Fix client mask generation

random.randrange() gives integers, which need to be explicitly converted
to bytes.
This commit is contained in:
Pierre Ossman 2024-05-20 10:01:18 +02:00
parent bccf1dd258
commit a2362da1b7
1 changed files with 1 additions and 1 deletions

View File

@ -731,7 +731,7 @@ class WebSocket(object):
if self.client: if self.client:
mask = b'' mask = b''
for i in range(4): for i in range(4):
mask += random.randrange(256) mask += random.randrange(256).to_bytes()
frame = self._encode_hybi(opcode, msg, mask) frame = self._encode_hybi(opcode, msg, mask)
else: else:
frame = self._encode_hybi(opcode, msg) frame = self._encode_hybi(opcode, msg)