From d02f47cce6cf13b8d451e614e0ab91c5766036c3 Mon Sep 17 00:00:00 2001 From: jdl Date: Mon, 15 Jun 2026 06:17:52 +0200 Subject: [PATCH] Bug fix - peer Up calculation --- peer/on_ping.go | 2 ++ peer/remote.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/peer/on_ping.go b/peer/on_ping.go index 9dc8264..3ee4cc6 100644 --- a/peer/on_ping.go +++ b/peer/on_ping.go @@ -17,6 +17,8 @@ func (a *App) onPing(e PingEvent) { now := time.Now() + peer.LastPing = now + // 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 { diff --git a/peer/remote.go b/peer/remote.go index b0961ca..e5625fc 100644 --- a/peer/remote.go +++ b/peer/remote.go @@ -7,7 +7,6 @@ import ( "golang.zx2c4.com/wireguard/wgctrl/wgtypes" "vppn/peer/control" - "vppn/peer/wginterface" ) type PeerState string @@ -29,6 +28,7 @@ type Peer struct { EndpointLAN netip.AddrPort // Discovered via multicast. EndpointWG netip.AddrPort // Current wireguard endpoint. RTT time.Duration // Round-trip time. + LastPing time.Time // Last time we had a ping. ProbeStart time.Time // When we started probing. State PeerState // Current routing state; updated on each devXxx call. Role control.Role // Role in relation to the local application. @@ -57,7 +57,7 @@ func (p *Peer) LastHandshakeTime() time.Time { } func (p *Peer) Up() bool { - return time.Since(p.wgPeer.LastHandshakeTime) < wginterface.SessionTimeout + return time.Since(p.LastPing) > 3*PingInterval } func (p *Peer) CanRelay() bool {