Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
use public dns first, then use net.dns1 server
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed May 10, 2018
1 parent e6b3e2c commit e964f62
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ var (
)

func dnsLookupHost(hostname string) (ip net.IP, err error) {
for _, dnsServer := range []string{getProperty("net.dns1"), "114.114.114.114", "8.8.4.4"} {
if dnsServer == "" {
continue
}
for _, dnsServer := range []string{"114.114.114.114", "8.8.4.4"} {
ip, err = dnsLookupHostWithDNS(hostname, dnsServer)
if err == nil {
return
}
}
return
defaultDNSResolver := getProperty("net.dns1")
if defaultDNSResolver == "" {
return
}
return dnsLookupHostWithDNS(hostname, defaultDNSResolver)
}

func dnsLookupHostWithDNS(hostname string, dnsServer string) (ip net.IP, err error) {
Expand Down

0 comments on commit e964f62

Please sign in to comment.