fix reservation checking

This commit is contained in:
brent saner 2025-03-10 09:57:25 -04:00
parent d8469533a7
commit 2a780ae88a
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 5 additions and 4 deletions

View File

@ -177,6 +177,7 @@ func CheckReserved(nets []*netip.Prefix, revRecursive, recursive, excludePrivate
if _, _, reserved, err = RetrieveReserved(); err != nil {
return
}

for _, n := range nets {
if n == nil {
continue
@ -219,8 +220,6 @@ func CheckReserved(nets []*netip.Prefix, revRecursive, recursive, excludePrivate
// Contain takes the results of a NetSplitter and returns a StructuredResults. The reservations are only checked against nets.
func Contain(origPfx *netip.Prefix, nets []*netip.Prefix, remaining *netipx.IPSet, splitter NetSplitter) (s *StructuredResults, err error) {

var idx int
var r *IANAAddrNetResRecord
var rem []netip.Prefix
var reserved map[netip.Prefix]*IANAAddrNetResRecord
var sr = StructuredResults{
@ -281,8 +280,10 @@ func Contain(origPfx *netip.Prefix, nets []*netip.Prefix, remaining *netipx.IPSe
}
if reserved != nil && len(reserved) > 0 {
s.Reservations = make([]*IANAAddrNetResRecord, len(reserved))
for idx, r = range reserved {
idx := 0
for _, r := range reserved {
s.Reservations[idx] = r
idx++
}
}
}

View File

@ -121,7 +121,7 @@ func RetrieveReserved() (ipv4, ipv6 IANARegistry, reserved map[netip.Prefix]*IAN
return
}
ianaReserved4 = new(IANARegistry)
ianaReserved4 = new(IANARegistry)
ianaReserved6 = new(IANARegistry)
if err = json.Unmarshal(dat4, ianaReserved4); err != nil {
return
}