mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-03-31 22:50:19 +08:00
Remove branch
This commit is contained in:
parent
7aecdc148d
commit
6edfbe4b5c
17
allowlist.go
17
allowlist.go
@ -146,18 +146,11 @@ func (al *Allowlist) Remove(ma multiaddr.Multiaddr) error {
|
|||||||
for i > 0 {
|
for i > 0 {
|
||||||
i--
|
i--
|
||||||
if ipNetList[i].IP.Equal(ipnet.IP) && bytes.Equal(ipNetList[i].Mask, ipnet.Mask) {
|
if ipNetList[i].IP.Equal(ipnet.IP) && bytes.Equal(ipNetList[i].Mask, ipnet.Mask) {
|
||||||
if i == len(ipNetList)-1 {
|
// swap remove
|
||||||
// Trim this element from the end
|
ipNetList[i] = ipNetList[len(ipNetList)-1]
|
||||||
ipNetList = ipNetList[:i]
|
ipNetList = ipNetList[:len(ipNetList)-1]
|
||||||
// We only remove one thing
|
// We only remove one thing
|
||||||
break
|
break
|
||||||
} else {
|
|
||||||
// swap remove
|
|
||||||
ipNetList[i] = ipNetList[len(ipNetList)-1]
|
|
||||||
ipNetList = ipNetList[:len(ipNetList)-1]
|
|
||||||
// We only remove one thing
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user