mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-03 08:11:50 +00:00
Skip unspecified IPs
This commit is contained in:
parent
39eaa577e0
commit
dc51476897
@ -61,9 +61,13 @@ func GetLans() ([]*net.IPNet, error) {
|
|||||||
for ; ipl != nil; ipl = ipl.Next {
|
for ; ipl != nil; ipl = ipl.Next {
|
||||||
ipStr := strings.Trim(string(ipl.IpAddress.String[:]), "\x00")
|
ipStr := strings.Trim(string(ipl.IpAddress.String[:]), "\x00")
|
||||||
maskStr := strings.Trim(string(ipl.IpMask.String[:]), "\x00")
|
maskStr := strings.Trim(string(ipl.IpMask.String[:]), "\x00")
|
||||||
|
ip := net.ParseIP(ipStr)
|
||||||
maskip := net.ParseIP(maskStr)
|
maskip := net.ParseIP(maskStr)
|
||||||
|
if ip.IsUnspecified() || maskip.IsUnspecified() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
nets = append(nets, &net.IPNet{
|
nets = append(nets, &net.IPNet{
|
||||||
IP: net.ParseIP(ipStr),
|
IP: ip,
|
||||||
Mask: net.IPv4Mask(
|
Mask: net.IPv4Mask(
|
||||||
maskip[net.IPv6len-net.IPv4len],
|
maskip[net.IPv6len-net.IPv4len],
|
||||||
maskip[net.IPv6len-net.IPv4len+1],
|
maskip[net.IPv6len-net.IPv4len+1],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user