refactor(netx): remove the self censorship mechanism (#364)

We're currently use jafar for QA and jafar is a better mechanism,
even though it is not portable outside of Linux.

This self censorship mechanism was less cool and added a bunch
of (also cognitive) complexity to netx.

If we ever want to go down a self censorship like road, we probably
want to do as little work as possible in the problem and as much
work as possible inside a helper like jafar.

Part of https://github.com/ooni/probe/issues/1591.
This commit is contained in:
Simone Basso
2021-06-08 19:40:17 +02:00
committed by GitHub
parent c553afdbd5
commit adbde7246b
11 changed files with 88 additions and 538 deletions
+24 -5
View File
@@ -1,10 +1,29 @@
package resolver
import "github.com/ooni/probe-cli/v3/internal/engine/netx/selfcensor"
import (
"context"
"net"
)
// SystemResolver is the system resolver. It is implemented using
// selfcensor.SystemResolver so that we can perform integration testing
// by forcing the code to return specific responses.
type SystemResolver = selfcensor.SystemResolver
// SystemResolver is the system resolver.
type SystemResolver struct{}
// LookupHost implements Resolver.LookupHost.
func (r SystemResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
return net.DefaultResolver.LookupHost(ctx, hostname)
}
// Network implements Resolver.Network.
func (r SystemResolver) Network() string {
return "system"
}
// Address implements Resolver.Address.
func (r SystemResolver) Address() string {
return ""
}
// Default is the resolver we use by default.
var Default = SystemResolver{}
var _ Resolver = SystemResolver{}