WIP
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user