From 5a68d21e8c87e05f2ad0c18e6c7c505f5e9fc93d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 19 Oct 2016 15:08:35 +1300 Subject: Remove flow module entirely, move contents to top level mitmproxy.flow.io -> mitmproxy.io mitmproxy.flow.export -> mitmproxy.export --- examples/flowbasic | 5 ++--- examples/flowwriter.py | 5 ++--- examples/read_dumpfile | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/flowbasic b/examples/flowbasic index bac98916..cb1e4ea4 100755 --- a/examples/flowbasic +++ b/examples/flowbasic @@ -8,7 +8,7 @@ Note that request and response messages are not automatically replied to, so we need to implement handlers to do this. """ -from mitmproxy import flow, controller, options +from mitmproxy import controller, options, master from mitmproxy.proxy import ProxyServer, ProxyConfig @@ -37,7 +37,6 @@ class MyMaster(master.Master): opts = options.Options(cadir="~/.mitmproxy/") config = ProxyConfig(opts) -state = state.State() server = ProxyServer(config) -m = MyMaster(opts, server, state) +m = MyMaster(opts, server) m.run() diff --git a/examples/flowwriter.py b/examples/flowwriter.py index df2e5a40..afce85aa 100644 --- a/examples/flowwriter.py +++ b/examples/flowwriter.py @@ -1,7 +1,6 @@ import random import sys - -from mitmproxy.flow import FlowWriter +from mimtproxy import io class Writer: @@ -10,7 +9,7 @@ class Writer: f = sys.stdout else: f = open(path, "wb") - self.w = FlowWriter(f) + self.w = io.FlowWriter(f) def response(self, flow): if random.choice([True, False]): diff --git a/examples/read_dumpfile b/examples/read_dumpfile index b1001c3d..e0e9064a 100644 --- a/examples/read_dumpfile +++ b/examples/read_dumpfile @@ -9,7 +9,7 @@ import pprint import sys with open(sys.argv[1], "rb") as logfile: - freader = flow.FlowReader(logfile) + freader = io.FlowReader(logfile) pp = pprint.PrettyPrinter(indent=4) try: for f in freader.stream(): -- cgit v1.2.3 From 24cf8da27eb56a65bf3e4ceb78bbeacdb1864597 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 19 Oct 2016 15:25:39 +1300 Subject: Move all tools into mitmproxy.tools, move models/* to top level The primary motivation here (and for all the other moving around) is to present a clean "front of house" to library users, and to migrate primary objects to the top of the module hierarchy. --- examples/flowwriter.py | 2 +- examples/redirect_requests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/flowwriter.py b/examples/flowwriter.py index afce85aa..a9768542 100644 --- a/examples/flowwriter.py +++ b/examples/flowwriter.py @@ -1,6 +1,6 @@ import random import sys -from mimtproxy import io +from mitmproxy import io class Writer: diff --git a/examples/redirect_requests.py b/examples/redirect_requests.py index bbb84e2f..c28042db 100644 --- a/examples/redirect_requests.py +++ b/examples/redirect_requests.py @@ -1,7 +1,7 @@ """ This example shows two ways to redirect flows to other destinations. """ -from mitmproxy.models import HTTPResponse +from mitmproxy import http def request(flow): @@ -11,7 +11,7 @@ def request(flow): # Method 1: Answer with a locally generated response if flow.request.pretty_host.endswith("example.com"): - flow.response = HTTPResponse.make(200, b"Hello World", {"Content-Type": "text/html"}) + flow.response = http.HTTPResponse.make(200, b"Hello World", {"Content-Type": "text/html"}) # Method 2: Redirect the request to a different server if flow.request.pretty_host.endswith("example.org"): -- cgit v1.2.3