Refactor: udp would use the first DNS record instead of a random one

This commit is contained in:
yaling888
2022-06-22 03:17:15 +08:00
parent f1fc0ef2ff
commit e31be4edc2
7 changed files with 61 additions and 35 deletions

View File

@@ -36,7 +36,7 @@ func (c *client) ExchangeContext(ctx context.Context, m *D.Msg) (*D.Msg, error)
if c.r == nil {
return nil, fmt.Errorf("dns %s not a valid ip", c.host)
} else {
if ip, err = resolver.ResolveIPWithResolver(c.host, c.r); err != nil {
if ip, err = resolver.ResolveIPWithResolver(c.host, c.r, true); err != nil {
return nil, fmt.Errorf("use default dns resolve failed: %w", err)
}
c.host = ip.String()