chore: reset resolver's connection after default interface changed

This commit is contained in:
wwqgtxx
2024-09-27 20:09:35 +08:00
parent 1633885794
commit acfc9f8baa
12 changed files with 103 additions and 37 deletions

View File

@@ -440,6 +440,10 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
//l.openAndroidHotspot(tunOptions)
if !l.options.AutoDetectInterface {
resolver.ResetConnection()
}
if options.FileDescriptor != 0 {
tunName = fmt.Sprintf("%s(fd=%d)", tunName, options.FileDescriptor)
}
@@ -507,6 +511,7 @@ func (l *Listener) FlushDefaultInterface() {
if old := dialer.DefaultInterface.Swap(autoDetectInterfaceName); old != autoDetectInterfaceName {
log.Warnln("[TUN] default interface changed by monitor, %s => %s", old, autoDetectInterfaceName)
iface.FlushCache()
resolver.ResetConnection() // reset resolver's connection after default interface changed
}
return
}