mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-26 16:57:08 +00:00
chore: dialer will consider the routing of the local interface when auto-detect-interface in tun is enabled
for #1881 #1819
This commit is contained in:
@@ -404,8 +404,14 @@ func Dial(network, address string) (*TCPConn, error) {
|
||||
|
||||
var lTcpAddr *net.TCPAddr
|
||||
var lIpAddr *net.IPAddr
|
||||
if ifaceName := dialer.DefaultInterface.Load(); len(ifaceName) > 0 {
|
||||
rAddrPort := raddr.AddrPort()
|
||||
rAddrPort := raddr.AddrPort()
|
||||
ifaceName := dialer.DefaultInterface.Load()
|
||||
if ifaceName == "" {
|
||||
if finder := dialer.DefaultInterfaceFinder.Load(); finder != nil {
|
||||
ifaceName = finder.FindInterfaceName(rAddrPort.Addr())
|
||||
}
|
||||
}
|
||||
if len(ifaceName) > 0 {
|
||||
addr, err := dialer.LookupLocalAddrFromIfaceName(ifaceName, network, rAddrPort.Addr(), int(rAddrPort.Port()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user