From 6b87c043dde59883558ab935b405578e28e67816 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 26 Oct 2023 18:41:36 -0700 Subject: [PATCH] The "address" passed to QUIC receive_datagram() should be a low-level tuple. Previously we sent just the address part, i.e. lltuple[0], but the aioquic code intends for the value to be the whole tuple. This did not break anything for dnspython as we were consistently wrong and aioquic is flexible enough with its notion of NetworkAddress for our purposes that dnspython's mistake had no effect. --- dns/quic/_asyncio.py | 6 ++---- dns/quic/_common.py | 3 ++- dns/quic/_sync.py | 2 +- dns/quic/_trio.py | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dns/quic/_asyncio.py b/dns/quic/_asyncio.py index b0574830..57c9910b 100644 --- a/dns/quic/_asyncio.py +++ b/dns/quic/_asyncio.py @@ -101,9 +101,7 @@ class AsyncioQuicConnection(AsyncQuicConnection): ) if address[0] != self._peer[0] or address[1] != self._peer[1]: continue - self._connection.receive_datagram( - datagram, self._peer[0], time.time() - ) + self._connection.receive_datagram(datagram, address, time.time()) # Wake up the timer in case the sender is sleeping, as there may be # stuff to send now. async with self._wake_timer: @@ -125,7 +123,7 @@ class AsyncioQuicConnection(AsyncQuicConnection): while not self._done: datagrams = self._connection.datagrams_to_send(time.time()) for datagram, address in datagrams: - assert address == self._peer[0] + assert address == self._peer await self._socket.sendto(datagram, self._peer, None) (expiration, interval) = self._get_timer_values() try: diff --git a/dns/quic/_common.py b/dns/quic/_common.py index e4a9f18d..4cbdcae1 100644 --- a/dns/quic/_common.py +++ b/dns/quic/_common.py @@ -164,7 +164,8 @@ class BaseQuicManager: if connection is not None: return (connection, False) qconn = aioquic.quic.connection.QuicConnection(configuration=self._conf) - qconn.connect(address, time.time()) + lladdress = dns.inet.low_level_address_tuple((address, port)) + qconn.connect(lladdress, time.time()) connection = self._connection_factory( qconn, address, port, source, source_port, self ) diff --git a/dns/quic/_sync.py b/dns/quic/_sync.py index 6e13cad4..25dd6d6e 100644 --- a/dns/quic/_sync.py +++ b/dns/quic/_sync.py @@ -107,7 +107,7 @@ class SyncQuicConnection(BaseQuicConnection): except BlockingIOError: return with self._lock: - self._connection.receive_datagram(datagram, self._peer[0], time.time()) + self._connection.receive_datagram(datagram, self._peer, time.time()) def _drain_wakeup(self): while True: diff --git a/dns/quic/_trio.py b/dns/quic/_trio.py index 43c1b1a4..1ee702b5 100644 --- a/dns/quic/_trio.py +++ b/dns/quic/_trio.py @@ -91,9 +91,7 @@ class TrioQuicConnection(AsyncQuicConnection): deadline=trio.current_time() + interval ) as self._worker_scope: datagram = await self._socket.recv(QUIC_MAX_DATAGRAM) - self._connection.receive_datagram( - datagram, self._peer[0], time.time() - ) + self._connection.receive_datagram(datagram, self._peer, time.time()) self._worker_scope = None self._handle_timer(expiration) datagrams = self._connection.datagrams_to_send(time.time()) -- 2.47.3