From 205b4efac7756abb85cb66bb11a8527534027eb9 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Tue, 14 Aug 2018 22:32:55 +0800 Subject: [PATCH] dns: use Direct dialer when dialer's domain equals to the query domain --- dns/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dns/client.go b/dns/client.go index 5b2694a..690e0bb 100644 --- a/dns/client.go +++ b/dns/client.go @@ -127,6 +127,11 @@ func (c *Client) exchange(qname string, reqBytes []byte, preferTCP bool) (server network = "tcp" dialer := c.dialer.NextDialer(qname + ":53") + // if we are resolving the dialer's domain, then use Direct to avoid denpency loop + if strings.Contains(dialer.Addr(), qname) { + dialer = proxy.Direct + } + // If client uses udp and no forwarders specified, use udp if !preferTCP && dialer.Addr() == "DIRECT" { network = "udp"