crip/ripv2/routes/timers.go
Jim Colderwood 9d18b81f81 Route timer
2024-04-11 21:15:36 +01:00

24 lines
329 B
Go

package routes
import (
"time"
)
func (r *Routes) Timer() {
t := time.NewTimer(time.Minute * 1)
go func() {
for {
<-t.C
r.Lock()
for k, route := range r.Routes {
if time.Since(route.TTL) >= time.Minute*2 {
delete(r.Routes, k)
continue
}
}
r.Unlock()
t.Reset(time.Minute * 1)
}
}()
}