mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
Rename peer_ips to peer_prefixes and simplify EncodePrefix with AsSlice
This commit is contained in:
@@ -17,19 +17,7 @@ import (
|
||||
// The address is always unmapped before encoding.
|
||||
func EncodePrefix(p netip.Prefix) []byte {
|
||||
addr := p.Addr().Unmap()
|
||||
raw := addr.As16()
|
||||
|
||||
if addr.Is4() {
|
||||
b := make([]byte, 5)
|
||||
copy(b, raw[12:16])
|
||||
b[4] = byte(p.Bits())
|
||||
return b
|
||||
}
|
||||
|
||||
b := make([]byte, 17)
|
||||
copy(b, raw[:])
|
||||
b[16] = byte(p.Bits())
|
||||
return b
|
||||
return append(addr.AsSlice(), byte(p.Bits()))
|
||||
}
|
||||
|
||||
// DecodePrefix decodes compact bytes into a netip.Prefix.
|
||||
|
||||
Reference in New Issue
Block a user