切换为默认的dns解析;增加resolver=system的支持
This commit is contained in:
@@ -82,6 +82,11 @@ func NewExchanger(addr string, opts ...Option) (Exchanger, error) {
|
||||
opt(&options)
|
||||
}
|
||||
|
||||
addr = strings.TrimSpace(addr)
|
||||
if isSystemResolverAddr(addr) {
|
||||
return newSystemExchanger(addr, options), nil
|
||||
}
|
||||
|
||||
if !strings.Contains(addr, "://") {
|
||||
addr = "udp://" + addr
|
||||
}
|
||||
@@ -143,6 +148,15 @@ func NewExchanger(addr string, opts ...Option) (Exchanger, error) {
|
||||
return ex, nil
|
||||
}
|
||||
|
||||
func isSystemResolverAddr(addr string) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(addr)) {
|
||||
case "system", "auto", "system://", "auto://":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (ex *exchanger) Exchange(ctx context.Context, msg []byte) ([]byte, error) {
|
||||
if ex.network == "https" {
|
||||
return ex.dohExchange(ctx, msg)
|
||||
|
||||
Reference in New Issue
Block a user