From 6d1ff52b02fa10ec0c0e1f906022d8a2943d9482 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Wed, 31 Jul 2024 21:11:49 +0000 Subject: [PATCH] Use literal NULs instead of pipes to differenciate between the message and client name --- server.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/server.py b/server.py index 28b9cec..5703fb7 100755 --- a/server.py +++ b/server.py @@ -36,6 +36,7 @@ G.killList = {} G.outboundLinks = [] G.S2SLogs = [] G.cwlgd = False +G.NUL = "\x00" saveLogs = True address = "::" # Try to load a message log, if one exists @@ -319,16 +320,16 @@ Please note that this is not network level statistics.\r\n""".encode( ) ) case "M": - cName = buffer[2:].split("|", 1)[0] - message = buffer[2:].split("|", 1)[1] + cName = buffer[2:].split(G.NUL, 1)[0] + message = buffer[2:].split(G.NUL, 1)[1] G.msgs.append(log(f" {cName}: {message}")) G.S2SLogs.append(("M", (cName, message), sName)) writer.write( b"I Get these damn heretic ghost clients out of my store so i can buy my cult candles in peace.\r\n" ) case "A": - cName = buffer[2:].split("|", 1)[0] - message = buffer[2:].split("|", 1)[1] + cName = buffer[2:].split(G.NUL, 1)[0] + message = buffer[2:].split(G.NUL, 1)[1] G.msgs.append(log(f"* {cName} {message}")) G.S2SLogs.append(("A", (cName, message), sName)) writer.write(b"I Mmm... Strawberries\r\n") @@ -371,10 +372,10 @@ Please note that this is not network level statistics.\r\n""".encode( match type: case "A": nick, msg = data - writer.write(f"A {nick}|{msg}\r\n".encode("utf8")) + writer.write(f"A {nick}{G.NUL}{msg}\r\n".encode("utf8")) case "M": nick, msg = data - writer.write(f"M {nick}|{msg}\r\n".encode("utf8")) + writer.write(f"M {nick}{G.NUL}{msg}\r\n".encode("utf8")) case "+": writer.write(f"+ {data}\r\n".encode("utf8")) case "-": @@ -505,16 +506,16 @@ async def connectServer(hostname: str, port: int): ) ) case "M": - cName = buffer[2:].split("|", 1)[0] - message = buffer[2:].split("|", 1)[1] + cName = buffer[2:].split(G.NUL, 1)[0] + message = buffer[2:].split(G.NUL, 1)[1] G.msgs.append(log(f" {cName}: {message}")) G.S2SLogs.append(("M", (cName, message), rID)) writer.write( b"I Get these damn heretic ghost clients out of my store so i can buy my cult candles in peace.\r\n" ) case "A": - cName = buffer[2:].split("|", 1)[0] - message = buffer[2:].split("|", 1)[1] + cName = buffer[2:].split(G.NUL, 1)[0] + message = buffer[2:].split(G.NUL, 1)[1] G.S2SLogs.append(("A", (cName, message), rID)) G.msgs.append(log(f"* {cName} {message}")) writer.write(b"I Mmm... Strawberries\r\n") @@ -556,10 +557,10 @@ async def connectServer(hostname: str, port: int): match type: case "A": nick, msg = data - writer.write(f"A {nick}|{msg}\r\n".encode("utf8")) + writer.write(f"A {nick}{G.NUL}{msg}\r\n".encode("utf8")) case "M": nick, msg = data - writer.write(f"M {nick}|{msg}\r\n".encode("utf8")) + writer.write(f"M {nick}{G.NUL}{msg}\r\n".encode("utf8")) case "+": writer.write(f"+ {data}\r\n".encode("utf8")) case "-":