Skip to content

Commit

Permalink
Fixed IPv6 0 initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
  • Loading branch information
rbrtbnfgl committed May 10, 2024
1 parent 6d18ae7 commit 3f521da
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"flag"
"fmt"
"math/big"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -502,10 +503,10 @@ func ReadCIDRFromSubnetFile(path string, CIDRKey string) ip.IP4Net {
prevCIDRs := ReadCIDRsFromSubnetFile(path, CIDRKey)
if len(prevCIDRs) == 0 {
log.Warningf("no subnet found for key: %s in file: %s", CIDRKey, path)
return ip.IP4Net{}
return ip.IP4Net{IP: 0, PrefixLen: 0}
} else if len(prevCIDRs) > 1 {
log.Errorf("error reading subnet: more than 1 entry found for key: %s in file %s: ", CIDRKey, path)
return ip.IP4Net{}
return ip.IP4Net{IP: 0, PrefixLen: 0}
} else {
return prevCIDRs[0]
}
Expand Down Expand Up @@ -537,10 +538,10 @@ func ReadIP6CIDRFromSubnetFile(path string, CIDRKey string) ip.IP6Net {
prevCIDRs := ReadIP6CIDRsFromSubnetFile(path, CIDRKey)
if len(prevCIDRs) == 0 {
log.Warningf("no subnet found for key: %s in file: %s", CIDRKey, path)
return ip.IP6Net{}
return ip.IP6Net{IP: (*ip.IP6)(big.NewInt(0)), PrefixLen: 0}
} else if len(prevCIDRs) > 1 {
log.Errorf("error reading subnet: more than 1 entry found for key: %s in file %s: ", CIDRKey, path)
return ip.IP6Net{}
return ip.IP6Net{IP: (*ip.IP6)(big.NewInt(0)), PrefixLen: 0}
} else {
return prevCIDRs[0]
}
Expand Down

0 comments on commit 3f521da

Please sign in to comment.