Bug fix - peer Up calculation

This commit is contained in:
jdl
2026-06-15 06:17:52 +02:00
parent 797ab8bdef
commit d02f47cce6
2 changed files with 4 additions and 2 deletions

View File

@@ -17,6 +17,8 @@ func (a *App) onPing(e PingEvent) {
now := time.Now() now := time.Now()
peer.LastPing = now
// If we're the server, respond - this is always necessary as it's used to // If we're the server, respond - this is always necessary as it's used to
// know if peers are up or down. // know if peers are up or down.
if peer.Role == control.Server { if peer.Role == control.Server {

View File

@@ -7,7 +7,6 @@ import (
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"vppn/peer/control" "vppn/peer/control"
"vppn/peer/wginterface"
) )
type PeerState string type PeerState string
@@ -29,6 +28,7 @@ type Peer struct {
EndpointLAN netip.AddrPort // Discovered via multicast. EndpointLAN netip.AddrPort // Discovered via multicast.
EndpointWG netip.AddrPort // Current wireguard endpoint. EndpointWG netip.AddrPort // Current wireguard endpoint.
RTT time.Duration // Round-trip time. RTT time.Duration // Round-trip time.
LastPing time.Time // Last time we had a ping.
ProbeStart time.Time // When we started probing. ProbeStart time.Time // When we started probing.
State PeerState // Current routing state; updated on each devXxx call. State PeerState // Current routing state; updated on each devXxx call.
Role control.Role // Role in relation to the local application. 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 { 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 { func (p *Peer) CanRelay() bool {