(t *testing.T)
| 138 | } |
| 139 | |
| 140 | func TestProxy_quicTruncatedRequest(t *testing.T) { |
| 141 | serverConfig, caPem := newTLSConfig(t) |
| 142 | |
| 143 | conf := &Config{ |
| 144 | Logger: testLogger, |
| 145 | QUICListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)}, |
| 146 | TLSConfig: serverConfig, |
| 147 | UpstreamConfig: newTestUpstreamConfig(t, defaultTimeout, testDefaultUpstreamAddr), |
| 148 | TrustedProxies: defaultTrustedProxies, |
| 149 | RequestHandler: &TestHandler{ |
| 150 | OnHandle: func(ctx context.Context, p *Proxy, d *DNSContext) (_ error) { |
| 151 | panic(testutil.UnexpectedCall(ctx, p, d)) |
| 152 | }, |
| 153 | }, |
| 154 | } |
| 155 | |
| 156 | dnsProxy := mustNew(t, conf) |
| 157 | |
| 158 | req := (&dns.Msg{ |
| 159 | MsgHdr: dns.MsgHdr{ |
| 160 | Id: 0, |
| 161 | RecursionDesired: true, |
| 162 | }, |
| 163 | Question: []dns.Question{{ |
| 164 | Name: "example.org.", |
| 165 | Qtype: dns.TypeA, |
| 166 | Qclass: dns.ClassINET, |
| 167 | }}, |
| 168 | }).SetEdns0(4096, false) |
| 169 | |
| 170 | packed, err := req.Pack() |
| 171 | require.NoError(t, err) |
| 172 | |
| 173 | fullBuf := proxyutil.AddPrefix(packed) |
| 174 | |
| 175 | dnsProxy.bytesPool = syncutil.NewPool(func() (v *[]byte) { |
| 176 | b := make([]byte, 2+dns.MaxMsgSize) |
| 177 | copy(b, fullBuf) |
| 178 | |
| 179 | return &b |
| 180 | }) |
| 181 | |
| 182 | servicetest.RequireRun(t, dnsProxy, testTimeout) |
| 183 | |
| 184 | addr := dnsProxy.Addr(ProtoQUIC) |
| 185 | |
| 186 | roots := x509.NewCertPool() |
| 187 | require.True(t, roots.AppendCertsFromPEM(caPem)) |
| 188 | |
| 189 | tlsConfig := &tls.Config{ |
| 190 | ServerName: tlsServerName, |
| 191 | RootCAs: roots, |
| 192 | NextProtos: append([]string{NextProtoDQ}, compatProtoDQ...), |
| 193 | } |
| 194 | |
| 195 | ctx := testutil.ContextWithTimeout(t, testTimeout) |
| 196 | |
| 197 | conn, err := quic.DialAddrEarly(ctx, addr.String(), tlsConfig, nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…