mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-09-19 20:15:59 +08:00
chore: mix the proxy adapter and interface to dns client
This commit is contained in:
14
dns/doh.go
14
dns/doh.go
@ -97,11 +97,17 @@ func newDoHClient(url string, r *Resolver, proxyAdapter string) *dohClient {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if proxyAdapter == "" {
|
||||
return dialer.DialContext(ctx, "tcp", net.JoinHostPort(ip.String(), port))
|
||||
} else {
|
||||
return dialContextWithProxyAdapter(ctx, proxyAdapter, "tcp", ip, port)
|
||||
if proxyAdapter != "" {
|
||||
var conn net.Conn
|
||||
conn, err = dialContextWithProxyAdapter(ctx, proxyAdapter, "tcp", ip, port)
|
||||
if err == errProxyNotFound {
|
||||
options := []dialer.Option{dialer.WithInterface(proxyAdapter), dialer.WithRoutingMark(0)}
|
||||
conn, err = dialer.DialContext(ctx, "tcp", net.JoinHostPort(ip.String(), port), options...)
|
||||
}
|
||||
return conn, err
|
||||
}
|
||||
|
||||
return dialer.DialContext(ctx, "tcp", net.JoinHostPort(ip.String(), port))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user