Cleanup - audit

This commit is contained in:
jdl
2026-06-13 19:55:16 +02:00
parent 2e19f0945f
commit b6052ee7b8
5 changed files with 34 additions and 43 deletions

View File

@@ -19,17 +19,18 @@ const (
)
type Peer struct {
wgPeer wgtypes.Peer
VPNIP netip.Addr // VPN IP address.
Name string // Human-readable DNS label.
IsRelay bool // Peer is a relay.
IsPublic bool // Peer has a public IP.
EndpointV4 netip.AddrPort // Reported IPv4 endpoint.
EndpointV6 netip.AddrPort // Reported IPv6 endpoint.
RTT time.Duration // Round-trip time.
State PeerState // Current routing state; updated on each devXxx call.
Role control.Role // Client initiates pings; server responds.
SignPubKey [32]byte // nacl/sign public key for verifying multicast beacons.
wgPeer wgtypes.Peer
VPNIP netip.Addr // VPN IP address.
Name string // Human-readable DNS label.
IsRelay bool // Peer is a relay.
IsPublic bool // Peer has a public IP.
EndpointV4 netip.AddrPort // Reported IPv4 endpoint.
EndpointV6 netip.AddrPort // Reported IPv6 endpoint.
EndpointLAN netip.AddrPort // Discovered via multicast.
RTT time.Duration // Round-trip time.
State PeerState // Current routing state; updated on each devXxx call.
Role control.Role // Client initiates pings; server responds.
SignPubKey [32]byte // nacl/sign public key for verifying multicast beacons.
}
// PubKey is the wireguard public key.
@@ -62,7 +63,13 @@ func (p *Peer) CanRelay() bool {
}
func (p *Peer) PreferredEndpoint() netip.AddrPort {
return preferredEndpoint(p.EndpointV4, p.EndpointV6)
if p.EndpointLAN.IsValid() {
return p.EndpointLAN
} else if p.EndpointV4.IsValid() {
return p.EndpointV4
} else {
return p.EndpointV6
}
}
func (p *Peer) UpdateEndpoints(v4, v6 netip.AddrPort) {