This commit is contained in:
jdl
2026-06-07 09:33:21 +02:00
parent 199f774ed3
commit cad200b9cc
16 changed files with 692 additions and 63 deletions

View File

@@ -15,10 +15,9 @@ func (a *App) onPing(e PingEvent) {
}
now := time.Now()
peer.LastPing = now
peer.Up = true
// If we're the server, respond.
// If we're the server, respond - this is always necessary as it's used to
// know if peers are up or down.
if peer.Role == control.Server {
a.sendPing(peer, e.ping.ID, e.ping.PingTS)
}
@@ -35,7 +34,7 @@ func (a *App) onPing(e PingEvent) {
// We can only learn our own endpoint from directly-connected peers — Dst
// is the sender's observation of our WG handshake source.
if peer.State == StateDirect {
if peer.State() == StateDirect {
if dst := e.ping.Dst; dst.IsValid() {
if dst.Addr().Is4() {
a.selfV4 = dst
@@ -51,16 +50,11 @@ func (a *App) onPing(e PingEvent) {
func (a *App) addProbe(peer *Peer, v4, v6 netip.AddrPort) {
endpoint := preferredEndpoint(v4, v6)
if !endpoint.IsValid() || endpoint == peer.WGEndpoint {
if !endpoint.IsValid() || endpoint == peer.WGEndpoint() {
return
}
peer.Endpoint4 = v4
peer.Endpoint6 = v6
peer.WGEndpoint = endpoint
if peer.State == StateRelayed {
peer.State = StateProbing
}
a.devAddProbe(peer, endpoint)
}