MCPcopy Create free account
hub / github.com/encodeous/nylon / buildRouteTables

Function buildRouteTables

core/ipc_handler.go:245–270  ·  view source on GitHub ↗
(n *Nylon)

Source from the content-addressed store, hash-verified

243}
244
245func buildRouteTables(n *Nylon) *protocol.RouteTables {
246 tables := &protocol.RouteTables{}
247 for _, route := range n.RouterState.Routes {
248 tables.Selected = append(tables.Selected, selRouteProto(route))
249 }
250 slices.SortFunc(tables.Selected, func(a, b *protocol.SelRoute) int {
251 return comparePubRoute(a.PubRoute, b.PubRoute)
252 })
253 for prefix, route := range n.router.ForwardTable.Load().All() {
254 tables.Forward = append(tables.Forward, &protocol.RouteTableEntry{
255 Prefix: prefix.String(),
256 Nh: string(route.Nh),
257 Blackhole: route.Blackhole,
258 })
259 }
260 sortRouteTableEntries(tables.Forward)
261 for prefix, route := range n.router.ExitTable.Load().All() {
262 tables.Exit = append(tables.Exit, &protocol.RouteTableEntry{
263 Prefix: prefix.String(),
264 Nh: string(route.Nh),
265 Blackhole: route.Blackhole,
266 })
267 }
268 sortRouteTableEntries(tables.Exit)
269 return tables
270}
271
272func buildFeasibilityDistances(n *Nylon) []*protocol.FeasibilityDistance {
273 entries := make([]*protocol.FeasibilityDistance, 0, len(n.RouterState.Sources))

Callers 1

handleStatusFunction · 0.85

Calls 4

selRouteProtoFunction · 0.85
comparePubRouteFunction · 0.85
sortRouteTableEntriesFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected