mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
direct: avoid panic when an interface link is down
This commit is contained in:
parent
1c2ad64000
commit
0170fd7c98
2
main.go
2
main.go
@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
// VERSION .
|
||||
const VERSION = "0.6.7"
|
||||
const VERSION = "0.6.8"
|
||||
|
||||
func main() {
|
||||
// read configs
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user