5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 20:00:27 +00:00

Ignore interfaces that are not up

This commit is contained in:
Neil Alexander 2018-09-25 19:46:06 +01:00
parent 6844b9df51
commit b7f2f8b55c
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -138,6 +138,9 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) {
var conn net.Conn var conn net.Conn
var err error var err error
if socksaddr != nil { if socksaddr != nil {
if sintf != "" {
return
}
var dialer proxy.Dialer var dialer proxy.Dialer
dialer, err = proxy.SOCKS5("tcp", *socksaddr, nil, proxy.Direct) dialer, err = proxy.SOCKS5("tcp", *socksaddr, nil, proxy.Direct)
if err != nil { if err != nil {
@ -159,6 +162,9 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) {
if sintf != "" { if sintf != "" {
ief, err := net.InterfaceByName(sintf) ief, err := net.InterfaceByName(sintf)
if err == nil { if err == nil {
if ief.Flags & net.FlagUp == 0 {
return
}
addrs, err := ief.Addrs() addrs, err := ief.Addrs()
if err == nil { if err == nil {
dst, err := net.ResolveTCPAddr("tcp", saddr) dst, err := net.ResolveTCPAddr("tcp", saddr)
@ -175,10 +181,10 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) {
IP: src, IP: src,
Port: 0, Port: 0,
} }
break
} }
} }
if dialer.LocalAddr == nil { if dialer.LocalAddr == nil {
iface.core.log.Println("No valid source address found for interface", sintf)
return return
} }
} }