Bug fix - peer Up calculation
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user