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

Function newTestDNSCryptProxy

proxy/serverdnscrypt_internal_test.go:38–68  ·  view source on GitHub ↗

newTestDNSCryptProxy is a helper function that creates a DNSCrypt proxy and the corresponding resolver configuration for testing.

(tb testing.TB)

Source from the content-addressed store, hash-verified

36// newTestDNSCryptProxy is a helper function that creates a DNSCrypt proxy and
37// the corresponding resolver configuration for testing.
38func newTestDNSCryptProxy(tb testing.TB) (p *Proxy, rc dnscrypt.ResolverConfig) {
39 tb.Helper()
40
41 rc, err := dnscrypt.GenerateResolverConfig("example.org", nil, 0)
42 require.NoError(tb, err)
43
44 cert, err := rc.NewCert()
45 require.NoError(tb, err)
46
47 port := dnsproxytest.NewFreePort(tb)
48 upstreamConf := newTestUpstreamConfig(tb, defaultTimeout, testDefaultUpstreamAddr)
49 p = mustNew(tb, &Config{
50 Logger: testLogger,
51 DNSCryptUDPListenAddr: []*net.UDPAddr{{
52 Port: int(port), IP: net.ParseIP(listenIP),
53 }},
54 DNSCryptTCPListenAddr: []*net.TCPAddr{{
55 Port: int(port), IP: net.ParseIP(listenIP),
56 }},
57 UpstreamConfig: upstreamConf,
58 TrustedProxies: defaultTrustedProxies,
59 EnableEDNSClientSubnet: true,
60 CacheEnabled: true,
61 CacheMinTTL: 20,
62 CacheMaxTTL: 40,
63 DNSCryptProviderName: rc.ProviderName,
64 DNSCryptResolverCert: cert,
65 })
66
67 return p, rc
68}
69
70// checkDNSCryptProxy is a helper function that checks the DNSCrypt proxy by
71// sending a test message and verifying the response.

Callers 1

TestDNSCryptProxyFunction · 0.85

Calls 3

NewFreePortFunction · 0.92
newTestUpstreamConfigFunction · 0.85
mustNewFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…