Websocket update.
This commit is contained in:
parent
41e12d304e
commit
851d1de1be
@ -87,8 +87,7 @@ class AOProtocol(asyncio.Protocol):
|
||||
self.client.disconnect()
|
||||
for msg in self.get_messages():
|
||||
if len(msg) < 2:
|
||||
self.client.disconnect()
|
||||
return
|
||||
continue
|
||||
# general netcode structure is not great
|
||||
if msg[0] in ('#', '3', '4'):
|
||||
if msg[0] == '#':
|
||||
@ -100,7 +99,7 @@ class AOProtocol(asyncio.Protocol):
|
||||
cmd, *args = msg.split('#')
|
||||
self.net_cmd_dispatcher[cmd](self, args)
|
||||
except KeyError:
|
||||
return
|
||||
logger.log_debug('[INC][UNK]{}'.format(msg), self.client)
|
||||
|
||||
def connection_made(self, transport):
|
||||
""" Called upon a new client connecting
|
||||
|
@ -109,14 +109,17 @@ class WebSocket:
|
||||
self.keep_alive = 0
|
||||
return
|
||||
|
||||
mask_offset = 2
|
||||
if payload_length == 126:
|
||||
payload_length = struct.unpack(">H", data[2:4])[0]
|
||||
mask_offset = 4
|
||||
elif payload_length == 127:
|
||||
payload_length = struct.unpack(">Q", data[2:10])[0]
|
||||
mask_offset = 10
|
||||
|
||||
masks = data[2:6]
|
||||
masks = data[mask_offset:mask_offset + 4]
|
||||
decoded = ""
|
||||
for char in data[6:payload_length + 6]:
|
||||
for char in data[mask_offset + 4:payload_length + mask_offset + 4]:
|
||||
char ^= masks[len(decoded) % 4]
|
||||
decoded += chr(char)
|
||||
|
||||
@ -209,4 +212,4 @@ class WebSocket:
|
||||
return response_key.decode('ASCII')
|
||||
|
||||
def finish(self):
|
||||
self.protocol.connection_lost(self)
|
||||
self.protocol.connection_lost(self)
|
||||
|
Loading…
Reference in New Issue
Block a user