mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-17 14:19:54 +00:00
[management, client] Add IPv6 overlay support (#5631)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
"github.com/netbirdio/netbird/route"
|
||||
)
|
||||
|
||||
@@ -10,6 +12,10 @@ type RouterPair struct {
|
||||
Destination Network
|
||||
Masquerade bool
|
||||
Inverse bool
|
||||
// Dynamic indicates the route is domain-based. NAT rules for dynamic
|
||||
// routes are duplicated to the v6 table so that resolved AAAA records
|
||||
// are masqueraded correctly.
|
||||
Dynamic bool
|
||||
}
|
||||
|
||||
func GetInversePair(pair RouterPair) RouterPair {
|
||||
@@ -20,5 +26,17 @@ func GetInversePair(pair RouterPair) RouterPair {
|
||||
Destination: pair.Source,
|
||||
Masquerade: pair.Masquerade,
|
||||
Inverse: true,
|
||||
Dynamic: pair.Dynamic,
|
||||
}
|
||||
}
|
||||
|
||||
// ToV6NatPair creates a v6 counterpart of a v4 NAT pair with `::/0` source
|
||||
// and, for prefix destinations, `::/0` destination.
|
||||
func ToV6NatPair(pair RouterPair) RouterPair {
|
||||
v6 := pair
|
||||
v6.Source = Network{Prefix: netip.PrefixFrom(netip.IPv6Unspecified(), 0)}
|
||||
if v6.Destination.IsPrefix() {
|
||||
v6.Destination = Network{Prefix: netip.PrefixFrom(netip.IPv6Unspecified(), 0)}
|
||||
}
|
||||
return v6
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user