From: Thomas Steen Rasmussen Date: Wed, 21 Feb 2024 13:30:03 +0000 (+0100) Subject: add an overridable socket_factory to dns.quic._sync for #1059 (#1060) X-Git-Tag: v2.7.0rc1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d535b982675cc377d96f122d49dc746810c27f4;p=thirdparty%2Fdnspython.git add an overridable socket_factory to dns.quic._sync for #1059 (#1060) --- diff --git a/dns/quic/_sync.py b/dns/quic/_sync.py index 79bfa774..6ef5dc94 100644 --- a/dns/quic/_sync.py +++ b/dns/quic/_sync.py @@ -21,6 +21,9 @@ from dns.quic._common import ( UnexpectedEOF, ) +# Function used to create a socket. Can be overridden if needed in special +# situations. +socket_factory = socket.socket class SyncQuicStream(BaseQuicStream): def __init__(self, connection, stream_id): @@ -75,7 +78,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(