ooni-probe-cli/internal/netxlite
Simone Basso 16f7407b13
feat(netxlite): observe additional DNS-over-UDP responses (#762)
This diff introduces support for observing additional DNS-over-UDP
responses in some censored environments (e.g. China).

After some uncertainty around whether to use connected or unconnected
UDP sockets, I eventually settled for connected.

Here's a recap:

|                         | connected | unconnected |
| ----------------------- | --------- | ----------- |
| see ICMP errors         | ✔️         |           |
| responses from any server |         | ✔️           |

Because most if not all DNS resolvers expect answers from exactly
the same servers to which they sent the query, I would say that
it's more important to have some limited ability of observing the
effect of ICMP errors (e.g., host_unreachable when we set a low
TTL and send out a query to a server).

Therefore, my choice was to modify the existing DNS-over-UDP transport.

Here's an overview of the changes:

1. introduce a new API for performing an async round trip that returns
a channel wrapper where all responses are posted. The channel will not ever
be closed, so the reader needs to use select for safely reading. If the
reader users the wrapper's Next or TryNextResponses methods, these details
do not matter because they already implement a safe reading pattern.

2. the async round trip API performs the round trip in the background
and stops processing when it sees the first error.

3. the background running code will use an overall deadline derived
from the DNSTransport.IOTimeout field to know when to stop.

4. the background running code will additionally stop running if
noone is reading the channel and there are no empty slots in the
channel's buffer.

5. the RoundTrip method has been rewritten in terms of the async API.

The design I'm using here implements the proposal for async round
trips defined at https://github.com/ooni/probe/issues/2099. I have
chosen not to make all transports async because the DNS transport
seems the only transport that needs to also work in async mode.

While there, I noticed that we were not propagating CloseIdleConnection
to the underlying dialer, which was potentially wrong, so I did it.
2022-05-26 20:09:00 +02:00
..
filtering feat(netxlite): observe additional DNS-over-UDP responses (#762) 2022-05-26 20:09:00 +02:00
internal fix(netxlite): reject replies with wrong queryID (#732) 2022-05-14 19:38:46 +02:00
mocks cli: upgrade to lucas-clemente/quic-go@v0.27.0 (#715) 2022-05-06 12:24:03 +02:00
quictesting [forwardport] fix: avoid http3 for dns.google and www.google.com (#593) (#594) 2021-11-12 14:43:28 +01:00
bogon_test.go chore: import improved bogons handling code (#723) 2022-05-13 15:32:47 +02:00
bogon.go feat(netxlite): implements NS queries (#734) 2022-05-16 10:46:53 +02:00
certifi_test.go netxlite: improve docs, tests, and code quality (#493) 2021-09-08 21:19:51 +02:00
certifi.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
classify_test.go fix(netxlite): reject replies with wrong queryID (#732) 2022-05-14 19:38:46 +02:00
classify.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
dialer_test.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
dialer.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
dnsdecoder_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsdecoder.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsencoder_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsencoder.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsoverhttps_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsoverhttps.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsovertcp_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsovertcp.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
dnsoverudp_test.go feat(netxlite): observe additional DNS-over-UDP responses (#762) 2022-05-26 20:09:00 +02:00
dnsoverudp.go feat(netxlite): observe additional DNS-over-UDP responses (#762) 2022-05-26 20:09:00 +02:00
doc.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
errno_darwin_test.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_darwin.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_freebsd_test.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_freebsd.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_linux_test.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_linux.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_openbsd_test.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_openbsd.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_windows_test.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno_windows.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errno.go chore: run go generate ./... (#743) 2022-05-19 20:44:39 +02:00
errwrapper_test.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
errwrapper.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
http_test.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
http.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
http3_test.go cli: upgrade to lucas-clemente/quic-go@v0.27.0 (#715) 2022-05-06 12:24:03 +02:00
http3.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
integration_test.go feat(netxlite): observe additional DNS-over-UDP responses (#762) 2022-05-26 20:09:00 +02:00
iox_test.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
iox.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
legacy.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
operations.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
parallelresolver_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
parallelresolver.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
quic_test.go netxlite: factor common code for parsing UDPAddr (#730) 2022-05-14 17:15:08 +02:00
quic.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
quirks_test.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
quirks.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
resolver_test.go feat(netxlite): implements NS queries (#734) 2022-05-16 10:46:53 +02:00
resolver.go feat(netxlite): implements NS queries (#734) 2022-05-16 10:46:53 +02:00
serialresolver_test.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
serialresolver.go refactor: DNSTransport I/Os DNS messages (#760) 2022-05-25 17:03:58 +02:00
shaping_otherwise_test.go refactor: only use shaping dialer for ndt7 and dash (#754) 2022-05-24 18:23:42 +02:00
shaping_otherwise.go refactor: only use shaping dialer for ndt7 and dash (#754) 2022-05-24 18:23:42 +02:00
shaping_shaping_test.go refactor: only use shaping dialer for ndt7 and dash (#754) 2022-05-24 18:23:42 +02:00
shaping_shaping.go refactor: only use shaping dialer for ndt7 and dash (#754) 2022-05-24 18:23:42 +02:00
shaping.go refactor: only use shaping dialer for ndt7 and dash (#754) 2022-05-24 18:23:42 +02:00
tls_test.go refactor: use ooni/oocrypto instead of ooni/go (#751) 2022-05-22 19:53:37 +02:00
tls.go refactor: use ooni/oocrypto instead of ooni/go (#751) 2022-05-22 19:53:37 +02:00
tproxy.go fix(netxlite): prefer composition over embedding (#733) 2022-05-15 19:25:27 +02:00
utls_test.go refactor: use ooni/oocrypto instead of ooni/go (#751) 2022-05-22 19:53:37 +02:00
utls.go refactor: use ooni/oocrypto instead of ooni/go (#751) 2022-05-22 19:53:37 +02:00