handle clients that send only \r for enter key

This commit is contained in:
Jeremy Penner 2020-06-27 18:53:10 -04:00
parent 59f0fc890a
commit 23c1b75be4

View file

@ -142,11 +142,18 @@ class AnsiTelnet(protocol.Protocol):
self.client.removeDgQuit(self.transport.loseConnection) self.client.removeDgQuit(self.transport.loseConnection)
self.client.quit() self.client.quit()
class DOSNewlineTelnetTransport(telnet.TelnetTransport):
def dataReceived(self, data):
telnet.TelnetTransport.dataReceived(self, data)
if self.state == 'newline':
self.state = 'data'
self.applicationDataReceived(b'\r')
class AnsiFactory(ServerFactory): class AnsiFactory(ServerFactory):
def __init__(self, fnRun): def __init__(self, fnRun):
self.fnRun = fnRun self.fnRun = fnRun
def buildProtocol(self, addr): def buildProtocol(self, addr):
p = telnet.TelnetTransport(AnsiTelnet, engine.Client()) p = DOSNewlineTelnetTransport(AnsiTelnet, engine.Client())
p.factory = self p.factory = self
print "built protocol for ", addr print "built protocol for ", addr
return p return p