mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
Fix gosec and staticcheck lint errors from proto deprecation
This commit is contained in:
@@ -36,10 +36,12 @@ func EncodePrefix(p netip.Prefix) []byte {
|
||||
func DecodePrefix(b []byte) (netip.Prefix, error) {
|
||||
switch len(b) {
|
||||
case 5:
|
||||
addr := netip.AddrFrom4([4]byte(b[:4]))
|
||||
ip4 := [4]byte(b[:4])
|
||||
addr := netip.AddrFrom4(ip4)
|
||||
return netip.PrefixFrom(addr, int(b[4])), nil
|
||||
case 17:
|
||||
addr := netip.AddrFrom16([16]byte(b[:16])).Unmap()
|
||||
ip6 := [16]byte(b[:16])
|
||||
addr := netip.AddrFrom16(ip6).Unmap()
|
||||
bits := int(b[16])
|
||||
// Clamp prefix length when unmapping v4-mapped v6 to v4
|
||||
if addr.Is4() && bits > 32 {
|
||||
|
||||
Reference in New Issue
Block a user