(n *Nylon, wgStats map[state.NyPublicKey]device.PeerStatus)
| 178 | } |
| 179 | |
| 180 | func 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 | |
| 207 | func buildEndpoints(neigh *state.Neighbour) []*protocol.EndpointInfo { |
| 208 | eps := make([]*protocol.EndpointInfo, 0, len(neigh.Eps)) |
no test coverage detected