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

Function handleProbePing

core/nylon_endpoints.go:89–130  ·  view source on GitHub ↗
(n *Nylon, node state.NodeId, wgEndpoint conn.Endpoint)

Source from the content-addressed store, hash-verified

87}
88
89func handleProbePing(n *Nylon, node state.NodeId, wgEndpoint conn.Endpoint) {
90 if node == n.LocalCfg.Id {
91 return
92 }
93 // check if link exists
94 for _, neigh := range n.RouterState.Neighbours {
95 for _, dep := range neigh.Eps {
96 dep := dep.AsNylonEndpoint()
97 ap, err := dep.DynEP.Get()
98 if err == nil && ap == wgEndpoint.DstIPPort() && neigh.Id == node {
99 // we have a link
100
101 // refresh wireguard ep
102 dep.WgEndpoint = wgEndpoint
103
104 wasInactive := !dep.IsActive()
105 dep.Renew()
106 if wasInactive {
107 ComputeRoutes(n.RouterState, n)
108 n.UpdateNeighbour(node)
109 }
110
111 if n.DBG_log_probe {
112 n.Log.Debug("probe from", "addr", ap.String())
113 }
114 return
115 }
116 }
117 }
118 // create a new link if we dont have a link
119 for _, neigh := range n.RouterState.Neighbours {
120 if neigh.Id == node {
121 newEp := state.NewEndpoint(state.NewDynamicEndpoint(wgEndpoint.DstIPPort().String()), true, wgEndpoint, &n.RouterTunables)
122 newEp.Renew()
123 neigh.Eps = append(neigh.Eps, newEp)
124 // push route update to improve convergence time
125 ComputeRoutes(n.RouterState, n)
126 n.UpdateNeighbour(node)
127 return
128 }
129 }
130}
131
132func handleProbePong(n *Nylon, node state.NodeId, token uint64, ep conn.Endpoint) {
133 // check if link exists

Callers 1

handleProbeFunction · 0.85

Calls 10

NewEndpointFunction · 0.92
NewDynamicEndpointFunction · 0.92
ComputeRoutesFunction · 0.85
RenewMethod · 0.80
UpdateNeighbourMethod · 0.80
AsNylonEndpointMethod · 0.65
DstIPPortMethod · 0.65
IsActiveMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected