Fixing a bug happening if connecting with plain telnet caused by the TTYPE handshake not being properly handled. Also made color default for telnet, hopefully all terminals should handle color by now?

This commit is contained in:
Griatch 2012-04-12 23:39:22 +02:00
parent 4977153de2
commit 9475fbd0d9
4 changed files with 6 additions and 13 deletions

View file

@ -20,7 +20,7 @@ try:
except ImportError:
import pickle
from twisted.protocols import amp
from twisted.internet import protocol, defer
from twisted.internet import protocol
from django.conf import settings
from src.utils.utils import to_str
@ -303,7 +303,7 @@ class AMPProtocol(amp.AMP):
sessid=sessid,
data=dumps(data)).addErrback(self.errback, "OOBPortal2Server")
# Server -> Portal message
# OOB Server -> Portal message
def amp_oob_server2portal(self, sessid, data):
"""
@ -316,7 +316,7 @@ class AMPProtocol(amp.AMP):
def call_remote_OOBServer2Portal(self, sessid, data=""):
"""
Access method called by the Server and executed on the Server.
Access method called by the Server and executed on the Portal.
"""
#print "oob server->portal (server side):", sessid, data
self.callRemote(OOBServer2Portal,

View file

@ -193,7 +193,6 @@ class ServerSession(Session):
# all other inputs, including empty inputs
character = self.get_character()
if character:
character.execute_cmd(command_string)
else:
@ -212,7 +211,6 @@ class ServerSession(Session):
"""
self.sessionhandler.data_out(self, msg, data)
def oob_data_in(self, data):
"""
This receives out-of-band data from the Portal.
@ -286,7 +284,6 @@ class ServerSession(Session):
"""
return u"%s" % str(self)
# easy-access functions
def login(self, player):

View file

@ -7,7 +7,7 @@ sessions etc.
"""
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE, DO, DONT
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE
from src.server.session import Session
from src.server import ttype, mssp
from src.server.mccp import Mccp, mccp_compress, MCCP
@ -27,10 +27,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
# initialize the session
client_address = self.transport.client
self.init_session("telnet", client_address, self.factory.sessionhandler)
# negotiate mccp (data compression)
self.mccp = Mccp(self)
# negotiate ttype (client info)
self.ttype = ttype.Ttype(self)
@ -142,7 +140,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
self.sendLine(str(e))
return
ttype = self.protocol_flags.get('TTYPE', {})
nomarkup = not (ttype.get('256 COLORS') or ttype.get('ANSI') or not ttype.get("init_done"))
nomarkup = not (ttype or ttype.get('256 COLORS') or ttype.get('ANSI') or not ttype.get("init_done"))
raw = False
if type(data) == dict:
# check if we want escape codes to go through unparsed.

View file

@ -42,7 +42,6 @@ class Ttype(object):
self.ttype_step = 0
self.protocol = protocol
self.protocol.protocol_flags['TTYPE'] = {"init_done":False}
# setup protocol to handle ttype initialization and negotiation
self.protocol.negotiationMap[TTYPE] = self.do_ttype
# ask if client will ttype, connect callback if it does.
@ -52,7 +51,7 @@ class Ttype(object):
"""
Callback if ttype is not supported by client.
"""
self.protocol.protocol_flags['TTYPE'] = False
self.protocol.protocol_flags['TTYPE'] = {"init_done":True}
def do_ttype(self, option):
"""
@ -64,7 +63,6 @@ class Ttype(object):
certain piece of information about the client. All data is
stored on protocol.protocol_flags under the TTYPE key.
"""
if self.protocol.protocol_flags['TTYPE']['init_done']:
return