Simplify telnet edefault encoding

This commit is contained in:
Vincent Le Goff 2017-12-12 20:51:16 +01:00
parent 8f5a28455e
commit 0acf0246c7
2 changed files with 4 additions and 10 deletions

View file

@ -24,7 +24,6 @@ _RE_LEND = re.compile(r"\n$|\r$|\r\n$|\r\x00$|", re.MULTILINE)
_RE_LINEBREAK = re.compile(r"\n\r|\r\n|\n|\r", re.DOTALL + re.MULTILINE) _RE_LINEBREAK = re.compile(r"\n\r|\r\n|\n|\r", re.DOTALL + re.MULTILINE)
_RE_SCREENREADER_REGEX = re.compile(r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE) _RE_SCREENREADER_REGEX = re.compile(r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE)
_IDLE_COMMAND = settings.IDLE_COMMAND + "\n" _IDLE_COMMAND = settings.IDLE_COMMAND + "\n"
_TELNET_ENCODING = settings.ENCODINGS[0]
class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session): class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
""" """
@ -49,8 +48,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
# this number is counted down for every handshake that completes. # this number is counted down for every handshake that completes.
# when it reaches 0 the portal/server syncs their data # when it reaches 0 the portal/server syncs their data
self.handshakes = 8 # suppress-go-ahead, naws, ttype, mccp, mssp, msdp, gmcp, mxp self.handshakes = 8 # suppress-go-ahead, naws, ttype, mccp, mssp, msdp, gmcp, mxp
self.init_session(self.protocol_name, client_address, self.factory.sessionhandler, self.init_session(self.protocol_name, client_address, self.factory.sessionhandler)
override_flags={"ENCODING": _TELNET_ENCODING}) # change encoding to ENCODINGS[0] which reflects Telnet default encoding
self.protocol_flags["ENCODING"] = settings.ENCODINGS[0]
# suppress go-ahead # suppress go-ahead
self.sga = suppress_ga.SuppressGA(self) self.sga = suppress_ga.SuppressGA(self)

View file

@ -7,7 +7,6 @@ from builtins import object
import time import time
#------------------------------------------------------------ #------------------------------------------------------------
# Server Session # Server Session
#------------------------------------------------------------ #------------------------------------------------------------
@ -41,7 +40,7 @@ class Session(object):
'conn_time', 'cmd_last', 'cmd_last_visible', 'cmd_total', 'conn_time', 'cmd_last', 'cmd_last_visible', 'cmd_total',
'protocol_flags', 'server_data', "cmdset_storage_string") 'protocol_flags', 'server_data', "cmdset_storage_string")
def init_session(self, protocol_key, address, sessionhandler, override_flags=None): def init_session(self, protocol_key, address, sessionhandler):
""" """
Initialize the Session. This should be called by the protocol when Initialize the Session. This should be called by the protocol when
a new session is established. a new session is established.
@ -52,7 +51,6 @@ class Session(object):
address (str): Client address. address (str): Client address.
sessionhandler (SessionHandler): Reference to the sessionhandler (SessionHandler): Reference to the
main sessionhandler instance. main sessionhandler instance.
override_flags (optional, dict): a dictionary of protocol flags to override.
""" """
# This is currently 'telnet', 'ssh', 'ssl' or 'web' # This is currently 'telnet', 'ssh', 'ssl' or 'web'
@ -88,10 +86,6 @@ class Session(object):
"INPUTDEBUG": False, "INPUTDEBUG": False,
"RAW": False, "RAW": False,
"NOCOLOR": False} "NOCOLOR": False}
if override_flags:
self.protocol_flags.update(override_flags)
self.server_data = {} self.server_data = {}
# map of input data to session methods # map of input data to session methods