mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 09:16:32 +01:00
Change GA style to not include endline, add FORCEDENDLINE for clients requiring GA+endline. See #1395.
This commit is contained in:
parent
9ed293b805
commit
587471c2b6
4 changed files with 24 additions and 12 deletions
|
|
@ -549,8 +549,11 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
try:
|
||||
old_val = flags.get(new_name, False)
|
||||
new_val = validator(new_val)
|
||||
flags[new_name] = new_val
|
||||
self.msg("Option |w%s|n was changed from '|w%s|n' to '|w%s|n'." % (new_name, old_val, new_val))
|
||||
if old_val == new_val:
|
||||
self.msg("Option |w%s|n was kept as '|w%s|n'." % (new_name, old_val))
|
||||
else:
|
||||
flags[new_name] = new_val
|
||||
self.msg("Option |w%s|n was changed from '|w%s|n' to '|w%s|n'." % (new_name, old_val, new_val))
|
||||
return {new_name: new_val}
|
||||
except Exception as err:
|
||||
self.msg("|rCould not set option |w%s|r:|n %s" % (new_name, err))
|
||||
|
|
@ -572,7 +575,8 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
"TERM": utils.to_str,
|
||||
"UTF-8": validate_bool,
|
||||
"XTERM256": validate_bool,
|
||||
"INPUTDEBUG": validate_bool}
|
||||
"INPUTDEBUG": validate_bool,
|
||||
"FORCEDENDLINE": validate_bool}
|
||||
|
||||
name = self.lhs.upper()
|
||||
val = self.rhs.strip()
|
||||
|
|
|
|||
|
|
@ -40,11 +40,9 @@ class SuppressGA(object):
|
|||
|
||||
self.protocol.protocol_flags["NOGOAHEAD"] = True
|
||||
# tell the client that we prefer to suppress GA ...
|
||||
self.protocol.will(SUPPRESS_GA).addCallbacks(self.do_suppress_ga, self.dont_suppress_ga)
|
||||
# ... but also accept if the client really wants not to.
|
||||
self.protocol.do(SUPPRESS_GA).addCallbacks(self.do_suppress_ga, self.dont_suppress_ga)
|
||||
self.protocol.will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)
|
||||
|
||||
def dont_suppress_ga(self, option):
|
||||
def wont_suppress_ga(self, option):
|
||||
"""
|
||||
Called when client requests to not suppress GA.
|
||||
|
||||
|
|
@ -55,9 +53,9 @@ class SuppressGA(object):
|
|||
self.protocol.protocol_flags["NOGOAHEAD"] = False
|
||||
self.protocol.handshake_done()
|
||||
|
||||
def do_suppress_ga(self, option):
|
||||
def will_suppress_ga(self, option):
|
||||
"""
|
||||
Client wants to suppress GA
|
||||
Client will suppress GA
|
||||
|
||||
Args:
|
||||
option (Option): Not used.
|
||||
|
|
|
|||
|
|
@ -231,11 +231,15 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
line (str): Line to send.
|
||||
|
||||
"""
|
||||
# escape IAC in line mode, and correctly add \r\n
|
||||
line += self.delimiter
|
||||
line = line.replace(IAC, IAC + IAC).replace('\n', '\r\n')
|
||||
# escape IAC in line mode, and correctly add \r\n (the TELNET end-of-line)
|
||||
line = line.replace(IAC, IAC + IAC)
|
||||
line = line.replace('\n', '\r\n')
|
||||
if not self.protocol_flags.get("NOGOAHEAD", True):
|
||||
if self.protocol_flags.get("FORCEDENDLINE", False):
|
||||
line += "\r\n"
|
||||
line += IAC + GA
|
||||
elif not line.endswith("\r\n"):
|
||||
line += "\r\n"
|
||||
return self.transport.write(mccp_compress(self, line))
|
||||
|
||||
# Session hooks
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class Ttype(object):
|
|||
"""
|
||||
self.ttype_step = 0
|
||||
self.protocol = protocol
|
||||
# we set FORCEDENDLINE for clients not supporting ttype
|
||||
self.protocol.protocol_flags["FORCEDENDLINE"] = True
|
||||
self.protocol.protocol_flags['TTYPE'] = False
|
||||
# is it a safe bet to assume ANSI is always supported?
|
||||
self.protocol.protocol_flags['ANSI'] = True
|
||||
|
|
@ -98,6 +100,10 @@ class Ttype(object):
|
|||
# just start the request chain
|
||||
self.protocol.requestNegotiation(TTYPE, SEND)
|
||||
|
||||
# for clients that support TTYPE we assume this is not needed
|
||||
# (they can set it manually if so)
|
||||
self.protocol.protocol_flags["FORCEDENDLINE"] = False
|
||||
|
||||
elif self.ttype_step == 1:
|
||||
# this is supposed to be the name of the client/terminal.
|
||||
# For clients not supporting the extended TTYPE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue