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

@@ -47,6 +47,7 @@ type Resolver interface {
ExchangeContext(ctx context.Context, m *dns.Msg) (msg *dns.Msg, err error)
Invalid() bool
ClearCache()
ResetConnection()
}
// LookupIPv4WithResolver same as LookupIPv4, but with a resolver
@@ -256,6 +257,15 @@ func LookupIPProxyServerHost(ctx context.Context, host string) ([]netip.Addr, er
return LookupIP(ctx, host)
}
func ResetConnection() {
if DefaultResolver != nil {
go DefaultResolver.ResetConnection()
}
if ProxyServerHostResolver != nil {
go ProxyServerHostResolver.ResetConnection()
}
}
func SortationAddr(ips []netip.Addr) (ipv4s, ipv6s []netip.Addr) {
for _, v := range ips {
if v.Unmap().Is4() {