Skip to content

Commit

Permalink
Use socket.has_dualstack_ipv6()
Browse files Browse the repository at this point in the history
  • Loading branch information
catap committed Jul 7, 2024
1 parent 3c4a567 commit 3e3d9eb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/aioquic/asyncio/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import socket
import sys
from contextlib import asynccontextmanager
from typing import AsyncGenerator, Callable, Optional, Tuple, Union, cast

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

Expand All @@ -60,9 +62,6 @@ async def connect(
token_handler=token_handler,
)

# OpenBSD well known to not support dual-stack
dual_stack = not sys.platform.startswith("openbsd")

# Use AI_ADDRCONFIG on platforms which doesn't support dual-stack
flags = 0
if not dual_stack:
Expand Down

0 comments on commit 3e3d9eb

Please sign in to comment.