feat(netxlite): add dialer factory, simplify resolver factory (#459)
See https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
b52d784f00
commit
6a1e92cace
7 changed files with 107 additions and 19 deletions
|
|
@ -180,9 +180,7 @@ func TestResolverIDNAWithInvalidPunycode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNewResolverTypeChain(t *testing.T) {
|
||||
r := NewResolver(&ResolverConfig{
|
||||
Logger: log.Log,
|
||||
})
|
||||
r := NewResolverSystem(log.Log)
|
||||
ridna, ok := r.(*resolverIDNA)
|
||||
if !ok {
|
||||
t.Fatal("invalid resolver")
|
||||
|
|
@ -238,3 +236,22 @@ func TestResolverShortCircuitIPAddrWithDomain(t *testing.T) {
|
|||
t.Fatal("invalid result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNullResolverWorksAsIntended(t *testing.T) {
|
||||
r := &nullResolver{}
|
||||
ctx := context.Background()
|
||||
addrs, err := r.LookupHost(ctx, "dns.google")
|
||||
if !errors.Is(err, ErrNoResolver) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
if addrs != nil {
|
||||
t.Fatal("expected nil addr")
|
||||
}
|
||||
if r.Network() != "null" {
|
||||
t.Fatal("invalid network")
|
||||
}
|
||||
if r.Address() != "" {
|
||||
t.Fatal("invalid address")
|
||||
}
|
||||
r.CloseIdleConnections() // should not crash
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue