Implement SUPPRESS-GO-AHEAD telnet option

With the current setup, the server will negotiate SUPPRESS-GO-AHEAD
as follows:
  Server sends WILL SUPPRESS-GO-AHEAD
  Client will then send or reply with DO/DONT SUPPRESS-GO-AHEAD
Evennia will abide by the instruction of the client, but defaults
to suppressing GA messages after every line.
This commit is contained in:
Griatch 2017-06-06 00:03:16 +02:00
parent f0d632cb51
commit 63eec3a659
3 changed files with 15 additions and 8 deletions

View file

@ -560,7 +560,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
"CLIENTNAME": utils.to_str, "CLIENTNAME": utils.to_str,
"ENCODING": validate_encoding, "ENCODING": validate_encoding,
"MCCP": validate_bool, "MCCP": validate_bool,
"MUDPROMPT": validate_bool, "NOGOAHEAD": validate_bool,
"MXP": validate_bool, "MXP": validate_bool,
"NOCOLOR": validate_bool, "NOCOLOR": validate_bool,
"NOPKEEPALIVE": validate_bool, "NOPKEEPALIVE": validate_bool,

View file

@ -194,7 +194,7 @@ def client_options(session, *args, **kwargs):
"MCCP", "SCREENHEIGHT", "MCCP", "SCREENHEIGHT",
"SCREENWIDTH", "INPUTDEBUG", "SCREENWIDTH", "INPUTDEBUG",
"RAW", "NOCOLOR", "RAW", "NOCOLOR",
"MUDPROMPT")) "NOGOAHEAD"))
session.msg(client_options=options) session.msg(client_options=options)
return return
@ -245,6 +245,8 @@ def client_options(session, *args, **kwargs):
flags["NOCOLOR"] = validate_bool(value) flags["NOCOLOR"] = validate_bool(value)
elif key == "raw": elif key == "raw":
flags["RAW"] = validate_bool(value) flags["RAW"] = validate_bool(value)
elif key == "nogoahead":
flags["NOGOAHEAD"] = validate_bool(value)
elif key in ('Char 1', 'Char.Skills 1', 'Char.Items 1', elif key in ('Char 1', 'Char.Skills 1', 'Char.Items 1',
'Room 1', 'IRE.Rift 1', 'IRE.Composer 1'): 'Room 1', 'IRE.Rift 1', 'IRE.Composer 1'):
# ignore mudlet's default send (aimed at IRE games) # ignore mudlet's default send (aimed at IRE games)

View file

@ -13,7 +13,7 @@ from twisted.conch.telnet import Telnet, StatefulTelnetProtocol
from twisted.conch.telnet import IAC, NOP, LINEMODE, GA, WILL, WONT, ECHO, NULL from twisted.conch.telnet import IAC, NOP, LINEMODE, GA, WILL, WONT, ECHO, NULL
from django.conf import settings from django.conf import settings
from evennia.server.session import Session from evennia.server.session import Session
from evennia.server.portal import ttype, mssp, telnet_oob, naws from evennia.server.portal import ttype, mssp, telnet_oob, naws, suppress_ga
from evennia.server.portal.mccp import Mccp, mccp_compress, MCCP from evennia.server.portal.mccp import Mccp, mccp_compress, MCCP
from evennia.server.portal.mxp import Mxp, mxp_parse from evennia.server.portal.mxp import Mxp, mxp_parse
from evennia.utils import ansi from evennia.utils import ansi
@ -47,9 +47,11 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
client_address = client_address[0] if client_address else None client_address = client_address[0] if client_address else None
# 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 = 7 # 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)
# suppress go-ahead
self.sga = suppress_ga.SuppressGA(self)
# negotiate client size # negotiate client size
self.naws = naws.Naws(self) self.naws = naws.Naws(self)
# negotiate ttype (client info) # negotiate ttype (client info)
@ -128,7 +130,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
option == ttype.TTYPE or option == ttype.TTYPE or
option == naws.NAWS or option == naws.NAWS or
option == MCCP or option == MCCP or
option == mssp.MSSP) option == mssp.MSSP or
option == suppress_ga.SUPPRESS_GA)
def enableLocal(self, option): def enableLocal(self, option):
""" """
@ -141,7 +144,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
enable (bool): If this option should be enabled. enable (bool): If this option should be enabled.
""" """
return option == MCCP or option == ECHO return (option == MCCP or
option == ECHO or
option == suppress_ga.SUPPRESS_GA)
def disableLocal(self, option): def disableLocal(self, option):
""" """
@ -221,8 +226,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
# escape IAC in line mode, and correctly add \r\n # escape IAC in line mode, and correctly add \r\n
line += self.delimiter line += self.delimiter
line = line.replace(IAC, IAC + IAC).replace('\n', '\r\n') line = line.replace(IAC, IAC + IAC).replace('\n', '\r\n')
if self.protocol_flags.get("MUDPROMPT", False): if not self.protocol_flags.get("NOGOAHEAD", True):
line = line + IAC + GA line += IAC + GA
return self.transport.write(mccp_compress(self, line)) return self.transport.write(mccp_compress(self, line))
# Session hooks # Session hooks