summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2022-02-21 00:32:15 +0300
committerdefanor <defanor@uberspace.net>2022-02-21 00:32:15 +0300
commite709aecbac488368db7b57541626e6c9aa798c88 (patch)
tree75c81776907254f7801f19c3ec2ebb12304ea110
parent3aea9ca26b84d71a9427fa3639f213a3ee832837 (diff)
Fix accidental swapping of SB and data in dwproxy.py
The callback is invoked by telnetlib before data processing even if it's after the data in a received stream, which led in particular to the proxy sending SB before the data to a client, making the client to hide it.
-rwxr-xr-xdwproxy.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/dwproxy.py b/dwproxy.py
index e4205cc..d23660d 100755
--- a/dwproxy.py
+++ b/dwproxy.py
@@ -74,8 +74,13 @@ class TelnetHandler(socketserver.BaseRequestHandler):
logging.debug("GMCP command received: %s %s",
gmcp_cmd.decode('ascii'),
json.loads(gmcp_json))
- self.request.sendall(sb_data)
- self.request.sendall(telnetlib.IAC + c + opt)
+ self.request.sendall(telnetlib.IAC + telnetlib.SB + self.sb_opt +
+ sb_data +
+ telnetlib.IAC + telnetlib.SE)
+ elif c == telnetlib.SB:
+ self.sb_opt = opt
+ else:
+ self.request.sendall(telnetlib.IAC + c + opt)
def process_cmd(self, s):
"""Processes client commands."""
@@ -179,6 +184,7 @@ class TelnetHandler(socketserver.BaseRequestHandler):
"""Client connection handling."""
logging.info("A new connection from %s", self.client_address)
self.gmcp_data = {"room.info": {"identifier": None}}
+ self.sb_opt = None
try:
with telnetlib.Telnet(self.server.args.host,
self.server.args.port) as tn: