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

Function buildNeighbours

core/ipc_handler.go:180–205  ·  view source on GitHub ↗
(n *Nylon, wgStats map[state.NyPublicKey]device.PeerStatus)

Source from the content-addressed store, hash-verified

178}
179
180func buildNeighbours(n *Nylon, wgStats map[state.NyPublicKey]device.PeerStatus) []*protocol.NeighbourInfo {
181 ids := slices.Clone(n.GetPeers(n.LocalCfg.Id))
182 slices.Sort(ids)
183 neighbours := make([]*protocol.NeighbourInfo, 0, len(ids))
184 for _, id := range ids {
185 cfg := n.GetNode(id)
186 neigh := n.RouterState.GetNeighbour(id)
187 eps := make([]*protocol.EndpointInfo, 0)
188 routes := make([]*protocol.NeighRoute, 0)
189 if neigh != nil {
190 eps = buildEndpoints(neigh)
191 routes = buildNeighRoutes(neigh)
192 }
193 stat := wgStats[cfg.PubKey]
194 neighbours = append(neighbours, &protocol.NeighbourInfo{
195 PeerId: string(id),
196 PublicKey: keyString(cfg.PubKey),
197 PassiveClient: n.IsClient(id),
198 Endpoints: eps,
199 Routes: routes,
200 Advertised: advertisementsForNode(n, id),
201 Wireguard: wireGuardPeerStatsProto(stat),
202 })
203 }
204 return neighbours
205}
206
207func buildEndpoints(neigh *state.Neighbour) []*protocol.EndpointInfo {
208 eps := make([]*protocol.EndpointInfo, 0, len(neigh.Eps))

Callers 1

handleStatusFunction · 0.85

Calls 10

buildEndpointsFunction · 0.85
buildNeighRoutesFunction · 0.85
keyStringFunction · 0.85
advertisementsForNodeFunction · 0.85
wireGuardPeerStatsProtoFunction · 0.85
CloneMethod · 0.80
GetNeighbourMethod · 0.80
IsClientMethod · 0.80
GetPeersMethod · 0.45
GetNodeMethod · 0.45

Tested by

no test coverage detected