mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-26 12:23:12 +03:00
Handle TUN loopback in direct outbound
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/service"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
@@ -77,12 +78,12 @@ func dnsReadConfig(ctx context.Context, _ string) *dnsConfig {
|
||||
}{ifName: windows.UTF16PtrToString(address.FriendlyName), Addr: dnsServerAddr})
|
||||
}
|
||||
}
|
||||
var myInterface string
|
||||
var myInterfaces []string
|
||||
if networkManager := service.FromContext[adapter.NetworkManager](ctx); networkManager != nil {
|
||||
myInterface = networkManager.InterfaceMonitor().MyInterface()
|
||||
myInterfaces = networkManager.InterfaceMonitor().MyInterfaces()
|
||||
}
|
||||
for _, address := range dnsAddresses {
|
||||
if address.ifName == myInterface {
|
||||
if common.Contains(myInterfaces, address.ifName) {
|
||||
continue
|
||||
}
|
||||
conf.servers = append(conf.servers, net.JoinHostPort(address.String(), "53"))
|
||||
|
||||
Reference in New Issue
Block a user