Skip to content

Commit

Permalink
Fixed Socket.connect() method arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtesta committed Oct 31, 2017
1 parent 95ca0bb commit f44663b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ssh-audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ class InsufficientReadException(Exception):

SM_BANNER_SENT = 1

def __init__(self, host, port):
def __init__(self, host, port, ipvo, timeout):
# type: (Optional[str], int) -> None
super(SSH.Socket, self).__init__()
self.__sock = None # type: Optional[socket.socket]
Expand All @@ -1847,7 +1847,12 @@ def __init__(self, host, port):
raise ValueError('invalid port: {0}'.format(port))
self.__host = host
self.__port = nport
self.__ipvo = ()
if ipvo is not None:
self.__ipvo = ipvo
else:
self.__ipvo = ()
self.__timeout = timeout


def _resolve(self, ipvo):
# type: (Sequence[int]) -> Iterable[Tuple[int, Tuple[Any, ...]]]
Expand All @@ -1872,16 +1877,14 @@ def _resolve(self, ipvo):
out.fail('[exception] {0}'.format(e))
sys.exit(1)

def connect(self, ipvo, timeout):
# type: (Sequence[int], float) -> None
def connect(self):
# type: () -> None
err = None
if ipvo is not None:
self.__ipvo = ipvo
for af, addr in self._resolve(self.__ipvo):
s = None
try:
s = socket.socket(af, socket.SOCK_STREAM)
s.settimeout(timeout)
s.settimeout(self.__timeout)
s.connect(addr)
self.__sock = s
return
Expand Down Expand Up @@ -2835,8 +2838,8 @@ def audit(aconf, sshv=None):
out.verbose = aconf.verbose
out.level = aconf.level
out.use_colors = aconf.colors
s = SSH.Socket(aconf.host, aconf.port)
s.connect(aconf.ipvo, aconf.timeout)
s = SSH.Socket(aconf.host, aconf.port, aconf.ipvo, aconf.timeout)
s.connect()
if sshv is None:
sshv = 2 if aconf.ssh2 else 1
err = None
Expand Down

0 comments on commit f44663b

Please sign in to comment.