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
|
return False
|
||||||
|
|
||||||
def get_telnet(self, verbose = 0, password = None):
|
def get_telnet(self, verbose = 0, password = None):
|
||||||
|
from telnetlib import NOP, IAC, SB, NAWS, SE
|
||||||
try:
|
try:
|
||||||
tn = telnetlib.Telnet(self.ip_addr, timeout=4)
|
tn = telnetlib.Telnet(self.ip_addr, timeout=4)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -799,10 +800,11 @@ class Gateway():
|
|||||||
try:
|
try:
|
||||||
p_login = b'login: '
|
p_login = b'login: '
|
||||||
p_passw = b'Password: '
|
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)
|
idx, obj, output = tn.expect([p_login, prompt], timeout=2)
|
||||||
if idx < 0:
|
if idx < 0:
|
||||||
raise Exception('TELNET auth error (1)')
|
raise Exception('TELNET auth error (1)')
|
||||||
|
tn.sock.sendall(IAC + SB + NAWS + b'\x03\xE8\x00\x20' + IAC + SE)
|
||||||
if idx > 0:
|
if idx > 0:
|
||||||
tn.prompt = obj.group()
|
tn.prompt = obj.group()
|
||||||
return tn
|
return tn
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ import socket
|
|||||||
import selectors
|
import selectors
|
||||||
from time import monotonic as _time
|
from time import monotonic as _time
|
||||||
|
|
||||||
__all__ = ["Telnet"]
|
|
||||||
|
|
||||||
# Tunable parameters
|
# Tunable parameters
|
||||||
DEBUGLEVEL = 0
|
DEBUGLEVEL = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user