Cleanup - audit

This commit is contained in:
jdl
2026-06-13 19:55:16 +02:00
parent 2e19f0945f
commit b6052ee7b8
5 changed files with 34 additions and 43 deletions

View File

@@ -2,6 +2,7 @@ package peer
import (
"log"
"net/netip"
"time"
"vppn/peer/control"
@@ -28,6 +29,12 @@ func (a *App) onTick() {
}
switch p.State {
case StateRelayed:
// If we have an ep to probe, add it.
if ep := p.PreferredEndpoint(); ep.IsValid() {
a.devAddProbe(p, ep)
}
case StateProbing:
// Promote probing peers to direct once alive (direct path confirmed
// working).
@@ -39,9 +46,13 @@ func (a *App) onTick() {
if p.IsPublic || a.isPublic || p.Up() {
break
}
// Stale non-public direct peer: demote to probing so WireGuard
// resumes handshake attempts on the direct path.
a.devAddProbe(p, p.PreferredEndpoint())
// Stale non-public direct peer: demote to relayed and wait for new IP
// information.
p.EndpointV4 = netip.AddrPort{}
p.EndpointV6 = netip.AddrPort{}
p.EndpointLAN = netip.AddrPort{}
a.devAddPeer(p)
}
}