mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
direct: avoid panic when an interface link is down
This commit is contained in:
1 parent
1c2ad64000
commit
0170fd7c98
2 files changed
+7
-4
No files matched your search
+6
-3
@@ -55,6 +55,11 @@ func (d *Direct) Dial(network, addr string) (c net.Conn, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// no ip available (so no dials made), maybe the interface link is down
|
||||
if c == nil && err == nil {
|
||||
err = errors.New("dial failed, maybe the interface link is down, please check it")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -113,9 +118,7 @@ func (d *Direct) IFaceIPs() (ips []net.IP) {
|
||||
}
|
||||
|
||||
for _, ipnet := range ipnets {
|
||||
if ip := ipnet.(*net.IPNet).IP; !ip.IsLinkLocalUnicast() {
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
ips = append(ips, ipnet.(*net.IPNet).IP) //!ip.IsLinkLocalUnicast()
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user