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

fix torsf #1529

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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: 8 additions & 0 deletions internal/experiment/torsf/torsf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
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://1098762253.rsc.cdn77.org/"
func (d *SnowflakeRendezvousMethodDomainFronting) BrokerURL() string {
if d.URL != "" {
return d.URL
} else {
return "https://1098762253.rsc.cdn77.org/"
}
}

func (d *snowflakeRendezvousMethodDomainFronting) FrontDomain() string {
return "www.phpmyadmin.net"
func (d *SnowflakeRendezvousMethodDomainFronting) FrontDomain() string {
if d.Front != "" {
return d.Front
} else {
return "www.phpmyadmin.net"
}
}

// NewSnowflakeRendezvousMethodAMP is a rendezvous method that
Expand Down
6 changes: 3 additions & 3 deletions internal/ptx/snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
})
Expand All @@ -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")
}
})
Expand Down Expand Up @@ -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")
}
Expand Down
Loading