fix ipv6 support in SSHClient
This commit is contained in:
parent
5e32b33be7
commit
20e3306f3d
|
@ -273,17 +273,21 @@ class SSHClient (object):
|
||||||
establishing an SSH session
|
establishing an SSH session
|
||||||
@raise socket.error: if a socket error occurred while connecting
|
@raise socket.error: if a socket error occurred while connecting
|
||||||
"""
|
"""
|
||||||
if len(hostname.split(':')) > 1:
|
for (family, socktype, proto, canonname, sockaddr) in \
|
||||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
socket.getaddrinfo(hostname, port):
|
||||||
|
if socktype==socket.SOCK_STREAM:
|
||||||
|
af = family
|
||||||
|
ADDR = sockaddr
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
raise SSHException('No suitable address family for %s' % hostname)
|
||||||
|
sock = socket.socket(af, socket.SOCK_STREAM)
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
try:
|
try:
|
||||||
sock.settimeout(timeout)
|
sock.settimeout(timeout)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
sock.connect(addr)
|
||||||
sock.connect((hostname, port))
|
|
||||||
t = self._transport = Transport(sock)
|
t = self._transport = Transport(sock)
|
||||||
|
|
||||||
if self._log_channel is not None:
|
if self._log_channel is not None:
|
||||||
|
@ -316,6 +320,8 @@ class SSHClient (object):
|
||||||
else:
|
else:
|
||||||
key_filenames = key_filename
|
key_filenames = key_filename
|
||||||
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
|
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
|
||||||
|
if agent_forwarding:
|
||||||
|
self._forward_agent()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue