mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 08:46:38 +00:00
[management] Add IPv6 overlay addressing and capability gating (#5698)
This commit is contained in:
@@ -14,10 +14,15 @@ import (
|
||||
)
|
||||
|
||||
// EncodePrefix encodes a netip.Prefix into compact bytes.
|
||||
// The address is always unmapped before encoding.
|
||||
// The address is always unmapped before encoding. If unmapping produces a v4
|
||||
// address, the prefix length is clamped to 32.
|
||||
func EncodePrefix(p netip.Prefix) []byte {
|
||||
addr := p.Addr().Unmap()
|
||||
return append(addr.AsSlice(), byte(p.Bits()))
|
||||
bits := p.Bits()
|
||||
if addr.Is4() && bits > 32 {
|
||||
bits = 32
|
||||
}
|
||||
return append(addr.AsSlice(), byte(bits))
|
||||
}
|
||||
|
||||
// DecodePrefix decodes compact bytes into a netip.Prefix.
|
||||
|
||||
Reference in New Issue
Block a user