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

refactor(enginenetx): make beacons API private #1303

Merged
merged 1 commit into from
Sep 26, 2023
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
14 changes: 7 additions & 7 deletions internal/enginenetx/beacons.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
"time"
)

// BeaconsPolicy is a policy where we use beacons for communicating
// beaconsPolicy is a policy where we use beacons for communicating
// with the OONI backend, i.e., api.ooni.io.
//
// A beacon is an IP address that can route traffic from and to
// the OONI backend and accepts any SNI.
//
// The zero value is invalid; please, init MANDATORY fields.
type BeaconsPolicy struct {
type beaconsPolicy struct {
// Fallback is the MANDATORY fallback policy.
Fallback HTTPSDialerPolicy
}

var _ HTTPSDialerPolicy = &BeaconsPolicy{}
var _ HTTPSDialerPolicy = &beaconsPolicy{}

// LookupTactics implements HTTPSDialerPolicy.
func (p *BeaconsPolicy) LookupTactics(ctx context.Context, domain, port string) <-chan *HTTPSDialerTactic {
func (p *beaconsPolicy) LookupTactics(ctx context.Context, domain, port string) <-chan *HTTPSDialerTactic {
out := make(chan *HTTPSDialerTactic)

go func() {
Expand All @@ -47,7 +47,7 @@ func (p *BeaconsPolicy) LookupTactics(ctx context.Context, domain, port string)
return out
}

func (p *BeaconsPolicy) tacticsForDomain(domain, port string) <-chan *HTTPSDialerTactic {
func (p *beaconsPolicy) tacticsForDomain(domain, port string) <-chan *HTTPSDialerTactic {
out := make(chan *HTTPSDialerTactic)

go func() {
Expand Down Expand Up @@ -81,14 +81,14 @@ func (p *BeaconsPolicy) tacticsForDomain(domain, port string) <-chan *HTTPSDiale
return out
}

func (p *BeaconsPolicy) beaconsAddrs() (out []string) {
func (p *beaconsPolicy) beaconsAddrs() (out []string) {
return append(
out,
"162.55.247.208",
)
}

func (p *BeaconsPolicy) beaconsDomains() (out []string) {
func (p *beaconsPolicy) beaconsDomains() (out []string) {
// See https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40273
return append(
out,
Expand Down
6 changes: 3 additions & 3 deletions internal/enginenetx/beacons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestBeaconsPolicy(t *testing.T) {
t.Run("for domains for which we don't have beacons and DNS failure", func(t *testing.T) {
expected := errors.New("mocked error")
policy := &BeaconsPolicy{
policy := &beaconsPolicy{
Fallback: &HTTPSDialerNullPolicy{
Logger: model.DiscardLogger,
Resolver: &mocks.Resolver{
Expand All @@ -38,7 +38,7 @@ func TestBeaconsPolicy(t *testing.T) {
})

t.Run("for domains for which we don't have beacons and DNS success", func(t *testing.T) {
policy := &BeaconsPolicy{
policy := &beaconsPolicy{
Fallback: &HTTPSDialerNullPolicy{
Logger: model.DiscardLogger,
Resolver: &mocks.Resolver{
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestBeaconsPolicy(t *testing.T) {

t.Run("for the api.ooni.io domain", func(t *testing.T) {
expected := errors.New("mocked error")
policy := &BeaconsPolicy{
policy := &beaconsPolicy{
Fallback: &HTTPSDialerNullPolicy{
Logger: model.DiscardLogger,
Resolver: &mocks.Resolver{
Expand Down
2 changes: 1 addition & 1 deletion internal/enginenetx/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func NewNetwork(
// newHTTPSDialerPolicy contains the logic to select the [HTTPSDialerPolicy] to use.
func newHTTPSDialerPolicy(kvStore model.KeyValueStore, logger model.Logger, resolver model.Resolver) HTTPSDialerPolicy {
// create a composed fallback TLS dialer policy
fallback := &BeaconsPolicy{
fallback := &beaconsPolicy{
Fallback: &HTTPSDialerNullPolicy{logger, resolver},
}

Expand Down