MCPcopy
hub / github.com/AdguardTeam/dnsproxy / TestLookupNetIP

Function TestLookupNetIP

proxy/lookup_internal_test.go:13–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestLookupNetIP(t *testing.T) {
14 // Use AdGuard DNS here.
15 dnsUpstream, err := upstream.AddressToUpstream(
16 "94.140.14.14",
17 &upstream.Options{
18 Logger: testLogger,
19 Timeout: defaultTimeout,
20 },
21 )
22 require.NoError(t, err)
23
24 conf := &Config{
25 Logger: testLogger,
26 UpstreamConfig: &UpstreamConfig{
27 Upstreams: []upstream.Upstream{dnsUpstream},
28 },
29 }
30
31 p, err := New(conf)
32 require.NoError(t, err)
33
34 // Now let's try doing some lookups.
35 addrs, err := p.LookupNetIP(context.Background(), "", "dns.google")
36 require.NoError(t, err)
37 require.NotEmpty(t, addrs)
38
39 assert.Contains(t, addrs, netip.MustParseAddr("8.8.8.8"))
40 assert.Contains(t, addrs, netip.MustParseAddr("8.8.4.4"))
41 if len(addrs) > 2 {
42 assert.Contains(t, addrs, netip.MustParseAddr("2001:4860:4860::8888"))
43 assert.Contains(t, addrs, netip.MustParseAddr("2001:4860:4860::8844"))
44 }
45}

Callers

nothing calls this directly

Calls 3

AddressToUpstreamFunction · 0.92
NewFunction · 0.70
LookupNetIPMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…