Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google DNS: try to lookup the closest IPv6 server #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Usage of dingo-linux-amd64:
debugging level (default 2)
-gdns:auto
Google DNS: try to lookup the closest IPv4 server
-gdns:auto6
Google DNS: try to lookup the closest IPv6 server
-gdns:edns string
Google DNS: EDNS client subnet (set 0.0.0.0/0 to disable)
-gdns:host string
Expand Down
10 changes: 10 additions & 0 deletions gdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Gdns struct {
workers *int
server *string
auto *bool
auto6 *bool
sni *string
host *string
edns *string
Expand All @@ -34,6 +35,8 @@ func (r *Gdns) Init() {
"Google DNS: server address")
r.auto = flag.Bool("gdns:auto", false,
"Google DNS: try to lookup the closest IPv4 server")
r.auto6 = flag.Bool("gdns:auto6", false,
"Google DNS: try to lookup the closest IPv6 server")
r.sni = flag.String("gdns:sni", "www.google.com",
"Google DNS: SNI string to send (should match server certificate)")
r.host = flag.String("gdns:host", "dns.google.com",
Expand All @@ -56,6 +59,13 @@ func (R *Gdns) Start() {
R.server = &r4.Answer[0].Data
}
}
if *R.auto6 {
dbg(1, "resolving dns.google.com...")
r6 := R.resolve(NewHttps(*R.sni, false), *R.server, "dns.google.com", 28)
if r6.Status == 0 && len(r6.Answer) > 0 {
R.server = &r6.Answer[0].Data
}
}

dbg(1, "starting %d Google Public DNS client(s) querying server %s",
*R.workers, *R.server)
Expand Down