gateway: Add arg "try_telnet" to func "create_gateway"

pull/36/head
remittor 7 months ago
parent 9324443de7
commit a854c4a6a3

@ -50,7 +50,7 @@ if gw.model_id > 0 and gw.model_id < gw.get_modelid_by_name('R2100'):
if True:
# init gw and check ssh
gw = create_gateway(timeout = 4, die_if_sshOk = True, die_if_ftpOk = True, web_login = True)
gw = create_gateway(timeout = 4, die_if_sshOk = True, die_if_ftpOk = True, web_login = True, try_telnet = True)
hackCheck = gw.detect_hackCheck(update = True)
if hackCheck:

@ -1318,7 +1318,7 @@ def import_module(mod_name, gw):
mod_object.inited_gw = gw
mod_spec.loader.exec_module(mod_object)
def create_gateway(timeout = 4, die_if_sshOk = True, die_if_ftpOk = True, web_login = True, ssh_port = 22):
def create_gateway(timeout = 4, die_if_sshOk = True, die_if_ftpOk = True, web_login = True, ssh_port = 22, try_telnet = False):
gw = Gateway(timeout = timeout, detect_ssh = False)
if gw.status < 1:
die(f"Xiaomi Mi Wi-Fi device not found (IP: {gw.ip_addr})")
@ -1329,6 +1329,8 @@ def create_gateway(timeout = 4, die_if_sshOk = True, die_if_ftpOk = True, web_lo
ret = gw.detect_ssh(verbose = 1, interactive = True)
while ret == 23:
ret = 0
if not try_telnet:
break
print(f'Detected running TELNET server. Try to start SSH server...')
if gw.passw and gw.passw != 'root':
print('Default TELNET password =', gw.passw)

Loading…
Cancel
Save