crip/ripv2/timers.go
Jim Colderwood 2d381d2a85 fib update
2024-04-18 14:32:35 +01:00

24 lines
327 B
Go

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