From a4d4b68befe868ff4406cbe9c11fdd8599d37b7f Mon Sep 17 00:00:00 2001 From: Lanius-collaris <55432068+Lanius-collaris@users.noreply.github.com> Date: Sat, 23 Mar 2024 00:08:11 +0800 Subject: [PATCH 1/4] fix torsf (dirty) --- internal/experiment/torsf/torsf.go | 10 ++++++++- internal/experiment/torsf/torsf_test.go | 2 +- internal/ptx/snowflake.go | 27 +++++++++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/internal/experiment/torsf/torsf.go b/internal/experiment/torsf/torsf.go index f61d6b9781..c209dbc8b5 100644 --- a/internal/experiment/torsf/torsf.go +++ b/internal/experiment/torsf/torsf.go @@ -25,7 +25,7 @@ import ( // We may want to have a single implementation for both nettests in the future. // testVersion is the experiment version. -const testVersion = "0.5.0" +const testVersion = "0.5.1" // Config contains the experiment config. type Config struct { @@ -37,6 +37,9 @@ type Config struct { // RendezvousMethod allows to choose the method with which to rendezvous. RendezvousMethod string `ooni:"Choose the method with which to rendezvous. Must be one of amp and domain_fronting. Leaving this field empty means we should use the default."` + + BrokerURL string `ooni:"TODO"` + FrontDomain string `ooni:"TODO"` } // TestKeys contains the experiment's result. @@ -176,6 +179,11 @@ func (m *Measurer) setup(ctx context.Context, // cannot run the experiment with unknown rendezvous method return nil, nil, err } + if rm.Name() == "domain_fronting" { + t1 := rm.(*ptx.SnowflakeRendezvousMethodDomainFronting) + t1.URL = m.config.BrokerURL + t1.Front = m.config.FrontDomain + } sfdialer := ptx.NewSnowflakeDialerWithRendezvousMethod(rm) ptl := &ptx.Listener{ ExperimentByteCounter: bytecounter.ContextExperimentByteCounter(ctx), diff --git a/internal/experiment/torsf/torsf_test.go b/internal/experiment/torsf/torsf_test.go index f7c2301810..5ecc94e41e 100644 --- a/internal/experiment/torsf/torsf_test.go +++ b/internal/experiment/torsf/torsf_test.go @@ -25,7 +25,7 @@ func TestExperimentNameAndVersion(t *testing.T) { if m.ExperimentName() != "torsf" { t.Fatal("invalid experiment name") } - if m.ExperimentVersion() != "0.5.0" { + if m.ExperimentVersion() != "0.5.1" { t.Fatal("invalid experiment version") } } diff --git a/internal/ptx/snowflake.go b/internal/ptx/snowflake.go index cf6cd0c352..766acd848a 100644 --- a/internal/ptx/snowflake.go +++ b/internal/ptx/snowflake.go @@ -27,25 +27,36 @@ type SnowflakeRendezvousMethod interface { // NewSnowflakeRendezvousMethodDomainFronting is a rendezvous method // that uses domain fronting to perform the rendezvous. func NewSnowflakeRendezvousMethodDomainFronting() SnowflakeRendezvousMethod { - return &snowflakeRendezvousMethodDomainFronting{} + return &SnowflakeRendezvousMethodDomainFronting{} } -type snowflakeRendezvousMethodDomainFronting struct{} +type SnowflakeRendezvousMethodDomainFronting struct { + URL string + Front string +} -func (d *snowflakeRendezvousMethodDomainFronting) Name() string { +func (d *SnowflakeRendezvousMethodDomainFronting) Name() string { return "domain_fronting" } -func (d *snowflakeRendezvousMethodDomainFronting) AMPCacheURL() string { +func (d *SnowflakeRendezvousMethodDomainFronting) AMPCacheURL() string { return "" } -func (d *snowflakeRendezvousMethodDomainFronting) BrokerURL() string { - return "https://snowflake-broker.torproject.net.global.prod.fastly.net/" +func (d *SnowflakeRendezvousMethodDomainFronting) BrokerURL() string { + if d.URL != "" { + return d.URL + } else { + return "https://1098762253.rsc.cdn77.org/" + } } -func (d *snowflakeRendezvousMethodDomainFronting) FrontDomain() string { - return "foursquare.com" +func (d *SnowflakeRendezvousMethodDomainFronting) FrontDomain() string { + if d.Front != "" { + return d.Front + } else { + return "www.phpmyadmin.net" + } } // NewSnowflakeRendezvousMethodAMP is a rendezvous method that From 1692da6eb342745ed53f4c291b636368f41f5273 Mon Sep 17 00:00:00 2001 From: Lanius-collaris <55432068+Lanius-collaris@users.noreply.github.com> Date: Sun, 24 Mar 2024 20:38:47 +0800 Subject: [PATCH 2/4] Update snowflake_test.go --- internal/ptx/snowflake_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/ptx/snowflake_test.go b/internal/ptx/snowflake_test.go index 0c2d8a6f26..68254dec5d 100644 --- a/internal/ptx/snowflake_test.go +++ b/internal/ptx/snowflake_test.go @@ -16,11 +16,11 @@ func TestSnowflakeMethodDomainFronting(t *testing.T) { if meth.AMPCacheURL() != "" { t.Fatal("invalid amp cache URL") } - const brokerURL = "https://snowflake-broker.torproject.net.global.prod.fastly.net/" + const brokerURL = "https://1098762253.rsc.cdn77.org/" if meth.BrokerURL() != brokerURL { t.Fatal("invalid broker URL") } - const frontDomain = "foursquare.com" + const frontDomain = "www.phpmyadmin.net" if meth.FrontDomain() != frontDomain { t.Fatal("invalid front domain") } @@ -54,7 +54,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { if err != nil { t.Fatal(err) } - if _, ok := meth.(*snowflakeRendezvousMethodDomainFronting); !ok { + if _, ok := meth.(*SnowflakeRendezvousMethodDomainFronting); !ok { t.Fatal("unexpected method type") } }) @@ -64,7 +64,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { if err != nil { t.Fatal(err) } - if _, ok := meth.(*snowflakeRendezvousMethodDomainFronting); !ok { + if _, ok := meth.(*SnowflakeRendezvousMethodDomainFronting); !ok { t.Fatal("unexpected method type") } }) @@ -92,7 +92,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { func TestNewSnowflakeDialer(t *testing.T) { dialer := NewSnowflakeDialer() - _, ok := dialer.RendezvousMethod.(*snowflakeRendezvousMethodDomainFronting) + _, ok := dialer.RendezvousMethod.(*SnowflakeRendezvousMethodDomainFronting) if !ok { t.Fatal("invalid rendezvous method type") } From bbc98e094b76cb79e9cb07b5ec6904b19113949f Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 25 Mar 2024 14:25:36 +0100 Subject: [PATCH 3/4] x --- internal/experiment/torsf/torsf.go | 8 -------- internal/ptx/snowflake.go | 27 ++++++++------------------- internal/ptx/snowflake_test.go | 6 +++--- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/internal/experiment/torsf/torsf.go b/internal/experiment/torsf/torsf.go index c209dbc8b5..835f20753f 100644 --- a/internal/experiment/torsf/torsf.go +++ b/internal/experiment/torsf/torsf.go @@ -37,9 +37,6 @@ type Config struct { // RendezvousMethod allows to choose the method with which to rendezvous. RendezvousMethod string `ooni:"Choose the method with which to rendezvous. Must be one of amp and domain_fronting. Leaving this field empty means we should use the default."` - - BrokerURL string `ooni:"TODO"` - FrontDomain string `ooni:"TODO"` } // TestKeys contains the experiment's result. @@ -179,11 +176,6 @@ func (m *Measurer) setup(ctx context.Context, // cannot run the experiment with unknown rendezvous method return nil, nil, err } - if rm.Name() == "domain_fronting" { - t1 := rm.(*ptx.SnowflakeRendezvousMethodDomainFronting) - t1.URL = m.config.BrokerURL - t1.Front = m.config.FrontDomain - } sfdialer := ptx.NewSnowflakeDialerWithRendezvousMethod(rm) ptl := &ptx.Listener{ ExperimentByteCounter: bytecounter.ContextExperimentByteCounter(ctx), diff --git a/internal/ptx/snowflake.go b/internal/ptx/snowflake.go index 766acd848a..a48883f583 100644 --- a/internal/ptx/snowflake.go +++ b/internal/ptx/snowflake.go @@ -27,36 +27,25 @@ type SnowflakeRendezvousMethod interface { // NewSnowflakeRendezvousMethodDomainFronting is a rendezvous method // that uses domain fronting to perform the rendezvous. func NewSnowflakeRendezvousMethodDomainFronting() SnowflakeRendezvousMethod { - return &SnowflakeRendezvousMethodDomainFronting{} + return &snowflakeRendezvousMethodDomainFronting{} } -type SnowflakeRendezvousMethodDomainFronting struct { - URL string - Front string -} +type snowflakeRendezvousMethodDomainFronting struct{} -func (d *SnowflakeRendezvousMethodDomainFronting) Name() string { +func (d *snowflakeRendezvousMethodDomainFronting) Name() string { return "domain_fronting" } -func (d *SnowflakeRendezvousMethodDomainFronting) AMPCacheURL() string { +func (d *snowflakeRendezvousMethodDomainFronting) AMPCacheURL() string { return "" } -func (d *SnowflakeRendezvousMethodDomainFronting) BrokerURL() string { - if d.URL != "" { - return d.URL - } else { - return "https://1098762253.rsc.cdn77.org/" - } +func (d *snowflakeRendezvousMethodDomainFronting) BrokerURL() string { + return "https://1098762253.rsc.cdn77.org/" } -func (d *SnowflakeRendezvousMethodDomainFronting) FrontDomain() string { - if d.Front != "" { - return d.Front - } else { - return "www.phpmyadmin.net" - } +func (d *snowflakeRendezvousMethodDomainFronting) FrontDomain() string { + return "www.phpmyadmin.net" } // NewSnowflakeRendezvousMethodAMP is a rendezvous method that diff --git a/internal/ptx/snowflake_test.go b/internal/ptx/snowflake_test.go index 68254dec5d..c0e7802812 100644 --- a/internal/ptx/snowflake_test.go +++ b/internal/ptx/snowflake_test.go @@ -54,7 +54,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { if err != nil { t.Fatal(err) } - if _, ok := meth.(*SnowflakeRendezvousMethodDomainFronting); !ok { + if _, ok := meth.(*snowflakeRendezvousMethodDomainFronting); !ok { t.Fatal("unexpected method type") } }) @@ -64,7 +64,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { if err != nil { t.Fatal(err) } - if _, ok := meth.(*SnowflakeRendezvousMethodDomainFronting); !ok { + if _, ok := meth.(*snowflakeRendezvousMethodDomainFronting); !ok { t.Fatal("unexpected method type") } }) @@ -92,7 +92,7 @@ func TestNewSnowflakeRendezvousMethod(t *testing.T) { func TestNewSnowflakeDialer(t *testing.T) { dialer := NewSnowflakeDialer() - _, ok := dialer.RendezvousMethod.(*SnowflakeRendezvousMethodDomainFronting) + _, ok := dialer.RendezvousMethod.(*snowflakeRendezvousMethodDomainFronting) if !ok { t.Fatal("invalid rendezvous method type") } From 375638f9d1f99d6f9b95989b4675846afb6df836 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 25 Mar 2024 14:53:01 +0100 Subject: [PATCH 4/4] revert https://github.com/ooni/probe-cli/pull/1525 --- internal/experiment/torsf/integration_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/experiment/torsf/integration_test.go b/internal/experiment/torsf/integration_test.go index 5de483f41a..c52735a2b5 100644 --- a/internal/experiment/torsf/integration_test.go +++ b/internal/experiment/torsf/integration_test.go @@ -13,7 +13,6 @@ import ( ) func TestRunWithExistingTor(t *testing.T) { - t.Skip("TODO(https://github.com/ooni/probe/issues/2692)") if testing.Short() { t.Skip("skip test in short mode") }