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

Function handleProbePong

core/nylon_endpoints.go:132–160  ·  view source on GitHub ↗
(n *Nylon, node state.NodeId, token uint64, ep conn.Endpoint)

Source from the content-addressed store, hash-verified

130}
131
132func handleProbePong(n *Nylon, node state.NodeId, token uint64, ep conn.Endpoint) {
133 // check if link exists
134 for _, neigh := range n.RouterState.Neighbours {
135 for _, dep := range neigh.Eps {
136 dpLink := dep.AsNylonEndpoint()
137 ap, err := dpLink.DynEP.Get()
138 if err == nil && ap == ep.DstIPPort() && neigh.Id == node {
139 linkHealth, ok := n.PingBuf.GetAndDelete(token)
140 if ok {
141 health := linkHealth.Value()
142 latency := time.Since(health.TimeSent)
143 // we have a link
144 if n.DBG_log_probe {
145 n.Log.Debug("probe back", "peer", node, "ping", latency)
146 }
147 dpLink.Renew()
148 dpLink.UpdatePing(latency)
149
150 // update wireguard endpoint
151 dpLink.WgEndpoint = ep
152
153 ComputeRoutes(n.RouterState, n)
154 }
155 return
156 }
157 }
158 }
159 n.Log.Warn("probe came back and couldn't find link", "from", ep.DstToString(), "node", node)
160}
161
162func (n *Nylon) probeLinks(active bool) error {
163 // probe links

Callers 1

handleProbeFunction · 0.85

Calls 7

ComputeRoutesFunction · 0.85
RenewMethod · 0.80
AsNylonEndpointMethod · 0.65
DstIPPortMethod · 0.65
UpdatePingMethod · 0.65
DstToStringMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected