Skip to content

Commit

Permalink
add an overridable socket_factory to dns.quic._sync for #1059
Browse files Browse the repository at this point in the history
  • Loading branch information
tykling committed Feb 21, 2024
1 parent a977e61 commit af623b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dns/quic/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
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):
Expand Down Expand Up @@ -75,7 +78,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
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(
Expand Down

0 comments on commit af623b1

Please sign in to comment.