1
0
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:
MetaCubeX
2022-06-04 21:18:49 +08:00
parent c045a4f2a7
commit 43d3a0c8ea
6 changed files with 275 additions and 18 deletions

View File

@ -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))
},
},
}