mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 16:22:57 -07:00
Bump dnspython from 2.6.1 to 2.7.0 (#2440)
* Bump dnspython from 2.6.1 to 2.7.0 Bumps [dnspython](https://github.com/rthalley/dnspython) from 2.6.1 to 2.7.0. - [Release notes](https://github.com/rthalley/dnspython/releases) - [Changelog](https://github.com/rthalley/dnspython/blob/main/doc/whatsnew.rst) - [Commits](https://github.com/rthalley/dnspython/compare/v2.6.1...v2.7.0) --- updated-dependencies: - dependency-name: dnspython dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update dnspython==2.7.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
0836fb902c
commit
feca713b76
56 changed files with 1382 additions and 665 deletions
|
@ -21,11 +21,9 @@ from dns.quic._common import (
|
|||
UnexpectedEOF,
|
||||
)
|
||||
|
||||
# Avoid circularity with dns.query
|
||||
if hasattr(selectors, "PollSelector"):
|
||||
_selector_class = selectors.PollSelector # type: ignore
|
||||
else:
|
||||
_selector_class = selectors.SelectSelector # type: ignore
|
||||
# Function used to create a socket. Can be overridden if needed in special
|
||||
# situations.
|
||||
socket_factory = socket.socket
|
||||
|
||||
|
||||
class SyncQuicStream(BaseQuicStream):
|
||||
|
@ -46,14 +44,29 @@ class SyncQuicStream(BaseQuicStream):
|
|||
raise dns.exception.Timeout
|
||||
self._expecting = 0
|
||||
|
||||
def wait_for_end(self, expiration):
|
||||
while True:
|
||||
timeout = self._timeout_from_expiration(expiration)
|
||||
with self._lock:
|
||||
if self._buffer.seen_end():
|
||||
return
|
||||
with self._wake_up:
|
||||
if not self._wake_up.wait(timeout):
|
||||
raise dns.exception.Timeout
|
||||
|
||||
def receive(self, timeout=None):
|
||||
expiration = self._expiration_from_timeout(timeout)
|
||||
self.wait_for(2, expiration)
|
||||
with self._lock:
|
||||
(size,) = struct.unpack("!H", self._buffer.get(2))
|
||||
self.wait_for(size, expiration)
|
||||
with self._lock:
|
||||
return self._buffer.get(size)
|
||||
if self._connection.is_h3():
|
||||
self.wait_for_end(expiration)
|
||||
with self._lock:
|
||||
return self._buffer.get_all()
|
||||
else:
|
||||
self.wait_for(2, expiration)
|
||||
with self._lock:
|
||||
(size,) = struct.unpack("!H", self._buffer.get(2))
|
||||
self.wait_for(size, expiration)
|
||||
with self._lock:
|
||||
return self._buffer.get(size)
|
||||
|
||||
def send(self, datagram, is_end=False):
|
||||
data = self._encapsulate(datagram)
|
||||
|
@ -81,7 +94,7 @@ class SyncQuicStream(BaseQuicStream):
|
|||
class SyncQuicConnection(BaseQuicConnection):
|
||||
def __init__(self, connection, address, port, source, source_port, manager):
|
||||
super().__init__(connection, address, port, source, source_port, manager)
|
||||
self._socket = socket.socket(self._af, socket.SOCK_DGRAM, 0)
|
||||
self._socket = socket_factory(self._af, socket.SOCK_DGRAM, 0)
|
||||
if self._source is not None:
|
||||
try:
|
||||
self._socket.bind(
|
||||
|
@ -118,7 +131,7 @@ class SyncQuicConnection(BaseQuicConnection):
|
|||
|
||||
def _worker(self):
|
||||
try:
|
||||
sel = _selector_class()
|
||||
sel = selectors.DefaultSelector()
|
||||
sel.register(self._socket, selectors.EVENT_READ, self._read)
|
||||
sel.register(self._receive_wakeup, selectors.EVENT_READ, self._drain_wakeup)
|
||||
while not self._done:
|
||||
|
@ -140,6 +153,7 @@ class SyncQuicConnection(BaseQuicConnection):
|
|||
finally:
|
||||
with self._lock:
|
||||
self._done = True
|
||||
self._socket.close()
|
||||
# Ensure anyone waiting for this gets woken up.
|
||||
self._handshake_complete.set()
|
||||
|
||||
|
@ -150,10 +164,29 @@ class SyncQuicConnection(BaseQuicConnection):
|
|||
if event is None:
|
||||
return
|
||||
if isinstance(event, aioquic.quic.events.StreamDataReceived):
|
||||
with self._lock:
|
||||
stream = self._streams.get(event.stream_id)
|
||||
if stream:
|
||||
stream._add_input(event.data, event.end_stream)
|
||||
if self.is_h3():
|
||||
h3_events = self._h3_conn.handle_event(event)
|
||||
for h3_event in h3_events:
|
||||
if isinstance(h3_event, aioquic.h3.events.HeadersReceived):
|
||||
with self._lock:
|
||||
stream = self._streams.get(event.stream_id)
|
||||
if stream:
|
||||
if stream._headers is None:
|
||||
stream._headers = h3_event.headers
|
||||
elif stream._trailers is None:
|
||||
stream._trailers = h3_event.headers
|
||||
if h3_event.stream_ended:
|
||||
stream._add_input(b"", True)
|
||||
elif isinstance(h3_event, aioquic.h3.events.DataReceived):
|
||||
with self._lock:
|
||||
stream = self._streams.get(event.stream_id)
|
||||
if stream:
|
||||
stream._add_input(h3_event.data, h3_event.stream_ended)
|
||||
else:
|
||||
with self._lock:
|
||||
stream = self._streams.get(event.stream_id)
|
||||
if stream:
|
||||
stream._add_input(event.data, event.end_stream)
|
||||
elif isinstance(event, aioquic.quic.events.HandshakeCompleted):
|
||||
self._handshake_complete.set()
|
||||
elif isinstance(event, aioquic.quic.events.ConnectionTerminated):
|
||||
|
@ -170,6 +203,18 @@ class SyncQuicConnection(BaseQuicConnection):
|
|||
self._connection.send_stream_data(stream, data, is_end)
|
||||
self._send_wakeup.send(b"\x01")
|
||||
|
||||
def send_headers(self, stream_id, headers, is_end=False):
|
||||
with self._lock:
|
||||
super().send_headers(stream_id, headers, is_end)
|
||||
if is_end:
|
||||
self._send_wakeup.send(b"\x01")
|
||||
|
||||
def send_data(self, stream_id, data, is_end=False):
|
||||
with self._lock:
|
||||
super().send_data(stream_id, data, is_end)
|
||||
if is_end:
|
||||
self._send_wakeup.send(b"\x01")
|
||||
|
||||
def run(self):
|
||||
if self._closed:
|
||||
return
|
||||
|
@ -203,16 +248,24 @@ class SyncQuicConnection(BaseQuicConnection):
|
|||
|
||||
|
||||
class SyncQuicManager(BaseQuicManager):
|
||||
def __init__(self, conf=None, verify_mode=ssl.CERT_REQUIRED, server_name=None):
|
||||
super().__init__(conf, verify_mode, SyncQuicConnection, server_name)
|
||||
def __init__(
|
||||
self, conf=None, verify_mode=ssl.CERT_REQUIRED, server_name=None, h3=False
|
||||
):
|
||||
super().__init__(conf, verify_mode, SyncQuicConnection, server_name, h3)
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def connect(
|
||||
self, address, port=853, source=None, source_port=0, want_session_ticket=True
|
||||
self,
|
||||
address,
|
||||
port=853,
|
||||
source=None,
|
||||
source_port=0,
|
||||
want_session_ticket=True,
|
||||
want_token=True,
|
||||
):
|
||||
with self._lock:
|
||||
(connection, start) = self._connect(
|
||||
address, port, source, source_port, want_session_ticket
|
||||
address, port, source, source_port, want_session_ticket, want_token
|
||||
)
|
||||
if start:
|
||||
connection.run()
|
||||
|
@ -226,6 +279,10 @@ class SyncQuicManager(BaseQuicManager):
|
|||
with self._lock:
|
||||
super().save_session_ticket(address, port, ticket)
|
||||
|
||||
def save_token(self, address, port, token):
|
||||
with self._lock:
|
||||
super().save_token(address, port, token)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue