Skip to content

Commit a468000

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

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/aioquic/asyncio/client.py

Lines changed: 2 additions & 6 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

@@ -60,12 +59,9 @@ async def connect(
6059
token_handler=token_handler,
6160
)
6261

63-
# OpenBSD well known to not support dual-stack
64-
dual_stack = not sys.platform.startswith("openbsd")
65-
6662
# Use AI_ADDRCONFIG on platforms which doesn't support dual-stack
6763
flags = 0
68-
if not dual_stack:
64+
if not socket.has_dualstack_ipv6():
6965
flags = socket.AI_ADDRCONFIG
7066

7167
# lookup remote address
@@ -74,7 +70,7 @@ async def connect(
7470
local_tuple: Union[Tuple[str, int], Tuple[str, int, int, int]]
7571
addr = infos[0][4]
7672
# addr is 2-tuple for AF_INET and 4-tuple for AF_INET6
77-
if dual_stack and len(addr) == 2:
73+
if socket.has_dualstack_ipv6() and len(addr) == 2:
7874
addr = ("::ffff:" + addr[0], addr[1], 0, 0)
7975
local_tuple = ("::", local_port, 0, 0)
8076
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)

0 commit comments

Comments
 (0)