From 8bc64df814c91a43c5f0c1fc9729ab61dd870251 Mon Sep 17 00:00:00 2001 From: Florian Schulze Date: Wed, 7 Feb 2024 10:16:10 +0100 Subject: [PATCH] Some more IPv6 support. --- ploy/common.py | 8 ++++++-- ploy/plain.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ploy/common.py b/ploy/common.py index 5d96fd6..fed9ffe 100644 --- a/ploy/common.py +++ b/ploy/common.py @@ -663,9 +663,13 @@ def parse_ssh_keygen(text): def wait_for_ssh(host, port, timeout=5): - with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: + addrinfos = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM) + if not addrinfos: + raise socket.gaierror + addrinfo = addrinfos[0] + with closing(socket.socket(*addrinfo[:3])) as s: s.settimeout(timeout) - if s.connect_ex((host, port)) == 0: + if s.connect_ex(addrinfo[4]) == 0: if s.recv(5).startswith(b'SSH-2'): return diff --git a/ploy/plain.py b/ploy/plain.py index 29aaac9..ba777ad 100644 --- a/ploy/plain.py +++ b/ploy/plain.py @@ -64,6 +64,8 @@ class Instance(BaseInstance): def get_host(self): if 'host' not in self.config: + if 'ip' not in self.config: + return self.config['ipv6'] return self.config['ip'] return self.config['host']