Fix annoying OptionRefused error when connecting from many clients
This commit is contained in:
parent
03356465db
commit
60f5b8c100
1 changed files with 29 additions and 13 deletions
|
|
@ -76,26 +76,20 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def dataReceived(self, data):
|
def dataReceived(self, data):
|
||||||
print(f"indata: {data}")
|
"""
|
||||||
|
Unused by default, but a good place to put debug printouts
|
||||||
|
of incoming data.
|
||||||
|
"""
|
||||||
|
# print(f"telnet dataReceived: {data}")
|
||||||
super().dataReceived(data)
|
super().dataReceived(data)
|
||||||
|
|
||||||
def wont_no_true(self, state, option):
|
|
||||||
from evennia.utils import logger
|
|
||||||
logger.log_err(f"wont_no_true {self}, {state}, {option}")
|
|
||||||
super().wont_no_true(state, options)
|
|
||||||
|
|
||||||
def dont_no_true(self, state, option):
|
|
||||||
from evennia.utils import logger
|
|
||||||
logger.log_err(f"dont_no_true {self}, {state}, {option}")
|
|
||||||
super().dont_no_true(state, options)
|
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
"""
|
"""
|
||||||
This is called when the connection is first established.
|
This is called when the connection is first established.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# important in order to work normally with standard telnet
|
# important in order to work normally with standard telnet
|
||||||
self.do(LINEMODE)
|
self.do(LINEMODE).addErrback(self._wont_linemode)
|
||||||
# initialize the session
|
# initialize the session
|
||||||
self.line_buffer = b""
|
self.line_buffer = b""
|
||||||
client_address = self.transport.client
|
client_address = self.transport.client
|
||||||
|
|
@ -140,6 +134,15 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
self.nop_keep_alive = None
|
self.nop_keep_alive = None
|
||||||
self.toggle_nop_keepalive()
|
self.toggle_nop_keepalive()
|
||||||
|
|
||||||
|
def _wont_linemode(self, *args):
|
||||||
|
"""
|
||||||
|
Client refuses do(linemode). This is common for MUD-specific
|
||||||
|
clients, but we must ask for the sake of raw telnet. We ignore
|
||||||
|
this error.
|
||||||
|
"""
|
||||||
|
print("client refuses line mode")
|
||||||
|
pass
|
||||||
|
|
||||||
def _send_nop_keepalive(self):
|
def _send_nop_keepalive(self):
|
||||||
"""Send NOP keepalive unless flag is set"""
|
"""Send NOP keepalive unless flag is set"""
|
||||||
if self.protocol_flags.get("NOPKEEPALIVE"):
|
if self.protocol_flags.get("NOPKEEPALIVE"):
|
||||||
|
|
@ -195,7 +198,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
if option == LINEMODE:
|
if option == LINEMODE:
|
||||||
# make sure to activate line mode with local editing for all clients
|
# make sure to activate line mode with local editing for all clients
|
||||||
self.requestNegotiation(
|
self.requestNegotiation(
|
||||||
LINEMODE, MODE + bytes(chr(ord(LINEMODE_EDIT) + ord(LINEMODE_TRAPSIG)), "ascii")
|
LINEMODE, MODE + bytes(chr(ord(LINEMODE_EDIT) +
|
||||||
|
ord(LINEMODE_TRAPSIG)), "ascii")
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
@ -207,6 +211,16 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
or option == suppress_ga.SUPPRESS_GA
|
or option == suppress_ga.SUPPRESS_GA
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def disableRemote(self, option):
|
||||||
|
return (
|
||||||
|
option == LINEMODE
|
||||||
|
or option == ttype.TTYPE
|
||||||
|
or option == naws.NAWS
|
||||||
|
or option == MCCP
|
||||||
|
or option == mssp.MSSP
|
||||||
|
or option == suppress_ga.SUPPRESS_GA
|
||||||
|
)
|
||||||
|
|
||||||
def enableLocal(self, option):
|
def enableLocal(self, option):
|
||||||
"""
|
"""
|
||||||
Call to allow the activation of options for this protocol
|
Call to allow the activation of options for this protocol
|
||||||
|
|
@ -233,6 +247,8 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
option (char): The telnet option to disable locally.
|
option (char): The telnet option to disable locally.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if option == LINEMODE:
|
||||||
|
return True
|
||||||
if option == ECHO:
|
if option == ECHO:
|
||||||
return True
|
return True
|
||||||
if option == MCCP:
|
if option == MCCP:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue