mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-04 20:49:06 +02:00
Renames SetRemotePort to SetRemoteAddr
This commit is contained in:
@@ -90,9 +90,9 @@ type PQHandshaker interface {
|
|||||||
// PSK returns the peer's latest derived post-quantum PSK to program at WG
|
// PSK returns the peer's latest derived post-quantum PSK to program at WG
|
||||||
// peer-config time (the pull path). ok is false until one has been derived.
|
// peer-config time (the pull path). ok is false until one has been derived.
|
||||||
PSK(remoteKey string) (wgtypes.Key, bool)
|
PSK(remoteKey string) (wgtypes.Key, bool)
|
||||||
// SetRemotePort registers the peer's data-path endpoint from signalling: the peer's
|
// SetRemoteAddr registers the peer's data-path endpoint learned from signalling:
|
||||||
// WG overlay IP combined with its advertised pq UDP port.
|
// its WG overlay IP with the advertised pq UDP port.
|
||||||
SetRemotePort(remoteKey string, overlayIP netip.Addr, port int)
|
SetRemoteAddr(remoteKey string, addr netip.AddrPort)
|
||||||
// OnDataPathRekeyed signals a fresh WireGuard handshake for the peer; it clocks the
|
// OnDataPathRekeyed signals a fresh WireGuard handshake for the peer; it clocks the
|
||||||
// next chained PSK rotation pushed over the data path.
|
// next chained PSK rotation pushed over the data path.
|
||||||
OnDataPathRekeyed(remoteKey string)
|
OnDataPathRekeyed(remoteKey string)
|
||||||
|
|||||||
@@ -177,10 +177,11 @@ func (h *Handshaker) Listen(ctx context.Context) {
|
|||||||
// pqRegisterEndpoint feeds the post-quantum handshaker the peer's data-path endpoint
|
// pqRegisterEndpoint feeds the post-quantum handshaker the peer's data-path endpoint
|
||||||
// (its WG overlay IP plus the advertised pq UDP port) learned from a remote offer/answer.
|
// (its WG overlay IP plus the advertised pq UDP port) learned from a remote offer/answer.
|
||||||
func (h *Handshaker) pqRegisterEndpoint(remotePort int) {
|
func (h *Handshaker) pqRegisterEndpoint(remotePort int) {
|
||||||
if h.config.PQ == nil || remotePort <= 0 || len(h.config.WgConfig.AllowedIps) == 0 {
|
if h.config.PQ == nil || remotePort <= 0 || remotePort > 65535 || len(h.config.WgConfig.AllowedIps) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.config.PQ.SetRemotePort(h.config.Key, h.config.WgConfig.AllowedIps[0].Addr(), remotePort)
|
addr := netip.AddrPortFrom(h.config.WgConfig.AllowedIps[0].Addr(), uint16(remotePort))
|
||||||
|
h.config.PQ.SetRemoteAddr(h.config.Key, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handshaker) SendOffer() error {
|
func (h *Handshaker) SendOffer() error {
|
||||||
|
|||||||
@@ -81,14 +81,14 @@ func (p pqHandshaker) PSK(remoteKey string) (wgtypes.Key, bool) {
|
|||||||
return wgtypes.Key(psk), true
|
return wgtypes.Key(psk), true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRemotePort registers the peer's data-path endpoint (overlay IP + pq UDP port)
|
// SetRemoteAddr registers the peer's data-path endpoint (overlay IP + pq UDP port)
|
||||||
// learned from signalling. Sends only ever fire once the tunnel is up (clocked by
|
// learned from signalling. Sends only ever fire once the tunnel is up (clocked by
|
||||||
// OnDataPathRekeyed), so registering here is safe even before connection-up.
|
// OnDataPathRekeyed), so registering here is safe even before connection-up.
|
||||||
func (p pqHandshaker) SetRemotePort(remoteKey string, overlayIP netip.Addr, port int) {
|
func (p pqHandshaker) SetRemoteAddr(remoteKey string, addr netip.AddrPort) {
|
||||||
if port <= 0 || port > 65535 || !overlayIP.IsValid() {
|
if !addr.IsValid() || addr.Port() == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.mgr.AddPeer(pqkem.RemoteID(remoteKey), netip.AddrPortFrom(overlayIP, uint16(port)))
|
p.mgr.AddPeer(pqkem.RemoteID(remoteKey), addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnDataPathRekeyed clocks the next chained PSK rotation on a fresh WG handshake.
|
// OnDataPathRekeyed clocks the next chained PSK rotation on a fresh WG handshake.
|
||||||
|
|||||||
Reference in New Issue
Block a user