fix reservation checking
This commit is contained in:
parent
d8469533a7
commit
2a780ae88a
@ -177,6 +177,7 @@ func CheckReserved(nets []*netip.Prefix, revRecursive, recursive, excludePrivate
|
|||||||
if _, _, reserved, err = RetrieveReserved(); err != nil {
|
if _, _, reserved, err = RetrieveReserved(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, n := range nets {
|
for _, n := range nets {
|
||||||
if n == nil {
|
if n == nil {
|
||||||
continue
|
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.
|
// 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) {
|
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 rem []netip.Prefix
|
||||||
var reserved map[netip.Prefix]*IANAAddrNetResRecord
|
var reserved map[netip.Prefix]*IANAAddrNetResRecord
|
||||||
var sr = StructuredResults{
|
var sr = StructuredResults{
|
||||||
@ -281,8 +280,10 @@ func Contain(origPfx *netip.Prefix, nets []*netip.Prefix, remaining *netipx.IPSe
|
|||||||
}
|
}
|
||||||
if reserved != nil && len(reserved) > 0 {
|
if reserved != nil && len(reserved) > 0 {
|
||||||
s.Reservations = make([]*IANAAddrNetResRecord, len(reserved))
|
s.Reservations = make([]*IANAAddrNetResRecord, len(reserved))
|
||||||
for idx, r = range reserved {
|
idx := 0
|
||||||
|
for _, r := range reserved {
|
||||||
s.Reservations[idx] = r
|
s.Reservations[idx] = r
|
||||||
|
idx++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func RetrieveReserved() (ipv4, ipv6 IANARegistry, reserved map[netip.Prefix]*IAN
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ianaReserved4 = new(IANARegistry)
|
ianaReserved4 = new(IANARegistry)
|
||||||
ianaReserved4 = new(IANARegistry)
|
ianaReserved6 = new(IANARegistry)
|
||||||
if err = json.Unmarshal(dat4, ianaReserved4); err != nil {
|
if err = json.Unmarshal(dat4, ianaReserved4); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user