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

feat(webconnectivitylte): use random DNS-over-UDP resolver #1500

Merged
merged 3 commits into from
Feb 8, 2024
Merged
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
8 changes: 2 additions & 6 deletions internal/experiment/webconnectivitylte/dnsresolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ func (t *DNSResolvers) run(parentCtx context.Context) []DNSEntry {
whoamiSystemV4Out := make(chan []webconnectivityalgo.DNSWhoamiInfoEntry)
whoamiUDPv4Out := make(chan []webconnectivityalgo.DNSWhoamiInfoEntry)

// TODO(bassosimone): add opportunistic support for detecting
// whether DNS queries are answered regardless of dest addr by
// sending a few queries to root DNS servers
// TODO(https://github.com/ooni/probe/issues/1521): detecting DNS interception

udpAddress := t.udpAddress()

Expand Down Expand Up @@ -292,14 +290,12 @@ func (t *DNSResolvers) do53SplitQueries(
return
}

// TODO(bassosimone): maybe cycle through a bunch of well known addresses

// Returns the UDP resolver we should be using by default.
func (t *DNSResolvers) udpAddress() string {
if t.UDPAddress != "" {
return t.UDPAddress
}
return "8.8.4.4:53"
return webconnectivityalgo.RandomDNSOverUDPResolverEndpointIPv4()
}

// OpportunisticDNSOverHTTPSSingleton is the singleton used to keep
Expand Down
4 changes: 1 addition & 3 deletions internal/experiment/webconnectivitylte/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ func (m *Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
tk.Finalize(sess.Logger())

// set the test helper we used
// TODO(bassosimone): it may be more informative to know about all the
// test helpers we _tried_ to use, however the data format does not have
// support for that as far as I can tell...
// TODO(https://github.com/ooni/probe/issues/1857): record how we submitted
if th := tk.getTestHelper(); th != nil {
measurement.TestHelpers = map[string]interface{}{
"backend": th,
Expand Down
3 changes: 2 additions & 1 deletion internal/experiment/webconnectivitylte/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ type SummaryKeys struct {

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
// TODO(https://github.com/ooni/probe/issues/1684)
// TODO(https://github.com/ooni/probe/issues/1684): accessible not computed correctly (which
// is an issue that needs some extra investigation to understand how to fix it).
sk := &SummaryKeys{}
switch v := tk.Blocking.(type) {
case string:
Expand Down
19 changes: 17 additions & 2 deletions internal/netemx/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ const AddressThreeThOONIOrg = "209.97.183.73"
// AddressTHCloudfront is the IP address for d33d1gs9kpq1c5.cloudfront.net.
const AddressTHCloudfront = "52.85.15.84"

// AddressDNSQuad9Net is the IP address for dns.quad9.net.
const AddressDNSQuad9Net = "9.9.9.9"
// AddressDNSQuad9Net9999 is the IP address for dns.quad9.net.
const AddressDNSQuad9Net9999 = "9.9.9.9"

// AddressDNSQuad9NetOther is the the other IP address for dns.quad9.net.
const AddressDNSQuad9NetOther = "149.112.112.112"

// AddressMozillaCloudflareDNSCom is the IP address for mozilla.cloudflare-dns.com.
const AddressMozillaCloudflareDNSCom = "172.64.41.4"
Expand Down Expand Up @@ -83,3 +86,15 @@ const AddressCloudflareCache1 = "104.16.132.229"
// AddressHTTPBinCom1 is the first address associated an httpbin.com-like
// service which our QA environment exports as httpbin.com.
const AddressHTTPBinCom1 = "172.67.144.64"

// AddressCloudflareDNSCom1111 is the 1.1.1.1 adress.
const AddressCloudflareDNSCom1111 = "1.1.1.1"

// AddressCloudflareDNSCom1001 is the 1.0.0.1 adress.
const AddressCloudflareDNSCom1001 = "1.0.0.1"

// AddressOpenDNS222 is the 208.67.222.222 opendns.com address.
const AddressOpenDNS222 = "208.67.222.222"

// AddressOpenDNS220 is the 208.67.220.220 opendns.com address.
const AddressOpenDNS220 = "208.67.220.220"
2 changes: 1 addition & 1 deletion internal/netemx/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func Example_dnsOverUDPWithInternetScenario() {
net.JoinHostPort(netemx.RootResolverAddress, "53"),
net.JoinHostPort(netemx.AddressDNSGoogle8844, "53"),
net.JoinHostPort(netemx.AddressDNSGoogle8888, "53"),
net.JoinHostPort(netemx.AddressDNSQuad9Net, "53"),
net.JoinHostPort(netemx.AddressDNSQuad9Net9999, "53"),
net.JoinHostPort(netemx.AddressMozillaCloudflareDNSCom, "53"),
}

Expand Down
21 changes: 20 additions & 1 deletion internal/netemx/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,30 @@ var InternetScenario = []*ScenarioDomainAddresses{{
}, {
Domains: []string{"dns.quad9.net"},
Addresses: []string{
AddressDNSQuad9Net,
AddressDNSQuad9Net9999,
AddressDNSQuad9NetOther,
},
Role: ScenarioRolePublicDNS,
ServerNameMain: "dns.quad9.net",
ServerNameExtras: []string{},
}, {
Domains: []string{"cloudflare-dns.com"},
Addresses: []string{
AddressCloudflareDNSCom1001,
AddressCloudflareDNSCom1111,
},
Role: ScenarioRolePublicDNS,
ServerNameMain: "cloudflare-dns.com",
ServerNameExtras: []string{},
}, {
Domains: []string{"doh.opendns.com"},
Addresses: []string{
AddressOpenDNS220,
AddressOpenDNS222,
},
Role: ScenarioRolePublicDNS,
ServerNameMain: "doh.opendns.com",
ServerNameExtras: []string{},
}, {
Domains: []string{"mozilla.cloudflare-dns.com"},
Addresses: []string{
Expand Down
31 changes: 31 additions & 0 deletions internal/webconnectivityalgo/dnsoverudp.go
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")
}
22 changes: 22 additions & 0 deletions internal/webconnectivityalgo/dnsoverudp_test.go
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")
}
}
2 changes: 1 addition & 1 deletion internal/x/dslx/qa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestDNSLookupQA(t *testing.T) {
// create DNS lookup function
function := dslx.DNSLookupParallel(
dslx.DNSLookupGetaddrinfo(rt),
dslx.DNSLookupUDP(rt, net.JoinHostPort(netemx.AddressDNSQuad9Net, "53")),
dslx.DNSLookupUDP(rt, net.JoinHostPort(netemx.AddressDNSQuad9Net9999, "53")),
)

// create context
Expand Down
Loading