-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webconnectivitylte): use random DNS-over-UDP resolver (#1500)
Using one resolver at random from a pool of some has been requested by users. While there link all the remaining TODOs to existing open issues. Closes ooni/probe#2669. Here are three measurements showcasing this new feature: 1. [using 1.0.0.1:53](https://explorer.ooni.org/m/20240208153440.990674_IT_webconnectivity_646b76338342a1a8) 2. [using 1.1.1.1:53](https://explorer.ooni.org/m/20240208154552.863516_IT_webconnectivity_97c3ed1a6bbebd5e) 3. [using 9.9.9.9:53](https://explorer.ooni.org/m/20240208154616.549959_IT_webconnectivity_2515d794df2ebd34)
- Loading branch information
1 parent
fee6e01
commit 2e43eea
Showing
9 changed files
with
97 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,22 @@ | ||
package webconnectivityalgo | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
) | ||
|
||
func TestRandomDNSOverUDPResolverEndpointIPv4(t *testing.T) { | ||
results := make(map[string]int64) | ||
const maxruns = 1024 | ||
for idx := 0; idx < maxruns; idx++ { | ||
endpoint := RandomDNSOverUDPResolverEndpointIPv4() | ||
results[endpoint]++ | ||
if _, _, err := net.SplitHostPort(endpoint); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
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