Fix address format used in find_best_address()
The current implementation only works for IPv6 addresses, for IPv4 addresses the connect() call always produces an exception because the address format is wrong. We need to use the format matching the address family that is being used. Change-Id: Ida5099278363dc4a527bb488c83883a1d2377f6b Story: 2001475 Task: 6195
This commit is contained in:
@@ -226,7 +226,10 @@ def find_best_address(addresses, family, public=False, cloud_public=True):
|
||||
try:
|
||||
connect_socket = socket.socket(family, socket.SOCK_STREAM, 0)
|
||||
connect_socket.settimeout(1)
|
||||
connect_socket.connect((address, 22, 0, 0))
|
||||
if family == socket.AF_INET4:
|
||||
connect_socket.connect((address, 22))
|
||||
else:
|
||||
connect_socket.connect((address, 22, 0, 0))
|
||||
return address
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user