🐛 修复 IPv6 only 机器取 IP 问题

This commit is contained in:
naiba
2021-05-23 10:25:40 +08:00
parent 7d5ea7ab99
commit 1c35caf0fb
5 changed files with 290 additions and 255 deletions

View File

@@ -108,8 +108,13 @@ func resolveIP(addr string, ipv6 bool) (string, error) {
}
m.RecursionDesired = true
dnsServer := "2606:4700:4700::1111"
if !ipv6 {
dnsServer = "1.1.1.1"
}
c := new(dns.Client)
r, _, err := c.Exchange(m, net.JoinHostPort("1.1.1.1", "53"))
r, _, err := c.Exchange(m, net.JoinHostPort(dnsServer, "53"))
if err != nil {
return "", err
}