Add a setting to change telnet default encoding
This commit is contained in:
parent
2dae4c4c6f
commit
abaf8d0a19
3 changed files with 15 additions and 3 deletions
|
|
@ -24,7 +24,7 @@ _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_SCREENREADER_REGEX = re.compile(r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE)
|
||||
_IDLE_COMMAND = settings.IDLE_COMMAND + "\n"
|
||||
|
||||
_TELNET_ENCODING = settings.TELNET_ENCODING
|
||||
|
||||
class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||
"""
|
||||
|
|
@ -49,7 +49,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
# this number is counted down for every handshake that completes.
|
||||
# when it reaches 0 the portal/server syncs their data
|
||||
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})
|
||||
|
||||
# suppress go-ahead
|
||||
self.sga = suppress_ga.SuppressGA(self)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Session(object):
|
|||
'conn_time', 'cmd_last', 'cmd_last_visible', 'cmd_total',
|
||||
'protocol_flags', 'server_data', "cmdset_storage_string")
|
||||
|
||||
def init_session(self, protocol_key, address, sessionhandler):
|
||||
def init_session(self, protocol_key, address, sessionhandler, override_flags=None):
|
||||
"""
|
||||
Initialize the Session. This should be called by the protocol when
|
||||
a new session is established.
|
||||
|
|
@ -52,6 +52,7 @@ class Session(object):
|
|||
address (str): Client address.
|
||||
sessionhandler (SessionHandler): Reference to the
|
||||
main sessionhandler instance.
|
||||
override_flags (optional, dict): a dictionary of protocol flags to override.
|
||||
|
||||
"""
|
||||
# This is currently 'telnet', 'ssh', 'ssl' or 'web'
|
||||
|
|
@ -87,6 +88,10 @@ class Session(object):
|
|||
"INPUTDEBUG": False,
|
||||
"RAW": False,
|
||||
"NOCOLOR": False}
|
||||
|
||||
if override_flags:
|
||||
self.protocol_flags.update(override_flags)
|
||||
|
||||
self.server_data = {}
|
||||
|
||||
# map of input data to session methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue