-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport patches mentioned by ooni/probe#1912 (#635)
* [backport] refactor(stunreachability): input required and must be an URL (#630) Here we're refactoring stunreachability to not provide internally a default input and to take in input an URL rather than a string. The related ooni/spec change is ooni/spec#227. This diff has been extracted from #539. Because the original diff was large, I'm splitting it in a set of more easily manageable diffs. The reference issue is ooni/probe#1814, which is complex enough to require us to proceed incrementally. This diff WILL need to be backported to release/3.11. * [backport] refactor: create common package for holding STUN input (#631) We want stunreachability to use the same STUN servers used by snowflake, so let's start by making a common package holding the servers. Let's also use this new package in Snowflake. We're currently not using this package in stunreachability, but I am going to apply this as a subsequent diff. Reference issue: ooni/probe#1814. This issue is a bit complex to address in a single PR, so we are going to proceed incremntally. This diff was extracted from #539. * [backport] refactor: introduce and use InputOrStaticDefault (#632) This commit introduces a new `InputLoader` policy by which, if no input is provided, we use a static default input list. We also modify the code to use this policy for dnscheck and stunreachability, with proper input. We also modify `miniooni` to pass the new `ExperimentName` field to the `InputLoader` to indicate which default input list to use. This diff is part of a set of diffs aiming at fixing ooni/probe#1814 and has been extracted from #539. What remains to be done, after this diff has landed is to ensure things also work for ooniprobe and oonimkall. * [backport] fix(ooniprobe): dnscheck,stunreachability run w/ default input (#633) This diff is part of ooni/probe#1814 and teaches `ooniprobe` to run dnscheck and stunreachability by using the default static input feature of the `InputLoader`. I've manually tested that we can still run `websites` like we did before (including category filtering). I've also manually tested that now we can run `experimental` and get parseable results for dnscheck and stunreachability. With this diff in, we have fixed the original problem highlighted in the ooni/probe#1814 issue. Yet, because of the way in which I solved the problem, there is more work to do. My changes have broken stunreachability for mobile and now it's time I apply fixes to make it work again. This diff was extracted from #539, which at this point only basically contains the remaining fixes to ensure we can run stunreachability on mobile. Co-authored-by: Arturo Filastò <arturo@filasto.net> Co-authored-by: Arturo Filastò <arturo@filasto.net> * [backport] fix(oonimkall): run tests with InputOrStaticDefault policy (#634) Previous work to make ooni/probe#1814 possible has broken running stunreachability on mobile. This diff repairs the blunder and allows to run any experiment using InputOrStaticDefault with oonimkall. Diff extracted from #539. Co-authored-by: Arturo Filastò <arturo@filasto.net>
- Loading branch information
1 parent
dcf2986
commit 5723542
Showing
18 changed files
with
907 additions
and
429 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,42 @@ | ||
package nettests | ||
|
||
import ( | ||
"encoding/json" | ||
"context" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck" | ||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/run" | ||
"github.com/ooni/probe-cli/v3/internal/runtimex" | ||
engine "github.com/ooni/probe-cli/v3/internal/engine" | ||
"github.com/ooni/probe-cli/v3/internal/engine/model" | ||
) | ||
|
||
// DNSCheck nettest implementation. | ||
type DNSCheck struct{} | ||
|
||
var dnsCheckDefaultInput []string | ||
|
||
func dnsCheckMustMakeInput(input *run.StructuredInput) string { | ||
data, err := json.Marshal(input) | ||
runtimex.PanicOnError(err, "json.Marshal failed") | ||
return string(data) | ||
} | ||
|
||
func init() { | ||
// The following code just adds a minimal set of URLs to | ||
// test using DNSCheck, so we start exposing it. | ||
// | ||
// TODO(bassosimone): | ||
// | ||
// 1. we should be getting input from the backend instead of | ||
// having an hardcoded list of inputs here. | ||
// | ||
// 2. we should modify dnscheck to accept http3://... as a | ||
// shortcut for https://... with h3. If we don't do that, we | ||
// are stuck with the h3 results hiding h2 results in OONI | ||
// Explorer because they use the same URL. | ||
// | ||
// 3. it seems we have the problem that dnscheck results | ||
// appear as the `run` nettest in `ooniprobe list <ID>` because | ||
// dnscheck is run using the `run` functionality. | ||
dnsCheckDefaultInput = append(dnsCheckDefaultInput, dnsCheckMustMakeInput( | ||
&run.StructuredInput{ | ||
DNSCheck: dnscheck.Config{}, | ||
Name: "dnscheck", | ||
Input: "https://dns.google/dns-query", | ||
})) | ||
dnsCheckDefaultInput = append(dnsCheckDefaultInput, dnsCheckMustMakeInput( | ||
&run.StructuredInput{ | ||
DNSCheck: dnscheck.Config{}, | ||
Name: "dnscheck", | ||
Input: "https://cloudflare-dns.com/dns-query", | ||
})) | ||
func (n DNSCheck) lookupURLs(ctl *Controller) ([]string, error) { | ||
inputloader := &engine.InputLoader{ | ||
CheckInConfig: &model.CheckInConfig{ | ||
// not needed because we have default static input in the engine | ||
}, | ||
ExperimentName: "dnscheck", | ||
InputPolicy: engine.InputOrStaticDefault, | ||
Session: ctl.Session, | ||
SourceFiles: ctl.InputFiles, | ||
StaticInputs: ctl.Inputs, | ||
} | ||
testlist, err := inputloader.Load(context.Background()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ctl.BuildAndSetInputIdxMap(ctl.Probe.DB(), testlist) | ||
} | ||
|
||
// Run starts the nettest. | ||
func (n DNSCheck) Run(ctl *Controller) error { | ||
builder, err := ctl.Session.NewExperimentBuilder("run") | ||
builder, err := ctl.Session.NewExperimentBuilder("dnscheck") | ||
if err != nil { | ||
return err | ||
} | ||
urls, err := n.lookupURLs(ctl) | ||
if err != nil { | ||
return err | ||
} | ||
return ctl.Run(builder, dnsCheckDefaultInput) | ||
return ctl.Run(builder, urls) | ||
} |
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 |
---|---|---|
@@ -1,13 +1,42 @@ | ||
package nettests | ||
|
||
import ( | ||
"context" | ||
|
||
engine "github.com/ooni/probe-cli/v3/internal/engine" | ||
"github.com/ooni/probe-cli/v3/internal/engine/model" | ||
) | ||
|
||
// STUNReachability nettest implementation. | ||
type STUNReachability struct{} | ||
|
||
func (n STUNReachability) lookupURLs(ctl *Controller) ([]string, error) { | ||
inputloader := &engine.InputLoader{ | ||
CheckInConfig: &model.CheckInConfig{ | ||
// not needed because we have default static input in the engine | ||
}, | ||
ExperimentName: "stunreachability", | ||
InputPolicy: engine.InputOrStaticDefault, | ||
Session: ctl.Session, | ||
SourceFiles: ctl.InputFiles, | ||
StaticInputs: ctl.Inputs, | ||
} | ||
testlist, err := inputloader.Load(context.Background()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ctl.BuildAndSetInputIdxMap(ctl.Probe.DB(), testlist) | ||
} | ||
|
||
// Run starts the nettest. | ||
func (n STUNReachability) Run(ctl *Controller) error { | ||
builder, err := ctl.Session.NewExperimentBuilder("stunreachability") | ||
if err != nil { | ||
return err | ||
} | ||
return ctl.Run(builder, []string{""}) | ||
urls, err := n.lookupURLs(ctl) | ||
if err != nil { | ||
return err | ||
} | ||
return ctl.Run(builder, urls) | ||
} |
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
18 changes: 0 additions & 18 deletions
18
internal/engine/experiment/stunreachability/stunreachability_internal_test.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.