WindowsXP telnet support
This commit is contained in:
parent
284c3932dd
commit
6ab9c030ba
2 changed files with 63 additions and 63 deletions
4
logs.py
4
logs.py
|
@ -33,9 +33,9 @@ def log(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for line in message.split("\n"):
|
for line in message.split("\n"):
|
||||||
log = log + f"\n[{level}]{'['+origin+']' if origin else ''}[{time}] {line}"
|
log = log + f"\r\n[{level}]{'['+origin+']' if origin else ''}[{time}] {line}"
|
||||||
print(
|
print(
|
||||||
f"[{level}]{'['+origin+']' if origin else ''}[{time}] {line}",
|
f"[{level}]{'['+origin+']' if origin else ''}[{time}] {line}",
|
||||||
file=stream,
|
file=stream,
|
||||||
)
|
)
|
||||||
return (log[5:] + "\n").encode("utf8")
|
return (log[5:] + "\r\n").encode("utf8")
|
||||||
|
|
122
server.py
122
server.py
|
@ -96,7 +96,7 @@ except Exception:
|
||||||
|
|
||||||
if not saveLogs:
|
if not saveLogs:
|
||||||
G.msgs.append(
|
G.msgs.append(
|
||||||
b"[00-00-0000 00:00:00] Notice: Logging is disabled on this server instance!\n"
|
b"[00-00-0000 00:00:00] Notice: Logging is disabled on this server instance!\r\n"
|
||||||
)
|
)
|
||||||
if len(G.remoteID) > 16:
|
if len(G.remoteID) > 16:
|
||||||
G.remoteID = G.remoteID[:15]
|
G.remoteID = G.remoteID[:15]
|
||||||
|
@ -122,7 +122,7 @@ async def handleClient(reader, writer):
|
||||||
try:
|
try:
|
||||||
name = ""
|
name = ""
|
||||||
global G
|
global G
|
||||||
writer.write(b"Please identify yourself. Nick limit is 20 chars.\n")
|
writer.write(b"Please identify yourself. Nick limit is 20 chars.\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
name = raw((await reader.read(20)).decode("utf8"))
|
name = raw((await reader.read(20)).decode("utf8"))
|
||||||
if len(name) > 20:
|
if len(name) > 20:
|
||||||
|
@ -136,13 +136,13 @@ async def handleClient(reader, writer):
|
||||||
except TimeoutErrors:
|
except TimeoutErrors:
|
||||||
pass
|
pass
|
||||||
if not name:
|
if not name:
|
||||||
writer.write(b"Nice try. Actually set a nick.\n")
|
writer.write(b"Nice try. Actually set a nick.\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
writer.close()
|
writer.close()
|
||||||
await writer.wait_closed()
|
await writer.wait_closed()
|
||||||
return
|
return
|
||||||
if name.lower() in G.clientsConnected:
|
if name.lower() in G.clientsConnected:
|
||||||
writer.write(f"Nick ({name}) in use\n".encode("utf8"))
|
writer.write(f"Nick ({name}) in use\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
writer.close()
|
writer.close()
|
||||||
await writer.wait_closed()
|
await writer.wait_closed()
|
||||||
|
@ -166,25 +166,25 @@ async def handleClient(reader, writer):
|
||||||
G.S2SLogs.append(("A", (name, request[4:]), G.remoteID))
|
G.S2SLogs.append(("A", (name, request[4:]), G.remoteID))
|
||||||
elif request.startswith("/h"):
|
elif request.startswith("/h"):
|
||||||
writer.write(
|
writer.write(
|
||||||
b"""Command List:
|
b"""Command List:\r
|
||||||
/me <action> - Sends a special message so it looks like you did <action>
|
/me <action> - Sends a special message so it looks like you did <action>\r
|
||||||
/mes <action> - Same as /me, but adds a 's onto your nick
|
/mes <action> - Same as /me, but adds a 's onto your nick\r
|
||||||
/afk [reason] - Optional reason, short hand for `/me is afk [to [reason]]`
|
/afk [reason] - Optional reason, short hand for `/me is afk [to [reason]]`\r
|
||||||
/h, /help - Triggers this command listing
|
/h, /help - Triggers this command listing\r
|
||||||
/back - Shorthand for `/me is back`
|
/back - Shorthand for `/me is back`\r
|
||||||
/stats - Sends you some server stats
|
/stats - Sends you some server stats\r
|
||||||
/quit - Disconnects you from the server\n"""
|
/quit - Disconnects you from the server\r\n"""
|
||||||
)
|
)
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
elif request.startswith("/stats"):
|
elif request.startswith("/stats"):
|
||||||
writer.write(
|
writer.write(
|
||||||
f"""Server stats:
|
f"""Server stats:\r
|
||||||
Linked servers: {len(G.servers)}
|
Linked servers: {len(G.servers)}\r
|
||||||
Connected clients: {G.uniqueClients}
|
Connected clients: {G.uniqueClients}\r
|
||||||
Total Clients: {len(G.clientsConnected)}
|
Total Clients: {len(G.clientsConnected)}\r
|
||||||
Messages sent: {len(G.msgs)}
|
Messages sent: {len(G.msgs)}\r
|
||||||
|
\r
|
||||||
Please note that this is not network level statistics.\n""".encode(
|
Please note that this is not network level statistics.\r\n""".encode(
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -215,7 +215,7 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
msgIndex = len(G.msgs)
|
msgIndex = len(G.msgs)
|
||||||
if name.lower() in G.killList and G.killList[name.lower()]:
|
if name.lower() in G.killList and G.killList[name.lower()]:
|
||||||
writer.write(b"Your client has been killed by the server\n")
|
writer.write(b"Your client has been killed by the server\r\n")
|
||||||
G.killList[name.lower()] = False
|
G.killList[name.lower()] = False
|
||||||
break
|
break
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
@ -240,7 +240,7 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
G.msgs.append(log(f"{sName} has linked to the network"))
|
G.msgs.append(log(f"{sName} has linked to the network"))
|
||||||
G.servers[sName] = {}
|
G.servers[sName] = {}
|
||||||
msgIndex = 0
|
msgIndex = 0
|
||||||
writer.write(b"I am awaiting your client listing.\n")
|
writer.write(b"I am awaiting your client listing.\r\n")
|
||||||
while 1:
|
while 1:
|
||||||
client = raw((await reader.read(1024)).decode("utf8"))
|
client = raw((await reader.read(1024)).decode("utf8"))
|
||||||
if client == f"END OF CLIENT LISTING FROM {sName}":
|
if client == f"END OF CLIENT LISTING FROM {sName}":
|
||||||
|
@ -249,19 +249,19 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
client.lower() in G.servers[sName]
|
client.lower() in G.servers[sName]
|
||||||
or client.lower() in G.clientsConnected
|
or client.lower() in G.clientsConnected
|
||||||
):
|
):
|
||||||
writer.write(b"K Client rejected: Already exists\n")
|
writer.write(b"K Client rejected: Already exists\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
continue
|
continue
|
||||||
writer.write(b"I added that client.\n")
|
writer.write(b"I added that client.\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
G.msgs.append(log(f"{client} has connected from {sName}"))
|
G.msgs.append(log(f"{client} has connected from {sName}"))
|
||||||
G.servers[sName][client.lower()] = False
|
G.servers[sName][client.lower()] = False
|
||||||
G.S2SLogs.append(("+", client, sName))
|
G.S2SLogs.append(("+", client, sName))
|
||||||
writer.write(f"{G.remoteID}\n".encode("utf8"))
|
writer.write(f"{G.remoteID}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
await reader.read(1024)
|
await reader.read(1024)
|
||||||
for client in G.clientsConnected:
|
for client in G.clientsConnected:
|
||||||
writer.write(f"{client}\n".encode("utf8"))
|
writer.write(f"{client}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
resp = raw((await reader.read(1024)).decode("utf8"))
|
resp = raw((await reader.read(1024)).decode("utf8"))
|
||||||
if resp.startswith("K"):
|
if resp.startswith("K"):
|
||||||
|
@ -269,7 +269,7 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
G.killList[client] = True
|
G.killList[client] = True
|
||||||
else:
|
else:
|
||||||
G.servers[G.clientsConnected[client]][client] = True
|
G.servers[G.clientsConnected[client]][client] = True
|
||||||
writer.write(f"END OF CLIENT LISTING FROM {G.remoteID}\n".encode("utf8"))
|
writer.write(f"END OF CLIENT LISTING FROM {G.remoteID}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
for client in G.servers[sName]:
|
for client in G.servers[sName]:
|
||||||
G.clientsConnected[client] = sName
|
G.clientsConnected[client] = sName
|
||||||
|
@ -281,7 +281,7 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
match buffer[0]:
|
match buffer[0]:
|
||||||
case "S": # Server notice
|
case "S": # Server notice
|
||||||
G.msgs.extend([log(buffer[2:])])
|
G.msgs.extend([log(buffer[2:])])
|
||||||
writer.write(b"I Mmm... Blueberries\n")
|
writer.write(b"I Mmm... Blueberries\r\n")
|
||||||
case "I":
|
case "I":
|
||||||
pass
|
pass
|
||||||
case "+":
|
case "+":
|
||||||
|
@ -293,9 +293,9 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
G.servers[sName][cName.lower()] = False
|
G.servers[sName][cName.lower()] = False
|
||||||
G.clientsConnected[cName.lower()] = sName
|
G.clientsConnected[cName.lower()] = sName
|
||||||
G.S2SLogs.append(("+", cName, sName))
|
G.S2SLogs.append(("+", cName, sName))
|
||||||
writer.write(b"I Mmm... Pineapples\n")
|
writer.write(b"I Mmm... Pineapples\r\n")
|
||||||
else:
|
else:
|
||||||
writer.write(f"K {cName}\n".encode("utf8"))
|
writer.write(f"K {cName}\r\n".encode("utf8"))
|
||||||
case "-":
|
case "-":
|
||||||
cName = buffer[2:]
|
cName = buffer[2:]
|
||||||
if G.clientsConnected.get(cName.lower(), None) == sName:
|
if G.clientsConnected.get(cName.lower(), None) == sName:
|
||||||
|
@ -305,10 +305,10 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
del G.servers[sName][cName.lower()]
|
del G.servers[sName][cName.lower()]
|
||||||
del G.clientsConnected[cName.lower()]
|
del G.clientsConnected[cName.lower()]
|
||||||
G.S2SLogs.append(("-", cName, sName))
|
G.S2SLogs.append(("-", cName, sName))
|
||||||
writer.write(b"I Mmm... Bananas\n")
|
writer.write(b"I Mmm... Bananas\r\n")
|
||||||
else:
|
else:
|
||||||
writer.write(
|
writer.write(
|
||||||
f"S Your server is LYING about who is connected to it. - {G.remoteID}, a fellow server\n".encode(
|
f"S Your server is LYING about who is connected to it. - {G.remoteID}, a fellow server\r\n".encode(
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -318,14 +318,14 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
G.msgs.append(log(f" {cName}: {message}"))
|
G.msgs.append(log(f" {cName}: {message}"))
|
||||||
G.S2SLogs.append(("M", (cName, message), sName))
|
G.S2SLogs.append(("M", (cName, message), sName))
|
||||||
writer.write(
|
writer.write(
|
||||||
b"I Get these damn heretic ghost clients out of my store so i can buy my cult candles in peace.\n"
|
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":
|
case "A":
|
||||||
cName = buffer[2:].split("|", 1)[0]
|
cName = buffer[2:].split("|", 1)[0]
|
||||||
message = buffer[2:].split("|", 1)[1]
|
message = buffer[2:].split("|", 1)[1]
|
||||||
G.msgs.append(log(f"* {cName} {message}"))
|
G.msgs.append(log(f"* {cName} {message}"))
|
||||||
G.S2SLogs.append(("A", (cName, message), sName))
|
G.S2SLogs.append(("A", (cName, message), sName))
|
||||||
writer.write(b"I Mmm... Strawberries\n")
|
writer.write(b"I Mmm... Strawberries\r\n")
|
||||||
case "Q":
|
case "Q":
|
||||||
break
|
break
|
||||||
case "K":
|
case "K":
|
||||||
|
@ -338,10 +338,10 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
G.servers[G.clientsConnected[cName.lower()]][
|
G.servers[G.clientsConnected[cName.lower()]][
|
||||||
cName.lower()
|
cName.lower()
|
||||||
] = True
|
] = True
|
||||||
writer.write(b"I Mmm... Blood\n")
|
writer.write(b"I Mmm... Blood\r\n")
|
||||||
case _:
|
case _:
|
||||||
writer.write(
|
writer.write(
|
||||||
f"S Your server is doing drugs over here, sending me bullshit messages man - {G.remoteID}, A fellow server\n".encode(
|
f"S Your server is doing drugs over here, sending me bullshit messages man - {G.remoteID}, A fellow server\r\n".encode(
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -355,7 +355,7 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
if any(G.servers[sName].values()):
|
if any(G.servers[sName].values()):
|
||||||
for name in G.servers[sName]:
|
for name in G.servers[sName]:
|
||||||
if G.servers[sName][name]:
|
if G.servers[sName][name]:
|
||||||
writer.write(f"K {name}\n".encode("utf8"))
|
writer.write(f"K {name}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
G.servers[sName][name] = False
|
G.servers[sName][name] = False
|
||||||
while msgInd < len(G.S2SLogs):
|
while msgInd < len(G.S2SLogs):
|
||||||
|
@ -365,14 +365,14 @@ Please note that this is not network level statistics.\n""".encode(
|
||||||
match type:
|
match type:
|
||||||
case "A":
|
case "A":
|
||||||
nick, msg = data
|
nick, msg = data
|
||||||
writer.write(f"A {nick}|{msg}\n".encode("utf8"))
|
writer.write(f"A {nick}|{msg}\r\n".encode("utf8"))
|
||||||
case "M":
|
case "M":
|
||||||
nick, msg = data
|
nick, msg = data
|
||||||
writer.write(f"M {nick}|{msg}\n".encode("utf8"))
|
writer.write(f"M {nick}|{msg}\r\n".encode("utf8"))
|
||||||
case "+":
|
case "+":
|
||||||
writer.write(f"+ {data}\n".encode("utf8"))
|
writer.write(f"+ {data}\r\n".encode("utf8"))
|
||||||
case "-":
|
case "-":
|
||||||
writer.write(f"- {data}\n".encode("utf8"))
|
writer.write(f"- {data}\r\n".encode("utf8"))
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
@ -411,11 +411,11 @@ async def connectServer(hostname: str, port: int):
|
||||||
try:
|
try:
|
||||||
reader, writer = await asyncio.open_connection(hostname, port)
|
reader, writer = await asyncio.open_connection(hostname, port)
|
||||||
await reader.read(1024)
|
await reader.read(1024)
|
||||||
writer.write(f"S2S-{G.remoteID}\n".encode("utf8"))
|
writer.write(f"S2S-{G.remoteID}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
await reader.read(1024)
|
await reader.read(1024)
|
||||||
for client in G.clientsConnected:
|
for client in G.clientsConnected:
|
||||||
writer.write(f"{client}\n".encode("utf8"))
|
writer.write(f"{client}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
resp = raw((await reader.read(1024)).decode("utf8"))
|
resp = raw((await reader.read(1024)).decode("utf8"))
|
||||||
if resp.startswith("K"):
|
if resp.startswith("K"):
|
||||||
|
@ -423,7 +423,7 @@ async def connectServer(hostname: str, port: int):
|
||||||
G.killList[client] = True
|
G.killList[client] = True
|
||||||
else:
|
else:
|
||||||
G.servers[G.clientsConnected[client]][client] = True
|
G.servers[G.clientsConnected[client]][client] = True
|
||||||
writer.write(f"END OF CLIENT LISTING FROM {G.remoteID}\n".encode("utf8"))
|
writer.write(f"END OF CLIENT LISTING FROM {G.remoteID}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
rID = raw((await reader.read(16)).decode("utf8"))
|
rID = raw((await reader.read(16)).decode("utf8"))
|
||||||
try:
|
try:
|
||||||
|
@ -440,7 +440,7 @@ async def connectServer(hostname: str, port: int):
|
||||||
return
|
return
|
||||||
G.msgs.append(log(f"{rID} has linked to the network"))
|
G.msgs.append(log(f"{rID} has linked to the network"))
|
||||||
G.servers[rID] = {}
|
G.servers[rID] = {}
|
||||||
writer.write(b"I recieved your remote ID, now awaiting client listing\n")
|
writer.write(b"I recieved your remote ID, now awaiting client listing\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
# recieve client list from the other server
|
# recieve client list from the other server
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -448,10 +448,10 @@ async def connectServer(hostname: str, port: int):
|
||||||
if client == f"END OF CLIENT LISTING FROM {rID}":
|
if client == f"END OF CLIENT LISTING FROM {rID}":
|
||||||
break
|
break
|
||||||
if client.lower() in G.servers[rID] or client.lower() in G.clientsConnected:
|
if client.lower() in G.servers[rID] or client.lower() in G.clientsConnected:
|
||||||
writer.write(b"K Client rejected: Already exists\n")
|
writer.write(b"K Client rejected: Already exists\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
continue
|
continue
|
||||||
writer.write(b"I added that client.\n")
|
writer.write(b"I added that client.\r\n")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
G.msgs.append(log(f"{client} has connected from {rID}"))
|
G.msgs.append(log(f"{client} has connected from {rID}"))
|
||||||
G.servers[rID][client.lower()] = False
|
G.servers[rID][client.lower()] = False
|
||||||
|
@ -466,7 +466,7 @@ async def connectServer(hostname: str, port: int):
|
||||||
match buffer[0]:
|
match buffer[0]:
|
||||||
case "S":
|
case "S":
|
||||||
G.msgs.extend([log(buffer[2:])])
|
G.msgs.extend([log(buffer[2:])])
|
||||||
writer.write(b"I Mmm... Blueberries\n")
|
writer.write(b"I Mmm... Blueberries\r\n")
|
||||||
case "I":
|
case "I":
|
||||||
pass
|
pass
|
||||||
case "+":
|
case "+":
|
||||||
|
@ -476,9 +476,9 @@ async def connectServer(hostname: str, port: int):
|
||||||
G.S2SLogs.append(("+", cName, rID))
|
G.S2SLogs.append(("+", cName, rID))
|
||||||
G.servers[rID][cName.lower()] = False
|
G.servers[rID][cName.lower()] = False
|
||||||
G.clientsConnected[cName.lower()] = rID
|
G.clientsConnected[cName.lower()] = rID
|
||||||
writer.write(b"I Mmm... Pineapples\n")
|
writer.write(b"I Mmm... Pineapples\r\n")
|
||||||
else:
|
else:
|
||||||
writer.write(f"K {cName}\n".encode("utf8"))
|
writer.write(f"K {cName}\r\n".encode("utf8"))
|
||||||
case "-":
|
case "-":
|
||||||
cName = buffer[2:]
|
cName = buffer[2:]
|
||||||
if G.clientsConnected.get(cName.lower(), None) == rID:
|
if G.clientsConnected.get(cName.lower(), None) == rID:
|
||||||
|
@ -490,7 +490,7 @@ async def connectServer(hostname: str, port: int):
|
||||||
G.S2SLogs.append(("-", cName, rID))
|
G.S2SLogs.append(("-", cName, rID))
|
||||||
else:
|
else:
|
||||||
writer.write(
|
writer.write(
|
||||||
f"S Your server is LYING about who is connected to it. - {G.remoteID}, a fellow server\n".encode(
|
f"S Your server is LYING about who is connected to it. - {G.remoteID}, a fellow server\r\n".encode(
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -500,14 +500,14 @@ async def connectServer(hostname: str, port: int):
|
||||||
G.msgs.append(log(f" {cName}: {message}"))
|
G.msgs.append(log(f" {cName}: {message}"))
|
||||||
G.S2SLogs.append(("M", (cName, message), rID))
|
G.S2SLogs.append(("M", (cName, message), rID))
|
||||||
writer.write(
|
writer.write(
|
||||||
b"I Get these damn heretic ghost clients out of my store so i can buy my cult candles in peace.\n"
|
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":
|
case "A":
|
||||||
cName = buffer[2:].split("|", 1)[0]
|
cName = buffer[2:].split("|", 1)[0]
|
||||||
message = buffer[2:].split("|", 1)[1]
|
message = buffer[2:].split("|", 1)[1]
|
||||||
G.S2SLogs.append(("A", (cName, message), rID))
|
G.S2SLogs.append(("A", (cName, message), rID))
|
||||||
G.msgs.append(log(f"* {cName} {message}"))
|
G.msgs.append(log(f"* {cName} {message}"))
|
||||||
writer.write(b"I Mmm... Strawberries\n")
|
writer.write(b"I Mmm... Strawberries\r\n")
|
||||||
case "Q":
|
case "Q":
|
||||||
break
|
break
|
||||||
case "K":
|
case "K":
|
||||||
|
@ -520,10 +520,10 @@ async def connectServer(hostname: str, port: int):
|
||||||
G.servers[G.clientsConnected[cName.lower()]][
|
G.servers[G.clientsConnected[cName.lower()]][
|
||||||
cName.lower()
|
cName.lower()
|
||||||
] = True
|
] = True
|
||||||
writer.write(b"I Mmm... Blood\n")
|
writer.write(b"I Mmm... Blood\r\n")
|
||||||
case _:
|
case _:
|
||||||
writer.write(
|
writer.write(
|
||||||
f"S Your server is doing drugs over here, sending me bullshit messages man - {G.remoteID}, A fellow server\n".encode(
|
f"S Your server is doing drugs over here, sending me bullshit messages man - {G.remoteID}, A fellow server\r\n".encode(
|
||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -537,7 +537,7 @@ async def connectServer(hostname: str, port: int):
|
||||||
if any(G.servers[rID].values()):
|
if any(G.servers[rID].values()):
|
||||||
for name in G.servers[rID]:
|
for name in G.servers[rID]:
|
||||||
if G.servers[rID][name]:
|
if G.servers[rID][name]:
|
||||||
writer.write(f"K {name}\n".encode("utf8"))
|
writer.write(f"K {name}\r\n".encode("utf8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
G.servers[rID][name] = False
|
G.servers[rID][name] = False
|
||||||
while msgInd < len(G.S2SLogs):
|
while msgInd < len(G.S2SLogs):
|
||||||
|
@ -546,14 +546,14 @@ async def connectServer(hostname: str, port: int):
|
||||||
match type:
|
match type:
|
||||||
case "A":
|
case "A":
|
||||||
nick, msg = data
|
nick, msg = data
|
||||||
writer.write(f"A {nick}|{msg}\n".encode("utf8"))
|
writer.write(f"A {nick}|{msg}\r\n".encode("utf8"))
|
||||||
case "M":
|
case "M":
|
||||||
nick, msg = data
|
nick, msg = data
|
||||||
writer.write(f"M {nick}|{msg}\n".encode("utf8"))
|
writer.write(f"M {nick}|{msg}\r\n".encode("utf8"))
|
||||||
case "+":
|
case "+":
|
||||||
writer.write(f"+ {data}\n".encode("utf8"))
|
writer.write(f"+ {data}\r\n".encode("utf8"))
|
||||||
case "-":
|
case "-":
|
||||||
writer.write(f"- {data}\n".encode("utf8"))
|
writer.write(f"- {data}\r\n".encode("utf8"))
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
@ -607,7 +607,7 @@ async def runServer(address: str, port: int):
|
||||||
G.msgs.append(log("Server crash", "FATAL")[1:])
|
G.msgs.append(log("Server crash", "FATAL")[1:])
|
||||||
log("Shutting down from Exception", "FATAL")
|
log("Shutting down from Exception", "FATAL")
|
||||||
Err = format_exc()
|
Err = format_exc()
|
||||||
for line in Err.split("\n"):
|
for line in Err.split("\r\n"):
|
||||||
log(line, "ERROR")
|
log(line, "ERROR")
|
||||||
finally:
|
finally:
|
||||||
if not crash:
|
if not crash:
|
||||||
|
@ -617,7 +617,7 @@ async def runServer(address: str, port: int):
|
||||||
# server.abort_clients()
|
# server.abort_clients()
|
||||||
if saveLogs:
|
if saveLogs:
|
||||||
with open("cache.py", "w") as cache:
|
with open("cache.py", "w") as cache:
|
||||||
cache.write(f"msgs = {G.msgs}\n")
|
cache.write(f"msgs = {G.msgs}\r\n")
|
||||||
log("Saved logs, exiting now.")
|
log("Saved logs, exiting now.")
|
||||||
else:
|
else:
|
||||||
log("Not saving logs, exiting now.")
|
log("Not saving logs, exiting now.")
|
||||||
|
|
Loading…
Reference in a new issue