Skip to content

Commit

Permalink
fix torsf (dirty)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanius-collaris committed Mar 22, 2024
1 parent dc3a53a commit a4d4b68
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
10 changes: 9 additions & 1 deletion internal/experiment/torsf/torsf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion internal/experiment/torsf/torsf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
27 changes: 19 additions & 8 deletions internal/ptx/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4d4b68

Please sign in to comment.