crip/ripv2/timers.go
Jim Colderwood 46f0c8aedf restructure
2024-04-16 12:55:08 +01:00

24 lines
328 B
Go

package ripv2
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)
}
}()
}