bug 363163: copy the SSHClient AF patch to transport.py too.

This commit is contained in:
Robey Pointer 2009-10-31 16:10:52 -07:00
parent d23ae79466
commit e80cec73b6
2 changed files with 55 additions and 49 deletions

View File

@ -273,8 +273,7 @@ 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
""" """
for (family, socktype, proto, canonname, sockaddr) in \ for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port):
socket.getaddrinfo(hostname, port):
if socktype == socket.SOCK_STREAM: if socktype == socket.SOCK_STREAM:
af = family af = family
addr = sockaddr addr = sockaddr

View File

@ -285,7 +285,14 @@ class Transport (threading.Thread):
if type(sock) is tuple: if type(sock) is tuple:
# connect to the given (host, port) # connect to the given (host, port)
hostname, port = sock hostname, port = sock
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port):
if socktype == socket.SOCK_STREAM:
af = family
addr = sockaddr
break
else:
raise SSHException('No suitable address family for %s' % hostname)
sock = socket.socket(af, socket.SOCK_STREAM)
sock.connect((hostname, port)) sock.connect((hostname, port))
# okay, normal socket-ish flow here... # okay, normal socket-ish flow here...
threading.Thread.__init__(self) threading.Thread.__init__(self)