-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webconnectivitylte): cycle through DNS-over-UDP resolvers
Cycling through resolvers has been requested by some users recently. While there address all the remaining TODOs. Closes ooni/probe#2669.
- Loading branch information
1 parent
576aa23
commit 05fb9dd
Showing
9 changed files
with
91 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package webconnectivityalgo | ||
|
||
import ( | ||
"math/rand" | ||
"net" | ||
) | ||
|
||
// dnsOverUDPResolverAddressIPv4 is the list of DNS-over-UDP IPv4 addresses. | ||
var dnsOverUDPResolverAddressIPv4 = []string{ | ||
// dns.google | ||
"8.8.8.8", | ||
"8.8.4.4", | ||
|
||
// dns.quad9.net | ||
"9.9.9.9", | ||
"149.112.112.112", | ||
|
||
// cloudflare-dns.com | ||
"1.1.1.1", | ||
"1.0.0.1", | ||
|
||
// doh.opendns.com | ||
"208.67.222.222", | ||
"208.67.220.220", | ||
} | ||
|
||
// RandomDNSOverUDPResolverEndpointIPv4 returns a random DNS-over-UDP resolver endpoint using IPv4. | ||
func RandomDNSOverUDPResolverEndpointIPv4() string { | ||
idx := rand.Intn(len(dnsOverUDPResolverAddressIPv4)) | ||
return net.JoinHostPort(dnsOverUDPResolverAddressIPv4[idx], "53") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package webconnectivityalgo | ||
|
||
import "testing" | ||
|
||
func TestRandomDNSOverUDPResolverEndpointIPv4(t *testing.T) { | ||
results := make(map[string]int64) | ||
const maxruns = 1024 | ||
for idx := 0; idx < maxruns; idx++ { | ||
endpoint := RandomDNSOverUDPResolverEndpointIPv4() | ||
results[endpoint]++ | ||
} | ||
t.Log(results) | ||
if len(results) < 3 { | ||
t.Fatal("expected to see at least three different results out of 1024 runs") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters