fix range check

This commit is contained in:
Matthew R. Kasun 2022-08-23 16:35:36 -04:00
parent dbec514d5d
commit b2e5b239db
2 changed files with 3 additions and 3 deletions

View file

@ -271,7 +271,7 @@ func GetAllowedIPs(node, peer *models.Node) []net.IPNet {
egressIPs := getEgressIPs(node, peer)
// remove internet gateway if server
if node.IsServer == "yes" {
for i := len(egressIPs) - 1; i <= 0; i-- {
for i := len(egressIPs) - 1; i >= 0; i-- {
if egressIPs[i].IP.String() == "0.0.0.0/0" || egressIPs[i].IP.String() == "::/0" {
egressIPs = append(egressIPs[:i], egressIPs[i+1:]...)
}

View file

@ -48,7 +48,7 @@ func ManageZombies(ctx context.Context) {
case id := <-removeZombie:
found := false
if len(zombies) > 0 {
for i := len(zombies) - 1; i <= 0; i-- {
for i := len(zombies) - 1; i >= 0; i-- {
if zombies[i] == id {
logger.Log(1, "removing zombie from quaratine list", zombies[i])
zombies = append(zombies[:i], zombies[i+1:]...)
@ -61,7 +61,7 @@ func ManageZombies(ctx context.Context) {
}
case <-time.After(time.Second * ZOMBIE_TIMEOUT):
if len(zombies) > 0 {
for i := len(zombies) - 1; i <= 0; i-- {
for i := len(zombies) - 1; i >= 0; i-- {
node, err := GetNodeByID(zombies[i])
if err != nil {
logger.Log(1, "error retrieving zombie node", zombies[i], err.Error())