This commit is contained in:
jdl
2026-06-09 07:40:06 +02:00
parent 3968fd8f16
commit 1c304767b8
5 changed files with 46 additions and 12 deletions

View File

@@ -5,7 +5,6 @@ import (
"time"
"vppn/peer/control"
"vppn/peer/wginterface"
)
func (a *App) onTick() {
@@ -29,16 +28,27 @@ func (a *App) onTick() {
switch p.State {
case StateProbing:
// Promote probing peers to direct once alive (direct path confirmed
// working).
if time.Since(p.LastHandshakeTime()) < wginterface.SessionTimeout {
a.devAddDirect(p, p.WGEndpoint())
if p.Up() {
// Direct handshake succeeded; WG entry already correct.
p.State = StateDirect
} else if time.Now().After(p.probeDeadline) {
// Probe timed out — revert to relay.
if a.relay != nil {
a.devAddRelayed(p, a.relay.VPNIP)
} else {
a.devAddPeer(p)
}
}
case StateDirect:
// Demote stale non-public direct peers back to probing.
// Demotion skips StateProbing — only probe when there is positive
// evidence of a direct path (ping or multicast beacon).
if !p.IsPublic && !p.Up() {
a.devAddProbe(p, p.WGEndpoint())
if a.relay != nil {
a.devAddRelayed(p, a.relay.VPNIP)
} else {
a.devAddPeer(p)
}
}
}
}