crip/ripv2/timers.go

24 lines
327 B
Go
Raw Normal View History

2024-04-16 12:55:08 +01:00
package ripv2
2024-04-11 21:15:36 +01:00
import (
"time"
)
func (r *Routes) Timer() {
t := time.NewTimer(time.Minute * 1)
go func() {
for {
<-t.C
r.Lock()
2024-04-18 14:32:35 +01:00
for _, route := range r.Routes {
2024-04-11 21:15:36 +01:00
if time.Since(route.TTL) >= time.Minute*2 {
2024-04-18 14:32:35 +01:00
route.FIB = DELETE
2024-04-11 21:15:36 +01:00
continue
}
}
r.Unlock()
t.Reset(time.Minute * 1)
}
}()
}