mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-24 04:14:57 +08:00
Py3: websockets
This commit is contained in:
committed by
Thomas Kriechbaumer
parent
0f1aa2b78e
commit
d9b940c21e
@@ -20,7 +20,7 @@ import os
|
||||
|
||||
import six
|
||||
|
||||
from netlib import http
|
||||
from netlib import http, strutils
|
||||
|
||||
websockets_magic = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
|
||||
VERSION = "13"
|
||||
@@ -109,4 +109,4 @@ class WebsocketsProtocol(object):
|
||||
|
||||
@classmethod
|
||||
def create_server_nonce(self, client_nonce):
|
||||
return base64.b64encode(hashlib.sha1(client_nonce + websockets_magic).digest())
|
||||
return base64.b64encode(hashlib.sha1(strutils.always_bytes(client_nonce) + websockets_magic).digest())
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import random
|
||||
import string
|
||||
import netlib.websockets
|
||||
from netlib import strutils
|
||||
import pyparsing as pp
|
||||
from . import base, generators, actions, message
|
||||
|
||||
NESTED_LEADER = "pathod!"
|
||||
NESTED_LEADER = b"pathod!"
|
||||
|
||||
|
||||
class WF(base.CaselessLiteral):
|
||||
@@ -193,7 +194,7 @@ class WebsocketFrame(message.Message):
|
||||
bodygen = self.rawbody.value.get_generator(settings)
|
||||
length = len(self.rawbody.value.get_generator(settings))
|
||||
elif self.nested_frame:
|
||||
bodygen = NESTED_LEADER + self.nested_frame.parsed.spec()
|
||||
bodygen = NESTED_LEADER + strutils.always_bytes(self.nested_frame.parsed.spec())
|
||||
length = len(bodygen)
|
||||
else:
|
||||
bodygen = None
|
||||
|
||||
@@ -37,7 +37,7 @@ class WebsocketsProtocol:
|
||||
if frm.payload.startswith(ld):
|
||||
nest = frm.payload[len(ld):]
|
||||
try:
|
||||
wf_gen = language.parse_websocket_frame(nest)
|
||||
wf_gen = language.parse_websocket_frame(nest.decode())
|
||||
except language.exceptions.ParseException as v:
|
||||
logger.write(
|
||||
"Parse error in reflected frame specifcation:"
|
||||
|
||||
Reference in New Issue
Block a user