refactor(netxlite): introduce the getaddrinfo transport (#775)
This diff modifies the system resolver to use a getaddrinf transport. Obviously the transport is a fake, but its existence will allow us to observe DNS events more naturally. A lookup using the system resolver would be a ANY lookup that will contain all the resolved IP addresses into the same response. This change was also part of websteps-illustrated, albeit the way in which I did it there was less clean than what we have here. Ref issue: https://github.com/ooni/probe/issues/2096
This commit is contained in:
parent
7e0b47311d
commit
923d81cdee
14 changed files with 432 additions and 163 deletions
|
|
@ -32,7 +32,7 @@ func TestNewResolverVanilla(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func TestNewResolverWithBogonFilter(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ func TestNewResolverWithLogging(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ func TestNewResolverWithSaver(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ func TestNewResolverWithReadWriteCache(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ func TestNewResolverWithPrefilledReadonlyCache(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystem)
|
||||
_, ok = ar.Resolver.(*netxlite.ResolverSystemDoNotInstantiate)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
|
|
@ -556,7 +556,7 @@ func TestNewDNSClientSystemResolver(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := dnsclient.(*netxlite.ResolverSystem); !ok {
|
||||
if _, ok := dnsclient.(*netxlite.ResolverSystemDoNotInstantiate); !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
dnsclient.CloseIdleConnections()
|
||||
|
|
@ -568,7 +568,7 @@ func TestNewDNSClientEmpty(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := dnsclient.(*netxlite.ResolverSystem); !ok {
|
||||
if _, ok := dnsclient.(*netxlite.ResolverSystemDoNotInstantiate); !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
dnsclient.CloseIdleConnections()
|
||||
|
|
|
|||
Loading…
Reference in a new issue