checkDNSCryptProxy is a helper function that checks the DNSCrypt proxy by sending a test message and verifying the response.
(tb testing.TB, proto dnscrypt.Proto, stamp dnsstamps.ServerStamp)
| 70 | // checkDNSCryptProxy is a helper function that checks the DNSCrypt proxy by |
| 71 | // sending a test message and verifying the response. |
| 72 | func checkDNSCryptProxy(tb testing.TB, proto dnscrypt.Proto, stamp dnsstamps.ServerStamp) { |
| 73 | tb.Helper() |
| 74 | |
| 75 | // Create a DNSCrypt client. |
| 76 | c := dnscrypt.NewClient(&dnscrypt.ClientConfig{ |
| 77 | Logger: slogutil.NewDiscardLogger(), |
| 78 | Proto: proto, |
| 79 | }) |
| 80 | |
| 81 | ctx := testutil.ContextWithTimeout(tb, testTimeout) |
| 82 | |
| 83 | // Fetch the server certificate. |
| 84 | ri, err := c.DialStampContext(ctx, stamp) |
| 85 | require.NoError(tb, err) |
| 86 | |
| 87 | // Send the test message. |
| 88 | msg := newTestMessage() |
| 89 | reply, err := c.ExchangeContext(ctx, msg, ri) |
| 90 | require.NoError(tb, err) |
| 91 | requireResponse(tb, msg, reply) |
| 92 | } |
no test coverage detected
searching dependent graphs…