dns: use Direct dialer when dialer's domain equals to the query domain

This commit is contained in:
nadoo 2018-08-14 22:32:55 +08:00
parent fbb78d50d4
commit 205b4efac7

View File

@ -127,6 +127,11 @@ func (c *Client) exchange(qname string, reqBytes []byte, preferTCP bool) (server
network = "tcp" network = "tcp"
dialer := c.dialer.NextDialer(qname + ":53") 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 client uses udp and no forwarders specified, use udp
if !preferTCP && dialer.Addr() == "DIRECT" { if !preferTCP && dialer.Addr() == "DIRECT" {
network = "udp" network = "udp"