mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-29 12:45:00 +08:00
Convert examples and example tests for new-style scripts
Remove the test that just loads all the example scripts for now - it's a very low-value test, and we need to think of something better.
This commit is contained in:
@@ -62,7 +62,7 @@ class ViewPigLatin(contentviews.View):
|
||||
pig_view = ViewPigLatin()
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
contentviews.add(pig_view)
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from mitmproxy import filt
|
||||
state = {}
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
if len(sys.argv) != 2:
|
||||
raise ValueError("Usage: -s 'filt.py FILTER'")
|
||||
state["filter"] = filt.parse(sys.argv[1])
|
||||
|
||||
@@ -6,7 +6,7 @@ from mitmproxy.flow import FlowWriter
|
||||
state = {}
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
if len(sys.argv) != 2:
|
||||
raise ValueError('Usage: -s "flowriter.py filename"')
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class Context(object):
|
||||
context = Context()
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
"""
|
||||
On start we create a HARLog instance. You will have to adapt this to
|
||||
suit your actual needs of HAR generation. As it will probably be
|
||||
|
||||
@@ -7,7 +7,7 @@ from mitmproxy.models import decoded
|
||||
iframe_url = None
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
if len(sys.argv) != 2:
|
||||
raise ValueError('Usage: -s "iframe_injector.py url"')
|
||||
global iframe_url
|
||||
|
||||
@@ -8,7 +8,7 @@ from mitmproxy.models import decoded
|
||||
state = {}
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
if len(sys.argv) != 3:
|
||||
raise ValueError('Usage: -s "modify_response_body.py old new"')
|
||||
# You may want to use Python's argparse for more sophisticated argument
|
||||
|
||||
@@ -16,7 +16,7 @@ def hello_world():
|
||||
|
||||
# Register the app using the magic domain "proxapp" on port 80. Requests to
|
||||
# this domain and port combination will now be routed to the WSGI app instance.
|
||||
def start():
|
||||
def configure(options):
|
||||
mitmproxy.ctx.master.apps.add(app, "proxapp", 80)
|
||||
|
||||
# SSL works too, but the magic domain needs to be resolvable from the mitmproxy machine due to mitmproxy's design.
|
||||
|
||||
@@ -4,11 +4,11 @@ import mitmproxy
|
||||
"""
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
"""
|
||||
Called once on script startup, before any other events.
|
||||
Called once on script startup before any other events, and whenever options changes.
|
||||
"""
|
||||
mitmproxy.ctx.log("start")
|
||||
mitmproxy.ctx.log("configure")
|
||||
|
||||
|
||||
def clientconnect(root_layer):
|
||||
|
||||
@@ -113,7 +113,7 @@ class TlsFeedback(TlsLayer):
|
||||
tls_strategy = None
|
||||
|
||||
|
||||
def start():
|
||||
def configure(options):
|
||||
global tls_strategy
|
||||
if len(sys.argv) == 2:
|
||||
tls_strategy = ProbabilisticStrategy(float(sys.argv[1]))
|
||||
|
||||
Reference in New Issue
Block a user