Skip unspecified IPs

This commit is contained in:
Audrius Butkevicius 2015-03-19 12:44:38 +00:00
parent 39eaa577e0
commit dc51476897

View File

@ -61,9 +61,13 @@ func GetLans() ([]*net.IPNet, error) {
for ; ipl != nil; ipl = ipl.Next {
ipStr := strings.Trim(string(ipl.IpAddress.String[:]), "\x00")
maskStr := strings.Trim(string(ipl.IpMask.String[:]), "\x00")
ip := net.ParseIP(ipStr)
maskip := net.ParseIP(maskStr)
if ip.IsUnspecified() || maskip.IsUnspecified() {
continue
}
nets = append(nets, &net.IPNet{
IP: net.ParseIP(ipStr),
IP: ip,
Mask: net.IPv4Mask(
maskip[net.IPv6len-net.IPv4len],
maskip[net.IPv6len-net.IPv4len+1],