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
parent
28c991fe26
commit
b32e502597
|
@ -255,11 +255,21 @@ class Marionette(WebDriverBase):
|
||||||
self.port,
|
self.port,
|
||||||
)
|
)
|
||||||
try:
|
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(
|
transport, _protocol = await loop.create_connection(
|
||||||
lambda: _MarionetteProtocol(self),
|
lambda: _MarionetteProtocol(self),
|
||||||
host=self.host,
|
host=host,
|
||||||
port=self.port,
|
port=port,
|
||||||
family=socket.AF_INET6,
|
family=family,
|
||||||
)
|
)
|
||||||
fut = self._waiting[-1] = loop.create_future()
|
fut = self._waiting[-1] = loop.create_future()
|
||||||
hello: Dict[str, Any] = await fut
|
hello: Dict[str, Any] = await fut
|
||||||
|
|
Loading…
Reference in New Issue