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

Support for an additional EDNS client subnet for AAAA queries #21

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 @@ -52,6 +52,8 @@ Usage of dingo-linux-amd64:
Google DNS: try to lookup the closest IPv4 server
-gdns:edns string
Google DNS: EDNS client subnet (set 0.0.0.0/0 to disable)
-gdns:edns6 string
Google DNS: Optional IPv6 EDNS client subnet for AAAA queries
-gdns:host string
Google DNS: HTTP 'Host' header (real FQDN, encrypted in TLS) (default "dns.google.com")
-gdns:nopad
Expand Down
9 changes: 8 additions & 1 deletion gdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Gdns struct {
sni *string
host *string
edns *string
edns6 *string
nopad *bool
}

Expand All @@ -40,6 +41,8 @@ func (r *Gdns) Init() {
"Google DNS: HTTP 'Host' header (real FQDN, encrypted in TLS)")
r.edns = flag.String("gdns:edns", "",
"Google DNS: EDNS client subnet (set 0.0.0.0/0 to disable)")
r.edns6 = flag.String("gdns:edns6", "",
"Google DNS: Optional IPv6 EDNS client subnet for AAAA queries")
r.nopad = flag.Bool("gdns:nopad", false,
"Google DNS: disable random padding")
}
Expand Down Expand Up @@ -76,9 +79,13 @@ func (R *Gdns) resolve(https *Https, server string, qname string, qtype int) *Re
/* prepare */
v.Set("name", qname)
v.Set("type", fmt.Sprintf("%d", qtype))
if len(*R.edns) > 0 {

if (qtype == 28 && len(*R.edns6) > 0) {
v.Set("edns_client_subnet", *R.edns6)
} else if (len(*R.edns) > 0) {
v.Set("edns_client_subnet", *R.edns)
}

if !*R.nopad {
v.Set("random_padding", strings.Repeat(string(65+rand.Intn(26)), rand.Intn(500)))
}
Expand Down