(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestHttpsProxy(t *testing.T) { |
| 27 | testCases := []struct { |
| 28 | name string |
| 29 | http3 bool |
| 30 | }{{ |
| 31 | name: "https_proxy", |
| 32 | http3: false, |
| 33 | }, { |
| 34 | name: "h3_proxy", |
| 35 | http3: true, |
| 36 | }} |
| 37 | |
| 38 | for _, tc := range testCases { |
| 39 | t.Run(tc.name, func(t *testing.T) { |
| 40 | tlsConf, caPem := newTLSConfig(t) |
| 41 | |
| 42 | httpConf := &HTTPConfig{ |
| 43 | ListenAddresses: []netip.AddrPort{localhostAnyPort}, |
| 44 | HTTP3Enabled: tc.http3, |
| 45 | } |
| 46 | dnsProxy := mustNew(t, &Config{ |
| 47 | Logger: testLogger, |
| 48 | TLSListenAddr: []*net.TCPAddr{net.TCPAddrFromAddrPort(localhostAnyPort)}, |
| 49 | QUICListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)}, |
| 50 | TLSConfig: tlsConf, |
| 51 | UpstreamConfig: newTestUpstreamConfig(t, defaultTimeout, testDefaultUpstreamAddr), |
| 52 | TrustedProxies: defaultTrustedProxies, |
| 53 | HTTPConfig: httpConf, |
| 54 | }) |
| 55 | |
| 56 | servicetest.RequireRun(t, dnsProxy, testTimeout) |
| 57 | |
| 58 | // Create the HTTP client that we'll be using for this test. |
| 59 | client := createTestHTTPClient(dnsProxy, caPem, tc.http3) |
| 60 | |
| 61 | // Prepare a test message to be sent to the server. |
| 62 | msg := newTestMessage() |
| 63 | |
| 64 | // Send the test message and check if the response is what we |
| 65 | // expected. |
| 66 | resp := sendTestDoHMessage(t, client, msg, nil) |
| 67 | requireResponse(t, msg, resp) |
| 68 | }) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestProxy_trustedProxies(t *testing.T) { |
| 73 | var ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…