connect: Correctly handle IPv4 addresses

It seems that the "shortcut" of using the `AF_INET6` address family for
both IPv4 and IPv6 address does not always work.  As such, we have to
determine the correct family for the address by calling `getaddrinfo`.
master
Dustin 2022-08-01 22:25:39 -05:00
parent 28c991fe26
commit b32e502597
1 changed files with 13 additions and 3 deletions

View File

@ -255,11 +255,21 @@ class Marionette(WebDriverBase):
self.port,
)
try:
res = await loop.getaddrinfo(
self.host, self.port, type=socket.SOCK_STREAM
)
if res:
family = res[0][0]
host, port = res[0][4][:2]
else:
host = self.host
port = self.port
family = socket.AF_INET
transport, _protocol = await loop.create_connection(
lambda: _MarionetteProtocol(self),
host=self.host,
port=self.port,
family=socket.AF_INET6,
host=host,
port=port,
family=family,
)
fut = self._waiting[-1] = loop.create_future()
hello: Dict[str, Any] = await fut