newTestDNSCryptProxy is a helper function that creates a DNSCrypt proxy and the corresponding resolver configuration for testing.
(tb testing.TB)
| 36 | // newTestDNSCryptProxy is a helper function that creates a DNSCrypt proxy and |
| 37 | // the corresponding resolver configuration for testing. |
| 38 | func 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. |
no test coverage detected
searching dependent graphs…