remove route & zone ageing
This commit is contained in:
parent
830f0dfde0
commit
fd2ab2918b
2 changed files with 17 additions and 17 deletions
14
route.go
14
route.go
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/sfiera/multitalk/pkg/ddp"
|
"github.com/sfiera/multitalk/pkg/ddp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxRouteAge = 10 * time.Minute // TODO: confirm
|
// const maxRouteAge = 10 * time.Minute // TODO: confirm
|
||||||
|
|
||||||
type Route struct {
|
type Route struct {
|
||||||
Extended bool
|
Extended bool
|
||||||
|
@ -42,9 +42,9 @@ func (rt *RoutingTable) LookupRoute(network ddp.Network) *Route {
|
||||||
if network < r.NetStart || network > r.NetEnd {
|
if network < r.NetStart || network > r.NetEnd {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if time.Since(r.LastSeen) > maxRouteAge {
|
// if time.Since(r.LastSeen) > maxRouteAge {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if bestRoute == nil {
|
if bestRoute == nil {
|
||||||
bestRoute = r
|
bestRoute = r
|
||||||
continue
|
continue
|
||||||
|
@ -86,9 +86,9 @@ func (rt *RoutingTable) ValidRoutes() []*Route {
|
||||||
if r.Peer == nil {
|
if r.Peer == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if time.Since(r.LastSeen) > maxRouteAge {
|
// if time.Since(r.LastSeen) > maxRouteAge {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
valid = append(valid, r)
|
valid = append(valid, r)
|
||||||
}
|
}
|
||||||
return valid
|
return valid
|
||||||
|
|
20
zones.go
20
zones.go
|
@ -25,7 +25,7 @@ import (
|
||||||
"github.com/sfiera/multitalk/pkg/ddp"
|
"github.com/sfiera/multitalk/pkg/ddp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxZoneAge = 10 * time.Minute // TODO: confirm
|
//const maxZoneAge = 10 * time.Minute // TODO: confirm
|
||||||
|
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
Network ddp.Network
|
Network ddp.Network
|
||||||
|
@ -75,9 +75,9 @@ func (zt *ZoneTable) Query(ns []ddp.Network) map[ddp.Network][]string {
|
||||||
zt.mu.Lock()
|
zt.mu.Lock()
|
||||||
defer zt.mu.Unlock()
|
defer zt.mu.Unlock()
|
||||||
for _, z := range zt.zones {
|
for _, z := range zt.zones {
|
||||||
if time.Since(z.LastSeen) > maxZoneAge {
|
// if time.Since(z.LastSeen) > maxZoneAge {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if _, ok := slices.BinarySearch(ns, z.Network); ok {
|
if _, ok := slices.BinarySearch(ns, z.Network); ok {
|
||||||
zs[z.Network] = append(zs[z.Network], z.Name)
|
zs[z.Network] = append(zs[z.Network], z.Name)
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,9 @@ func (zt *ZoneTable) LocalNames() []string {
|
||||||
seen := make(map[string]struct{})
|
seen := make(map[string]struct{})
|
||||||
zs := make([]string, 0, len(zt.zones))
|
zs := make([]string, 0, len(zt.zones))
|
||||||
for _, z := range zt.zones {
|
for _, z := range zt.zones {
|
||||||
if time.Since(z.LastSeen) > maxZoneAge {
|
// if time.Since(z.LastSeen) > maxZoneAge {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if !z.Local {
|
if !z.Local {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,9 @@ func (zt *ZoneTable) AllNames() []string {
|
||||||
seen := make(map[string]struct{})
|
seen := make(map[string]struct{})
|
||||||
zs := make([]string, 0, len(zt.zones))
|
zs := make([]string, 0, len(zt.zones))
|
||||||
for _, z := range zt.zones {
|
for _, z := range zt.zones {
|
||||||
if time.Since(z.LastSeen) > maxZoneAge {
|
// if time.Since(z.LastSeen) > maxZoneAge {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if _, s := seen[z.Name]; s {
|
if _, s := seen[z.Name]; s {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue