diff --git a/peer/on_tick.go b/peer/on_tick.go index 92c385d..c1c30c3 100644 --- a/peer/on_tick.go +++ b/peer/on_tick.go @@ -21,12 +21,13 @@ func (a *App) onTick() { a.devRemove(&Peer{wgPeer: wgPeer}) continue } + p.wgPeer = wgPeer - if a.isPublic && !p.IsPublic { - if ep := p.WGEndpoint(); ep != p.EndpointV4 { - log.Printf("Client %s %s endpoint: %s -> %s", p.Name, p.VPNIP, p.EndpointV4, ep) - p.EndpointV4 = ep - } + + // Log endpoint changes. + if ep := p.WGEndpoint(); ep != p.EndpointWG { + log.Printf("Client %s %s endpoint: %s -> %s", p.Name, p.VPNIP, p.EndpointWG, ep) + p.EndpointWG = ep } // Send pings to peers where we're the client. diff --git a/peer/remote.go b/peer/remote.go index bdd860a..444a8be 100644 --- a/peer/remote.go +++ b/peer/remote.go @@ -27,6 +27,7 @@ type Peer struct { EndpointV4 netip.AddrPort // Reported IPv4 endpoint. EndpointV6 netip.AddrPort // Reported IPv6 endpoint. EndpointLAN netip.AddrPort // Discovered via multicast. + EndpointWG netip.AddrPort // Current wireguard port. RTT time.Duration // Round-trip time. State PeerState // Current routing state; updated on each devXxx call. Role control.Role // Role in relation to the local application.