]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add an overridable socket_factory to dns.quic._sync for #1059 (#1060)
authorThomas Steen Rasmussen <thomas@gibfest.dk>
Wed, 21 Feb 2024 13:30:03 +0000 (14:30 +0100)
committerGitHub <noreply@github.com>
Wed, 21 Feb 2024 13:30:03 +0000 (05:30 -0800)
dns/quic/_sync.py

index 79bfa77430d179068cea0dc58f264fa0bf021fcc..6ef5dc9423b52c87f5a6a0a4c50ddda0a44caedc 100644 (file)
@@ -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(