diff --git a/connect.py b/connect.py index 29dc722..c957fff 100644 --- a/connect.py +++ b/connect.py @@ -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: diff --git a/gateway.py b/gateway.py index 0f3c33a..e4d6d49 100644 --- a/gateway.py +++ b/gateway.py @@ -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)