mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 09:16:32 +01:00
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
|
||||
|
|
|
|||
|
|
@ -166,6 +166,12 @@ IDLE_TIMEOUT = -1
|
|||
# command-name is given here; this is because the webclient needs a default
|
||||
# to send to avoid proxy timeouts.
|
||||
IDLE_COMMAND = "idle"
|
||||
# The encoding (character set) specific to Telnet. This will not influence
|
||||
# other encoding settings: namely, the webclient, the website, the
|
||||
# database encoding will remain (utf-8 by default). This setting only
|
||||
# affects the telnet encoding and will be overridden by user settings
|
||||
# (through one of their client's supported protocol or their account options).
|
||||
TELNET_ENCODING = "utf-8"
|
||||
# The set of encodings tried. An Account object may set an attribute "encoding" on
|
||||
# itself to match the client used. If not set, or wrong encoding is
|
||||
# given, this list is tried, in order, aborting on the first match.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue