mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 09:17:12 +00:00
chore: no longer used net.DefaultResolver when dns section is disabled, now is equally only "system://"
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
|
||||
package resolver
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname defaultNS net.defaultNS
|
||||
var defaultNS []string
|
||||
|
||||
func init() {
|
||||
defaultNS = []string{"114.114.114.114:53", "8.8.8.8:53"}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
//go:build !go1.22
|
||||
|
||||
// a simple standard lib fix from: https://github.com/golang/go/commit/33d4a5105cf2b2d549922e909e9239a48b8cefcc
|
||||
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
//go:linkname testHookHostsPath net.testHookHostsPath
|
||||
var testHookHostsPath string
|
||||
|
||||
func init() {
|
||||
if dir, err := windows.GetSystemDirectory(); err == nil {
|
||||
testHookHostsPath = dir + "/Drivers/etc/hosts"
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -23,6 +22,9 @@ var (
|
||||
// ProxyServerHostResolver resolve ip to proxies server host
|
||||
ProxyServerHostResolver Resolver
|
||||
|
||||
// SystemResolver always using system dns, and was init in dns module
|
||||
SystemResolver Resolver
|
||||
|
||||
// DisableIPv6 means don't resolve ipv6 host
|
||||
// default value is true
|
||||
DisableIPv6 = true
|
||||
@@ -72,14 +74,7 @@ func LookupIPv4WithResolver(ctx context.Context, host string, r Resolver) ([]net
|
||||
return r.LookupIPv4(ctx, host)
|
||||
}
|
||||
|
||||
ipAddrs, err := net.DefaultResolver.LookupNetIP(ctx, "ip4", host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(ipAddrs) == 0 {
|
||||
return nil, ErrIPNotFound
|
||||
}
|
||||
|
||||
return ipAddrs, nil
|
||||
return SystemResolver.LookupIPv4(ctx, host)
|
||||
}
|
||||
|
||||
// LookupIPv4 with a host, return ipv4 list
|
||||
@@ -128,14 +123,7 @@ func LookupIPv6WithResolver(ctx context.Context, host string, r Resolver) ([]net
|
||||
return r.LookupIPv6(ctx, host)
|
||||
}
|
||||
|
||||
ipAddrs, err := net.DefaultResolver.LookupNetIP(ctx, "ip6", host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(ipAddrs) == 0 {
|
||||
return nil, ErrIPNotFound
|
||||
}
|
||||
|
||||
return ipAddrs, nil
|
||||
return SystemResolver.LookupIPv6(ctx, host)
|
||||
}
|
||||
|
||||
// LookupIPv6 with a host, return ipv6 list
|
||||
@@ -177,14 +165,7 @@ func LookupIPWithResolver(ctx context.Context, host string, r Resolver) ([]netip
|
||||
return []netip.Addr{ip}, nil
|
||||
}
|
||||
|
||||
ips, err := net.DefaultResolver.LookupNetIP(ctx, "ip", host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(ips) == 0 {
|
||||
return nil, ErrIPNotFound
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
return SystemResolver.LookupIP(ctx, host)
|
||||
}
|
||||
|
||||
// LookupIP with a host, return ip
|
||||
|
||||
Reference in New Issue
Block a user