Skip to content

Commit 3e3d9eb

Browse files
committed
Use socket.has_dualstack_ipv6()
1 parent 3c4a567 commit 3e3d9eb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/aioquic/asyncio/client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import asyncio
22
import socket
3-
import sys
43
from contextlib import asynccontextmanager
54
from typing import AsyncGenerator, Callable, Optional, Tuple, Union, cast
65

@@ -24,6 +23,7 @@ async def connect(
2423
token_handler: Optional[QuicTokenHandler] = None,
2524
wait_connected: bool = True,
2625
local_port: int = 0,
26+
dual_stack: bool = socket.has_dualstack_ipv6(),
2727
) -> AsyncGenerator[QuicConnectionProtocol, None]:
2828
"""
2929
Connect to a QUIC server at the given `host` and `port`.
@@ -46,6 +46,8 @@ async def connect(
4646
created. It must accept two arguments: a :class:`asyncio.StreamReader`
4747
and a :class:`asyncio.StreamWriter`.
4848
* ``local_port`` is the UDP port number that this client wants to bind.
49+
* ``dual_stack`` is a flag which enabled or disabled using IPv4/IPv6 Dual-Stack.
50+
The default value is platform specific and similar with socket.has_dualstack_ipv6().
4951
"""
5052
loop = asyncio.get_event_loop()
5153

@@ -60,9 +62,6 @@ async def connect(
6062
token_handler=token_handler,
6163
)
6264

63-
# OpenBSD well known to not support dual-stack
64-
dual_stack = not sys.platform.startswith("openbsd")
65-
6665
# Use AI_ADDRCONFIG on platforms which doesn't support dual-stack
6766
flags = 0
6867
if not dual_stack:

0 commit comments

Comments
 (0)