mirror of
https://github.com/openwrt-xiaomi/xmir-patcher.git
synced 2026-09-22 22:57:55 +03:00
gateway: Fix prompt in get_telnet and set TELNET window size: 1000x32
This commit is contained in:
+3
-1
@@ -790,6 +790,7 @@ class Gateway():
|
||||
return False
|
||||
|
||||
def get_telnet(self, verbose = 0, password = None):
|
||||
from telnetlib import NOP, IAC, SB, NAWS, SE
|
||||
try:
|
||||
tn = telnetlib.Telnet(self.ip_addr, timeout=4)
|
||||
except Exception as e:
|
||||
@@ -799,10 +800,11 @@ class Gateway():
|
||||
try:
|
||||
p_login = b'login: '
|
||||
p_passw = b'Password: '
|
||||
prompt = f"{self.login}@XiaoQiang:(.*?)#".encode('ascii')
|
||||
prompt = f"{self.login}@XiaoQiang:(.*?)# ".encode('ascii')
|
||||
idx, obj, output = tn.expect([p_login, prompt], timeout=2)
|
||||
if idx < 0:
|
||||
raise Exception('TELNET auth error (1)')
|
||||
tn.sock.sendall(IAC + SB + NAWS + b'\x03\xE8\x00\x20' + IAC + SE)
|
||||
if idx > 0:
|
||||
tn.prompt = obj.group()
|
||||
return tn
|
||||
|
||||
@@ -38,8 +38,6 @@ import socket
|
||||
import selectors
|
||||
from time import monotonic as _time
|
||||
|
||||
__all__ = ["Telnet"]
|
||||
|
||||
# Tunable parameters
|
||||
DEBUGLEVEL = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user