2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-22 09:32:28 +00:00

Decrease max input of ssh connection

Specify connect and login timeouts
to avoid sessions being held open.

Also, in blocking_scan, wrap everything so that finally can ensure the scan is recognized as complete.
This commit is contained in:
Jarrod Johnson
2026-09-16 15:41:58 -04:00
parent 10c822fcd2
commit d793c521fe
2 changed files with 16 additions and 12 deletions
+13 -11
View File
@@ -1738,17 +1738,19 @@ async def blocking_scan(aggressive=False):
else:
pingscan_result = {}
gencheckers = []
for iface in pingscan_result:
for ipa in pingscan_result[iface]:
hwaddr = await neighutil.get_hwaddr(ipa)
if not hwaddr:
continue
if hwaddr in known_info:
continue
gencheckers.append(generic_eval(ipa, hwaddr))
if gencheckers:
await asyncio.gather(*gencheckers, return_exceptions=True)
scanner = None
try:
for iface in pingscan_result:
for ipa in pingscan_result[iface]:
hwaddr = await neighutil.get_hwaddr(ipa)
if not hwaddr:
continue
if hwaddr in known_info:
continue
gencheckers.append(generic_eval(ipa, hwaddr))
if gencheckers:
await asyncio.gather(*gencheckers, return_exceptions=True)
finally:
scanner = None
async def generic_eval(address, hwaddr=None):
+3 -1
View File
@@ -123,7 +123,9 @@ def connect(target, context=None, disable_hostkey_validation=False, known_hosts=
sco = asyncssh.SSHClientConnectionOptions(
client_factory=make_client,
x509_trusted_cert_paths=None,
known_hosts=known_hosts)
known_hosts=known_hosts,
login_timeout=3,
connect_timeout=2)
return asyncssh.connect(target, options=sco, **kwargs)