mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-25 16:19:07 +02:00
UDPv4 is sufficient! we always have 100.x overlay. IPv6 is additive
ipAllowed[0] is the v4
This commit is contained in:
@@ -17,14 +17,14 @@ type fakePQ struct {
|
||||
ok bool
|
||||
}
|
||||
|
||||
func (f fakePQ) OfferPayload(string) ([]byte, int) { return nil, 0 }
|
||||
func (f fakePQ) ShouldSendBootstrapOffer(string) bool { return false }
|
||||
func (f fakePQ) AnswerPayload(string, []byte) ([]byte, int) { return nil, 0 }
|
||||
func (f fakePQ) OnAnswer(string, []byte) {}
|
||||
func (f fakePQ) PSK(string) (wgtypes.Key, bool) { return f.psk, f.ok }
|
||||
func (f fakePQ) SetRemoteAddr(string, netip.AddrPort) {}
|
||||
func (f fakePQ) OnDataPathRekeyed(string, time.Duration) {}
|
||||
func (f fakePQ) OnDataPathDown(string) {}
|
||||
func (f fakePQ) OfferPayload(string) ([]byte, uint16) { return nil, 0 }
|
||||
func (f fakePQ) ShouldSendBootstrapOffer(string) bool { return false }
|
||||
func (f fakePQ) AnswerPayload(string, []byte) ([]byte, uint16) { return nil, 0 }
|
||||
func (f fakePQ) OnAnswer(string, []byte) {}
|
||||
func (f fakePQ) PSK(string) (wgtypes.Key, bool) { return f.psk, f.ok }
|
||||
func (f fakePQ) SetRemoteAddr(string, netip.AddrPort) {}
|
||||
func (f fakePQ) OnDataPathRekeyed(string, time.Duration) {}
|
||||
func (f fakePQ) OnDataPathDown(string) {}
|
||||
|
||||
// TestConn_presharedKey_PQ covers the post-quantum branch of presharedKey across the
|
||||
// three states that matter: a derived PSK is programmed, and — before one exists —
|
||||
|
||||
@@ -234,23 +234,17 @@ func (h *Handshaker) pqRegisterEndpoint(remotePort uint16) {
|
||||
h.config.PQ.SetRemoteAddr(h.config.Key, netip.AddrPortFrom(overlay, remotePort))
|
||||
}
|
||||
|
||||
// pqPeerOverlayAddr picks the peer's overlay address for the pq data path. The pq
|
||||
// transport binds on the local WG overlay IPv4, so an IPv4 AllowedIP is preferred; a v6
|
||||
// prefix is used only when this interface actually has a v6 overlay, and never in place
|
||||
// of a usable v4. Returns false when no suitable address exists.
|
||||
// pqPeerOverlayAddr returns the peer's IPv4 overlay address for the pq data path. A
|
||||
// RemotePeerConfig carries only the peer overlay (v4 /32, optionally v6 /128) — served
|
||||
// routes are programmed on WireGuard separately and never land in WgConfig.AllowedIps —
|
||||
// so AllowedIps[0] is the v4 overlay, matching conn.AllowedIP(). The transport is v4
|
||||
// (the overlay always has v4; v6 is additive). Returns false when no v4 overlay exists.
|
||||
func (h *Handshaker) pqPeerOverlayAddr() (netip.Addr, bool) {
|
||||
var v6 netip.Addr
|
||||
for _, p := range h.config.WgConfig.AllowedIps {
|
||||
a := p.Addr().Unmap()
|
||||
if a.Is4() {
|
||||
return a, true
|
||||
}
|
||||
if a.Is6() && !v6.IsValid() {
|
||||
v6 = a
|
||||
}
|
||||
if len(h.config.WgConfig.AllowedIps) == 0 {
|
||||
return netip.Addr{}, false
|
||||
}
|
||||
if v6.IsValid() && h.config.WgConfig.WgInterface.Address().HasIPv6() {
|
||||
return v6, true
|
||||
if a := h.config.WgConfig.AllowedIps[0].Addr().Unmap(); a.Is4() {
|
||||
return a, true
|
||||
}
|
||||
return netip.Addr{}, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user