mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
commit
c4c9527fa0
@ -6,7 +6,8 @@ import threading
|
|||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
from netlib import basethread
|
from netlib import basethread
|
||||||
from mitmproxy import exceptions
|
|
||||||
|
from . import exceptions
|
||||||
|
|
||||||
|
|
||||||
Events = frozenset([
|
Events = frozenset([
|
||||||
@ -76,9 +77,9 @@ class Master(object):
|
|||||||
if mtype not in Events:
|
if mtype not in Events:
|
||||||
raise exceptions.ControlException("Unknown event %s" % repr(mtype))
|
raise exceptions.ControlException("Unknown event %s" % repr(mtype))
|
||||||
handle_func = getattr(self, mtype)
|
handle_func = getattr(self, mtype)
|
||||||
if not hasattr(handle_func, "func_dict"):
|
if not hasattr(handle_func, "__dict__"):
|
||||||
raise exceptions.ControlException("Handler %s not a function" % mtype)
|
raise exceptions.ControlException("Handler %s not a function" % mtype)
|
||||||
if not handle_func.func_dict.get("__handler"):
|
if not handle_func.__dict__.get("__handler"):
|
||||||
raise exceptions.ControlException(
|
raise exceptions.ControlException(
|
||||||
"Handler function %s is not decorated with controller.handler" % (
|
"Handler function %s is not decorated with controller.handler" % (
|
||||||
handle_func
|
handle_func
|
||||||
@ -177,7 +178,7 @@ def handler(f):
|
|||||||
message.reply.ack()
|
message.reply.ack()
|
||||||
return ret
|
return ret
|
||||||
# Mark this function as a handler wrapper
|
# Mark this function as a handler wrapper
|
||||||
wrapper.func_dict["__handler"] = True
|
wrapper.__dict__["__handler"] = True
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import pf
|
from . import pf
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Doing this the "right" way by using DIOCNATLOOK on the pf device turns out
|
Doing this the "right" way by using DIOCNATLOOK on the pf device turns out
|
||||||
|
@ -130,7 +130,7 @@ def _rdumpq(q, size, value, encoding=None):
|
|||||||
if value is False:
|
if value is False:
|
||||||
write("5:false!")
|
write("5:false!")
|
||||||
return size + 8
|
return size + 8
|
||||||
if isinstance(value, (int, long)):
|
if isinstance(value, six.integer_types):
|
||||||
data = str(value)
|
data = str(value)
|
||||||
ldata = len(data)
|
ldata = len(data)
|
||||||
span = str(ldata)
|
span = str(ldata)
|
||||||
@ -208,7 +208,7 @@ def _gdumps(value, encoding):
|
|||||||
yield "4:true!"
|
yield "4:true!"
|
||||||
elif value is False:
|
elif value is False:
|
||||||
yield "5:false!"
|
yield "5:false!"
|
||||||
elif isinstance(value, (int, long)):
|
elif isinstance(value, six.integer_types):
|
||||||
data = str(value)
|
data = str(value)
|
||||||
yield str(len(data))
|
yield str(len(data))
|
||||||
yield ":"
|
yield ":"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import tutils
|
|
||||||
import netlib.tutils
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from . import tutils
|
||||||
|
import netlib.tutils
|
||||||
|
|
||||||
from mitmproxy import flow, proxy, models
|
from mitmproxy import flow, proxy, models
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,16 +138,16 @@ class TestContentView:
|
|||||||
def test_view_image(self):
|
def test_view_image(self):
|
||||||
v = cv.ViewImage()
|
v = cv.ViewImage()
|
||||||
p = tutils.test_data.path("data/image.png")
|
p = tutils.test_data.path("data/image.png")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
p = tutils.test_data.path("data/image.gif")
|
p = tutils.test_data.path("data/image.gif")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
p = tutils.test_data.path("data/image-err1.jpg")
|
p = tutils.test_data.path("data/image-err1.jpg")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
p = tutils.test_data.path("data/image.ico")
|
p = tutils.test_data.path("data/image.ico")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
assert not v("flibble")
|
assert not v("flibble")
|
||||||
|
|
||||||
@ -252,22 +252,22 @@ if pyamf:
|
|||||||
v = cv.ViewAMF()
|
v = cv.ViewAMF()
|
||||||
|
|
||||||
p = tutils.test_data.path("data/amf01")
|
p = tutils.test_data.path("data/amf01")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
p = tutils.test_data.path("data/amf02")
|
p = tutils.test_data.path("data/amf02")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
def test_view_amf_response():
|
def test_view_amf_response():
|
||||||
v = cv.ViewAMF()
|
v = cv.ViewAMF()
|
||||||
p = tutils.test_data.path("data/amf03")
|
p = tutils.test_data.path("data/amf03")
|
||||||
assert v(file(p, "rb").read())
|
assert v(open(p, "rb").read())
|
||||||
|
|
||||||
if cv.ViewProtobuf.is_available():
|
if cv.ViewProtobuf.is_available():
|
||||||
def test_view_protobuf_request():
|
def test_view_protobuf_request():
|
||||||
v = cv.ViewProtobuf()
|
v = cv.ViewProtobuf()
|
||||||
|
|
||||||
p = tutils.test_data.path("data/protobuf01")
|
p = tutils.test_data.path("data/protobuf01")
|
||||||
content_type, output = v(file(p, "rb").read())
|
content_type, output = v(open(p, "rb").read())
|
||||||
assert content_type == "Protobuf"
|
assert content_type == "Protobuf"
|
||||||
assert output.next()[0][1] == '1: "3bbc333c-e61c-433b-819a-0b9a8cc103b8"'
|
assert output.next()[0][1] == '1: "3bbc333c-e61c-433b-819a-0b9a8cc103b8"'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user