Send back unknown packets to client as text message

This commit is contained in:
Amazed 2019-02-06 14:09:17 +01:00
parent 30aa2a81c7
commit 92ebbdf64c
2 changed files with 6 additions and 3 deletions

View File

@ -210,7 +210,7 @@ class Netserver(asyncio.DatagramProtocol):
sack_sent = True
if not session.next_send == cframe.NRecv:
logger.error("Received CFRAME (%s) does not have same NRcv (%s). One sent packet might have been lost.", cframe.NRecv, session.CFRAME_NRcv)
logger.error("Received CFRAME (%s) does not have same NRcv (%s). One sent packet might have been lost.", cframe.NRecv, session.next_send)
if not sack_sent:
session.send_cframe_sack()
sack_sent = True
@ -227,7 +227,7 @@ class Netserver(asyncio.DatagramProtocol):
return
#logger.debug("Got a CFrame POLL. Replying with a SACK.")
# must send back a ACK
#session.send_cframe_sack()
session.send_cframe_sack()
except Exception:
logger.error("Should have been a CFRAME but could not parse it")
traceback.print_exc()
@ -380,7 +380,8 @@ class Netserver(asyncio.DatagramProtocol):
player.session.send_gamedata(b'\x2f\x02\x00\x00\xc2\x00\x00\x00\x00\x00\x00\x00\x00\x00', acknow=True) # unknown
"""
else:
logger.debug("OPCODE: %s VALUES: %s", payload[0], payload[1:])
logger.debug("OPCODE: %s VALUES: %s", struct.pack("<B", payload[0]).hex(), payload[1:].hex())
await self.server.broadcast_message("SENT OPCODE: %s VALUES: %s" % (struct.pack("<B", payload[0]).hex(), payload[1:].hex()))
def send_packet(self, addr, packet):

View File

@ -99,6 +99,8 @@ class Server:
async def broadcast_message(self, text):
for player in self.players:
if player.name == "[Server]":
continue
await player.session.send_gamedata(b'\x35\x80\x81'+text.encode("ascii")+b'\x00\x00')
if __name__ == '__main__':