mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Added telnet option ECHO, so that server can request no local echo on client. Related with feature request #540
This commit is contained in:
parent
9ed8e92c71
commit
efd2eeafb8
2 changed files with 19 additions and 5 deletions
|
|
@ -88,6 +88,7 @@ class CmdUsernameSelect(Command):
|
|||
else:
|
||||
# store the player so next step can find it
|
||||
self.menutree.player = player
|
||||
self.caller.msg("", switchecho="off")
|
||||
self.menutree.goto("node1b")
|
||||
|
||||
|
||||
|
|
@ -103,6 +104,7 @@ class CmdPasswordSelectBack(Command):
|
|||
def func(self):
|
||||
"Execute the command"
|
||||
self.menutree.goto("node1a")
|
||||
self.caller.msg("", switchecho="on")
|
||||
|
||||
|
||||
class CmdPasswordSelect(Command):
|
||||
|
|
@ -114,6 +116,7 @@ class CmdPasswordSelect(Command):
|
|||
|
||||
def func(self):
|
||||
"Execute the command"
|
||||
self.caller.msg("", switchecho="on")
|
||||
if not hasattr(self.menutree, "player"):
|
||||
self.caller.msg("{rSomething went wrong! The player was not remembered from last step!{n")
|
||||
self.menutree.goto("node1a")
|
||||
|
|
@ -178,6 +181,7 @@ its and @/./+/-/_ only.{n") # this echoes the restrictions made by django's auth
|
|||
return
|
||||
# store the name for the next step
|
||||
self.menutree.playername = playername
|
||||
self.caller.msg("", switchecho="off")
|
||||
self.menutree.goto("node2b")
|
||||
|
||||
|
||||
|
|
@ -190,6 +194,7 @@ class CmdPasswordCreateBack(Command):
|
|||
|
||||
def func(self):
|
||||
"Execute the command"
|
||||
self.caller.msg("", switchecho="on")
|
||||
self.menutree.goto("node2a")
|
||||
|
||||
|
||||
|
|
@ -201,6 +206,7 @@ class CmdPasswordCreate(Command):
|
|||
def func(self):
|
||||
"Execute the command"
|
||||
password = self.args
|
||||
self.caller.msg("", switchecho="on")
|
||||
if not hasattr(self.menutree, 'playername'):
|
||||
self.caller.msg("{rSomething went wrong! Playername not remembered from previous step!{n")
|
||||
self.menutree.goto("node2a")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ sessions etc.
|
|||
"""
|
||||
|
||||
import re
|
||||
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE, GA
|
||||
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE, GA, WILL, WONT, ECHO
|
||||
from src.server.session import Session
|
||||
from src.server.portal import ttype, mssp, msdp, naws
|
||||
from src.server.portal.mccp import Mccp, mccp_compress, MCCP
|
||||
|
|
@ -87,16 +87,19 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
"""
|
||||
Call to allow the activation of options for this protocol
|
||||
"""
|
||||
return option == MCCP
|
||||
return (option == MCCP or option==ECHO)
|
||||
|
||||
def disableLocal(self, option):
|
||||
"""
|
||||
Disable a given option
|
||||
"""
|
||||
if option == ECHO:
|
||||
return True
|
||||
if option == MCCP:
|
||||
self.mccp.no_mccp(option)
|
||||
return True
|
||||
else:
|
||||
|
||||
return super(TelnetProtocol, self).disableLocal(option)
|
||||
|
||||
def connectionLost(self, reason):
|
||||
|
|
@ -206,7 +209,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
not convert them into ansi tokens)
|
||||
prompt=<string> - supply a prompt text which gets sent without a
|
||||
newline added to the end
|
||||
|
||||
switchecho="on"/"off"
|
||||
The telnet ttype negotiation flags, if any, are used if no kwargs
|
||||
are given.
|
||||
"""
|
||||
|
|
@ -231,7 +234,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
raw = kwargs.get("raw", False)
|
||||
nomarkup = kwargs.get("nomarkup", not (xterm256 or useansi))
|
||||
prompt = kwargs.get("prompt")
|
||||
|
||||
switchecho = kwargs.get("switchecho")
|
||||
#print "telnet kwargs=%s, message=%s" % (kwargs, text)
|
||||
#print "xterm256=%s, useansi=%s, raw=%s, nomarkup=%s, init_done=%s" % (xterm256, useansi, raw, nomarkup, ttype.get("init_done"))
|
||||
if raw:
|
||||
|
|
@ -249,4 +252,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
prompt = prompt.replace(IAC, IAC + IAC).replace('\n', '\r\n')
|
||||
prompt += IAC + GA
|
||||
self.transport.write(mccp_compress(self, prompt))
|
||||
|
||||
if switchecho:
|
||||
if switchecho == "on":
|
||||
self.transport.write(mccp_compress(self, IAC+WONT+ECHO))
|
||||
if switchecho == "off":
|
||||
self.transport.write(mccp_compress(self, IAC+WILL+ECHO))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue