aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-07-14 16:20:27 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-07-14 19:54:15 +1200
commitb94f5fd361af6255ad4d3c7a88b9a21868736dea (patch)
tree5237bbd32c84d284a5c4b2478a9034f11d39a850 /examples
parenta6821aad8e9296640c3efd4275e8922dd7c6e43b (diff)
downloadmitmproxy-b94f5fd361af6255ad4d3c7a88b9a21868736dea.tar.gz
mitmproxy-b94f5fd361af6255ad4d3c7a88b9a21868736dea.tar.bz2
mitmproxy-b94f5fd361af6255ad4d3c7a88b9a21868736dea.zip
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.
Diffstat (limited to 'examples')
-rw-r--r--examples/custom_contentviews.py2
-rw-r--r--examples/filt.py2
-rw-r--r--examples/flowwriter.py2
-rw-r--r--examples/har_extractor.py2
-rw-r--r--examples/iframe_injector.py2
-rw-r--r--examples/modify_response_body.py2
-rw-r--r--examples/proxapp.py2
-rw-r--r--examples/stub.py6
-rw-r--r--examples/tls_passthrough.py2
9 files changed, 11 insertions, 11 deletions
diff --git a/examples/custom_contentviews.py b/examples/custom_contentviews.py
index 5a63e2a0..b10d936f 100644
--- a/examples/custom_contentviews.py
+++ b/examples/custom_contentviews.py
@@ -62,7 +62,7 @@ class ViewPigLatin(contentviews.View):
pig_view = ViewPigLatin()
-def start():
+def configure(options):
contentviews.add(pig_view)
diff --git a/examples/filt.py b/examples/filt.py
index 21744edd..102d1274 100644
--- a/examples/filt.py
+++ b/examples/filt.py
@@ -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])
diff --git a/examples/flowwriter.py b/examples/flowwriter.py
index 07c7ca20..d8fbc1f4 100644
--- a/examples/flowwriter.py
+++ b/examples/flowwriter.py
@@ -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"')
diff --git a/examples/har_extractor.py b/examples/har_extractor.py
index 2a69b9af..23deb43a 100644
--- a/examples/har_extractor.py
+++ b/examples/har_extractor.py
@@ -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
diff --git a/examples/iframe_injector.py b/examples/iframe_injector.py
index 70247d31..40934dd3 100644
--- a/examples/iframe_injector.py
+++ b/examples/iframe_injector.py
@@ -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
diff --git a/examples/modify_response_body.py b/examples/modify_response_body.py
index 23ad0151..8b6908a4 100644
--- a/examples/modify_response_body.py
+++ b/examples/modify_response_body.py
@@ -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
diff --git a/examples/proxapp.py b/examples/proxapp.py
index 2935b587..095f412a 100644
--- a/examples/proxapp.py
+++ b/examples/proxapp.py
@@ -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.
diff --git a/examples/stub.py b/examples/stub.py
index 10b34283..614acee2 100644
--- a/examples/stub.py
+++ b/examples/stub.py
@@ -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):
diff --git a/examples/tls_passthrough.py b/examples/tls_passthrough.py
index 20e8f9be..306f55f6 100644
--- a/examples/tls_passthrough.py
+++ b/examples/tls_passthrough.py
@@ -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]))