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

Function handleStatus

core/ipc_handler.go:100–149  ·  view source on GitHub ↗
(n *Nylon, req *protocol.StatusRequest)

Source from the content-addressed store, hash-verified

98}
99
100func handleStatus(n *Nylon, req *protocol.StatusRequest) *protocol.IpcResponse {
101 activeEps := 0
102 for _, neigh := range n.RouterState.Neighbours {
103 for _, ep := range neigh.Eps {
104 if ep.IsActive() {
105 activeEps++
106 }
107 }
108 }
109
110 txBytes := uint64(0)
111 rxBytes := uint64(0)
112 wgStats := wireGuardPeerStats(n)
113 for _, stat := range wgStats {
114 txBytes += stat.TxBytes
115 rxBytes += stat.RxBytes
116 }
117
118 listenPort := uint32(n.LocalCfg.Port)
119 if n.Device != nil {
120 listenPort = uint32(n.Device.ListenPort())
121 }
122
123 return &protocol.IpcResponse{
124 Ok: true,
125 Response: &protocol.IpcResponse_Status{Status: &protocol.StatusResponse{
126 Node: &protocol.NodeStatus{
127 NodeId: string(n.LocalCfg.Id),
128 Interface: n.Interface,
129 PublicKey: keyString(n.LocalCfg.Key.Pubkey()),
130 ListenPort: listenPort,
131 ConfigTimestamp: n.CentralCfg.Timestamp,
132 TraceEnabled: n.DBG_trace_tc,
133 Advertised: buildAdvertisements(n),
134 Seqnos: buildSeqnos(n),
135 Stats: &protocol.NodeStats{
136 NeighbourCount: int32(len(n.RouterState.Neighbours)),
137 ActiveEndpointCount: int32(activeEps),
138 SelectedRouteCount: int32(len(n.RouterState.Routes)),
139 AdvertisedPrefixCount: int32(len(n.RouterState.Advertised)),
140 TxBytes: txBytes,
141 RxBytes: rxBytes,
142 },
143 },
144 Neighbours: buildNeighbours(n, wgStats),
145 Routes: buildRouteTables(n),
146 FeasibilityDistances: buildFeasibilityDistances(n),
147 }},
148 }
149}
150
151func buildAdvertisements(n *Nylon) []*protocol.Advertisement {
152 entries := make([]*protocol.Advertisement, 0, len(n.RouterState.Advertised))

Callers 1

HandleNylonIPCFunction · 0.85

Calls 10

wireGuardPeerStatsFunction · 0.85
keyStringFunction · 0.85
buildAdvertisementsFunction · 0.85
buildSeqnosFunction · 0.85
buildNeighboursFunction · 0.85
buildRouteTablesFunction · 0.85
ListenPortMethod · 0.80
PubkeyMethod · 0.80
IsActiveMethod · 0.65

Tested by

no test coverage detected