Fix: resolver dial context udp

This commit is contained in:
yaling888
2021-11-11 00:53:42 +08:00
parent 038cc1f6b5
commit d0c23998d2
5 changed files with 79 additions and 10 deletions

View File

@ -49,14 +49,14 @@ func (c *client) ExchangeContext(ctx context.Context, m *D.Msg) (*D.Msg, error)
}
var conn net.Conn
if c.proxyAdapter != "" && network == "tcp" {
conn, err = dialContextWithProxyAdapter(ctx, c.proxyAdapter, ip, c.port)
} else {
if c.proxyAdapter == "" {
options := []dialer.Option{}
if c.iface != "" {
options = append(options, dialer.WithInterface(c.iface))
}
conn, err = dialer.DialContext(ctx, network, net.JoinHostPort(c.host, c.port), options...)
conn, err = dialer.DialContext(ctx, network, net.JoinHostPort(ip.String(), c.port), options...)
} else {
conn, err = dialContextWithProxyAdapter(ctx, c.proxyAdapter, network, ip, c.port)
}
if err != nil {