(t *testing.T)
| 822 | } |
| 823 | |
| 824 | func TestFallbackFromInvalidBootstrap(t *testing.T) { |
| 825 | t.Parallel() |
| 826 | |
| 827 | invalidRslv, err := upstream.NewUpstreamResolver("8.8.8.8:555", &upstream.Options{ |
| 828 | Logger: testLogger, |
| 829 | Timeout: testTimeout, |
| 830 | }) |
| 831 | require.NoError(t, err) |
| 832 | |
| 833 | // Prepare the proxy server |
| 834 | upsConf, err := ParseUpstreamsConfig([]string{"tls://dns.adguard.com"}, &upstream.Options{ |
| 835 | Logger: testLogger, |
| 836 | Bootstrap: invalidRslv, Timeout: testTimeout, |
| 837 | }) |
| 838 | require.NoError(t, err) |
| 839 | |
| 840 | dnsProxy := mustNew(t, &Config{ |
| 841 | Logger: testLogger, |
| 842 | UDPListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)}, |
| 843 | TCPListenAddr: []*net.TCPAddr{net.TCPAddrFromAddrPort(localhostAnyPort)}, |
| 844 | UpstreamConfig: upsConf, |
| 845 | TrustedProxies: defaultTrustedProxies, |
| 846 | Fallbacks: newTestUpstreamConfig( |
| 847 | t, |
| 848 | testTimeout, |
| 849 | "1.0.0.1", |
| 850 | "8.8.8.8", |
| 851 | ), |
| 852 | }) |
| 853 | |
| 854 | servicetest.RequireRun(t, dnsProxy, testTimeout) |
| 855 | |
| 856 | // Create a DNS-over-UDP client connection |
| 857 | addr := dnsProxy.Addr(ProtoUDP) |
| 858 | conn, err := dns.Dial("udp", addr.String()) |
| 859 | require.NoError(t, err) |
| 860 | |
| 861 | // Make sure that the response is okay and resolved by the fallback |
| 862 | req := newTestMessage() |
| 863 | err = conn.WriteMsg(req) |
| 864 | require.NoError(t, err) |
| 865 | |
| 866 | start := time.Now() |
| 867 | res, err := conn.ReadMsg() |
| 868 | require.NoError(t, err) |
| 869 | requireResponse(t, req, res) |
| 870 | |
| 871 | elapsed := time.Since(start) |
| 872 | assert.Greater(t, 3*testTimeout, elapsed) |
| 873 | } |
| 874 | |
| 875 | // Server must drop incoming Response messages |
| 876 | func TestResponseInRequest(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…