From b7f2f8b55c3047d6ce4fc527f1d37fde45c848a0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 25 Sep 2018 19:46:06 +0100 Subject: [PATCH] Ignore interfaces that are not up --- src/yggdrasil/tcp.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 4850899..8debba7 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -138,6 +138,9 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) { var conn net.Conn var err error if socksaddr != nil { + if sintf != "" { + return + } var dialer proxy.Dialer dialer, err = proxy.SOCKS5("tcp", *socksaddr, nil, proxy.Direct) if err != nil { @@ -159,6 +162,9 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) { if sintf != "" { ief, err := net.InterfaceByName(sintf) if err == nil { + if ief.Flags & net.FlagUp == 0 { + return + } addrs, err := ief.Addrs() if err == nil { dst, err := net.ResolveTCPAddr("tcp", saddr) @@ -175,10 +181,10 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) { IP: src, Port: 0, } + break } } if dialer.LocalAddr == nil { - iface.core.log.Println("No valid source address found for interface", sintf) return } }