gateway: Fix prompt in get_telnet and set TELNET window size: 1000x32

pull/92/head
remittor 6 months ago
parent fea8d7df80
commit e46d952586

@ -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

Loading…
Cancel
Save