mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 07:11:40 +00:00
Ignore interfaces that are not up
This commit is contained in:
parent
6844b9df51
commit
b7f2f8b55c
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user