Skip to content

Commit

Permalink
Some more IPv6 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
fschulze committed Feb 7, 2024
1 parent c0fea68 commit 8bc64df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ploy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions ploy/plain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit 8bc64df

Please sign in to comment.