diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-10-19 15:03:50 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 15:03:50 +1300 |
commit | 49346c5248b8aa33acef26f0d55f51dcd2493a59 (patch) | |
tree | e92c9ac66a83fed5cf964691e5b0e81b90fc1eea | |
parent | 83dbefb224c0b0d77b226f80e37b5b3d6bebb703 (diff) | |
parent | 7c32d4ea2a435484e83aa459831f74ca483d8e3c (diff) | |
download | mitmproxy-49346c5248b8aa33acef26f0d55f51dcd2493a59.tar.gz mitmproxy-49346c5248b8aa33acef26f0d55f51dcd2493a59.tar.bz2 mitmproxy-49346c5248b8aa33acef26f0d55f51dcd2493a59.zip |
Merge pull request #1632 from cortesi/refactor
Start rationalising our module structure bit by bit
-rw-r--r-- | docs/scripting/api.rst | 8 | ||||
-rw-r--r-- | docs/scripting/overview.rst | 2 | ||||
-rwxr-xr-x | examples/flowbasic | 2 | ||||
-rw-r--r-- | examples/proxapp.py | 2 | ||||
-rw-r--r-- | mitmproxy/addonmanager.py (renamed from mitmproxy/addons.py) | 2 | ||||
-rw-r--r-- | mitmproxy/addons/__init__.py | 29 | ||||
-rw-r--r-- | mitmproxy/addons/anticache.py (renamed from mitmproxy/builtins/anticache.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/anticomp.py (renamed from mitmproxy/builtins/anticomp.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/clientplayback.py (renamed from mitmproxy/builtins/clientplayback.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/dumper.py (renamed from mitmproxy/builtins/dumper.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/filestreamer.py (renamed from mitmproxy/builtins/filestreamer.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboarding.py (renamed from mitmproxy/builtins/onboarding.py) | 4 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/__init__.py (renamed from mitmproxy/builtins/onboardingapp/__init__.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/app.py (renamed from mitmproxy/builtins/onboardingapp/app.py) | 6 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/bootstrap.min.css (renamed from mitmproxy/builtins/onboardingapp/static/bootstrap.min.css) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.css (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.css) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.min.css (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.min.css) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/fonts/FontAwesome.otf (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/FontAwesome.otf) | bin | 62856 -> 62856 bytes | |||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot) | bin | 38205 -> 38205 bytes | |||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf) | bin | 80652 -> 80652 bytes | |||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff (renamed from mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff) | bin | 44432 -> 44432 bytes | |||
-rw-r--r-- | mitmproxy/addons/onboardingapp/static/mitmproxy.css (renamed from mitmproxy/builtins/onboardingapp/static/mitmproxy.css) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/templates/frame.html (renamed from mitmproxy/builtins/onboardingapp/templates/frame.html) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/templates/index.html (renamed from mitmproxy/builtins/onboardingapp/templates/index.html) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/onboardingapp/templates/layout.html (renamed from mitmproxy/builtins/onboardingapp/templates/layout.html) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/replace.py (renamed from mitmproxy/builtins/replace.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/script.py (renamed from mitmproxy/builtins/script.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/serverplayback.py (renamed from mitmproxy/builtins/serverplayback.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/setheaders.py (renamed from mitmproxy/builtins/setheaders.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/state.py (renamed from mitmproxy/flow/state.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/stickyauth.py (renamed from mitmproxy/builtins/stickyauth.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/stickycookie.py (renamed from mitmproxy/builtins/stickycookie.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/streambodies.py (renamed from mitmproxy/builtins/streambodies.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/termlog.py (renamed from mitmproxy/builtins/termlog.py) | 0 | ||||
-rw-r--r-- | mitmproxy/addons/wsgiapp.py (renamed from mitmproxy/builtins/wsgiapp.py) | 2 | ||||
-rw-r--r-- | mitmproxy/builtins/__init__.py | 29 | ||||
-rw-r--r-- | mitmproxy/builtins/onboarding/app.py | 93 | ||||
-rw-r--r-- | mitmproxy/console/grideditor/editors.py | 2 | ||||
-rw-r--r-- | mitmproxy/console/master.py | 9 | ||||
-rw-r--r-- | mitmproxy/controller.py | 41 | ||||
-rw-r--r-- | mitmproxy/dump.py | 6 | ||||
-rw-r--r-- | mitmproxy/flow/__init__.py | 2 | ||||
-rw-r--r-- | mitmproxy/log.py | 40 | ||||
-rw-r--r-- | mitmproxy/master.py | 9 | ||||
-rw-r--r-- | mitmproxy/proxy/root_context.py | 4 | ||||
-rw-r--r-- | mitmproxy/proxy/server.py | 4 | ||||
-rw-r--r-- | mitmproxy/web/master.py | 10 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/__init__.py (renamed from test/mitmproxy/builtins/__init__.py) | 0 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_anticache.py (renamed from test/mitmproxy/builtins/test_anticache.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_anticomp.py (renamed from test/mitmproxy/builtins/test_anticomp.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_clientplayback.py (renamed from test/mitmproxy/builtins/test_clientplayback.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py (renamed from test/mitmproxy/builtins/test_dumper.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_filestreamer.py (renamed from test/mitmproxy/builtins/test_filestreamer.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_onboarding.py (renamed from test/mitmproxy/builtins/test_onboarding.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_replace.py (renamed from test/mitmproxy/builtins/test_replace.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_script.py (renamed from test/mitmproxy/builtins/test_script.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_serverplayback.py (renamed from test/mitmproxy/builtins/test_serverplayback.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_setheaders.py (renamed from test/mitmproxy/builtins/test_setheaders.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_state.py (renamed from test/mitmproxy/test_flow_state.py) | 7 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_stickyauth.py (renamed from test/mitmproxy/builtins/test_stickyauth.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_stickycookie.py (renamed from test/mitmproxy/builtins/test_stickycookie.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_streambodies.py (renamed from test/mitmproxy/builtins/test_streambodies.py) | 2 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_termlog.py (renamed from test/mitmproxy/builtins/test_termlog.py) | 8 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_wsgiapp.py (renamed from test/mitmproxy/builtins/test_wsgiapp.py) | 10 | ||||
-rw-r--r-- | test/mitmproxy/script/test_concurrent.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_addonmanager.py (renamed from test/mitmproxy/test_addons.py) | 4 | ||||
-rw-r--r-- | test/mitmproxy/test_examples.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 27 | ||||
-rw-r--r-- | test/mitmproxy/test_server.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/tools/benchtool.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/tservers.py | 2 | ||||
-rw-r--r-- | test/netlib/http/test_request.py | 2 | ||||
-rw-r--r-- | test/netlib/http/test_response.py | 2 |
75 files changed, 157 insertions, 247 deletions
diff --git a/docs/scripting/api.rst b/docs/scripting/api.rst index abc9ff3e..59ef8d95 100644 --- a/docs/scripting/api.rst +++ b/docs/scripting/api.rst @@ -11,8 +11,8 @@ API - `mitmproxy.models.http.HTTPResponse <#mitmproxy.models.http.HTTPResponse>`_ - `mitmproxy.models.http.HTTPFlow <#mitmproxy.models.http.HTTPFlow>`_ - Logging - - `mitmproxy.controller.Log <#mitmproxy.controller.Log>`_ - - `mitmproxy.controller.LogEntry <#mitmproxy.controller.LogEntry>`_ + - `mitmproxy.log.Log <#mitmproxy.controller.Log>`_ + - `mitmproxy.log.LogEntry <#mitmproxy.controller.LogEntry>`_ Errors @@ -36,5 +36,7 @@ HTTP Logging -------- -.. autoclass:: mitmproxy.controller.Log +.. autoclass:: mitmproxy.log.Log + :inherited-members: +.. autoclass:: mitmproxy.log.LogEntry :inherited-members: diff --git a/docs/scripting/overview.rst b/docs/scripting/overview.rst index 5966eb1d..b820538e 100644 --- a/docs/scripting/overview.rst +++ b/docs/scripting/overview.rst @@ -6,7 +6,7 @@ Overview Mitmproxy has a powerful scripting API that allows you to control almost any aspect of traffic being proxied. In fact, much of mitmproxy's own core functionality is implemented using the exact same API exposed to scripters (see -:src:`mitmproxy/builtins`). +:src:`mitmproxy/addons`). A simple example diff --git a/examples/flowbasic b/examples/flowbasic index 0eb163a4..bac98916 100755 --- a/examples/flowbasic +++ b/examples/flowbasic @@ -37,7 +37,7 @@ class MyMaster(master.Master): opts = options.Options(cadir="~/.mitmproxy/") config = ProxyConfig(opts) -state = flow.State() +state = state.State() server = ProxyServer(config) m = MyMaster(opts, server, state) m.run() diff --git a/examples/proxapp.py b/examples/proxapp.py index b4fa8d3d..f95c41e5 100644 --- a/examples/proxapp.py +++ b/examples/proxapp.py @@ -4,7 +4,7 @@ instance, we're using the Flask framework (http://flask.pocoo.org/) to expose a single simplest-possible page. """ from flask import Flask -from mitmproxy.builtins import wsgiapp +from mitmproxy.addons import wsgiapp app = Flask("proxapp") diff --git a/mitmproxy/addons.py b/mitmproxy/addonmanager.py index 34ca8e55..db8e0cd7 100644 --- a/mitmproxy/addons.py +++ b/mitmproxy/addonmanager.py @@ -6,7 +6,7 @@ def _get_name(itm): return getattr(itm, "name", itm.__class__.__name__.lower()) -class Addons: +class AddonManager: def __init__(self, master): self.chain = [] self.master = master diff --git a/mitmproxy/addons/__init__.py b/mitmproxy/addons/__init__.py new file mode 100644 index 00000000..c5d40525 --- /dev/null +++ b/mitmproxy/addons/__init__.py @@ -0,0 +1,29 @@ +from mitmproxy.addons import anticache +from mitmproxy.addons import anticomp +from mitmproxy.addons import clientplayback +from mitmproxy.addons import filestreamer +from mitmproxy.addons import onboarding +from mitmproxy.addons import replace +from mitmproxy.addons import script +from mitmproxy.addons import setheaders +from mitmproxy.addons import serverplayback +from mitmproxy.addons import stickyauth +from mitmproxy.addons import stickycookie +from mitmproxy.addons import streambodies + + +def default_addons(): + return [ + onboarding.Onboarding(), + anticache.AntiCache(), + anticomp.AntiComp(), + stickyauth.StickyAuth(), + stickycookie.StickyCookie(), + script.ScriptLoader(), + filestreamer.FileStreamer(), + streambodies.StreamBodies(), + replace.Replace(), + setheaders.SetHeaders(), + serverplayback.ServerPlayback(), + clientplayback.ClientPlayback(), + ] diff --git a/mitmproxy/builtins/anticache.py b/mitmproxy/addons/anticache.py index 8d748a21..8d748a21 100644 --- a/mitmproxy/builtins/anticache.py +++ b/mitmproxy/addons/anticache.py diff --git a/mitmproxy/builtins/anticomp.py b/mitmproxy/addons/anticomp.py index eaf01296..eaf01296 100644 --- a/mitmproxy/builtins/anticomp.py +++ b/mitmproxy/addons/anticomp.py diff --git a/mitmproxy/builtins/clientplayback.py b/mitmproxy/addons/clientplayback.py index 75ef2ffd..75ef2ffd 100644 --- a/mitmproxy/builtins/clientplayback.py +++ b/mitmproxy/addons/clientplayback.py diff --git a/mitmproxy/builtins/dumper.py b/mitmproxy/addons/dumper.py index 04dfb42c..04dfb42c 100644 --- a/mitmproxy/builtins/dumper.py +++ b/mitmproxy/addons/dumper.py diff --git a/mitmproxy/builtins/filestreamer.py b/mitmproxy/addons/filestreamer.py index b1643b21..b1643b21 100644 --- a/mitmproxy/builtins/filestreamer.py +++ b/mitmproxy/addons/filestreamer.py diff --git a/mitmproxy/builtins/onboarding.py b/mitmproxy/addons/onboarding.py index 95844010..4b952438 100644 --- a/mitmproxy/builtins/onboarding.py +++ b/mitmproxy/addons/onboarding.py @@ -1,5 +1,5 @@ -from mitmproxy.builtins import wsgiapp -from mitmproxy.builtins.onboardingapp import app +from mitmproxy.addons import wsgiapp +from mitmproxy.addons.onboardingapp import app class Onboarding(wsgiapp.WSGIApp): diff --git a/mitmproxy/builtins/onboardingapp/__init__.py b/mitmproxy/addons/onboardingapp/__init__.py index e69de29b..e69de29b 100644 --- a/mitmproxy/builtins/onboardingapp/__init__.py +++ b/mitmproxy/addons/onboardingapp/__init__.py diff --git a/mitmproxy/builtins/onboardingapp/app.py b/mitmproxy/addons/onboardingapp/app.py index 6a65d142..9e07b75f 100644 --- a/mitmproxy/builtins/onboardingapp/app.py +++ b/mitmproxy/addons/onboardingapp/app.py @@ -6,9 +6,9 @@ import tornado.wsgi from mitmproxy import utils from mitmproxy.proxy import config -from mitmproxy.builtins import wsgiapp +from mitmproxy.addons import wsgiapp -loader = tornado.template.Loader(utils.pkg_data.path("builtins/onboardingapp/templates")) +loader = tornado.template.Loader(utils.pkg_data.path("addons/onboardingapp/templates")) class Adapter(tornado.wsgi.WSGIAdapter): @@ -86,7 +86,7 @@ application = tornado.web.Application( r"/static/(.*)", tornado.web.StaticFileHandler, { - "path": utils.pkg_data.path("builtins/onboardingapp/static") + "path": utils.pkg_data.path("addons/onboardingapp/static") } ), ], diff --git a/mitmproxy/builtins/onboardingapp/static/bootstrap.min.css b/mitmproxy/addons/onboardingapp/static/bootstrap.min.css index f31489f9..f31489f9 100644 --- a/mitmproxy/builtins/onboardingapp/static/bootstrap.min.css +++ b/mitmproxy/addons/onboardingapp/static/bootstrap.min.css diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.css b/mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.css index 048cff97..048cff97 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.css +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.css diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.min.css b/mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.min.css index 449d6ac5..449d6ac5 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/css/font-awesome.min.css +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/css/font-awesome.min.css diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/FontAwesome.otf b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/FontAwesome.otf Binary files differindex 8b0f54e4..8b0f54e4 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/FontAwesome.otf +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/FontAwesome.otf diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot Binary files differindex 7c79c6a6..7c79c6a6 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.eot diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg index 45fdf338..45fdf338 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.svg diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf Binary files differindex e89738de..e89738de 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.ttf diff --git a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff Binary files differindex 8c1748aa..8c1748aa 100644 --- a/mitmproxy/builtins/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff +++ b/mitmproxy/addons/onboardingapp/static/fontawesome/fonts/fontawesome-webfont.woff diff --git a/mitmproxy/builtins/onboardingapp/static/mitmproxy.css b/mitmproxy/addons/onboardingapp/static/mitmproxy.css index b390976a..b390976a 100644 --- a/mitmproxy/builtins/onboardingapp/static/mitmproxy.css +++ b/mitmproxy/addons/onboardingapp/static/mitmproxy.css diff --git a/mitmproxy/builtins/onboardingapp/templates/frame.html b/mitmproxy/addons/onboardingapp/templates/frame.html index f00e1a66..f00e1a66 100644 --- a/mitmproxy/builtins/onboardingapp/templates/frame.html +++ b/mitmproxy/addons/onboardingapp/templates/frame.html diff --git a/mitmproxy/builtins/onboardingapp/templates/index.html b/mitmproxy/addons/onboardingapp/templates/index.html index 1bcff1b8..1bcff1b8 100644 --- a/mitmproxy/builtins/onboardingapp/templates/index.html +++ b/mitmproxy/addons/onboardingapp/templates/index.html diff --git a/mitmproxy/builtins/onboardingapp/templates/layout.html b/mitmproxy/addons/onboardingapp/templates/layout.html index 8726a788..8726a788 100644 --- a/mitmproxy/builtins/onboardingapp/templates/layout.html +++ b/mitmproxy/addons/onboardingapp/templates/layout.html diff --git a/mitmproxy/builtins/replace.py b/mitmproxy/addons/replace.py index b675b779..b675b779 100644 --- a/mitmproxy/builtins/replace.py +++ b/mitmproxy/addons/replace.py diff --git a/mitmproxy/builtins/script.py b/mitmproxy/addons/script.py index d8ed0e39..d8ed0e39 100644 --- a/mitmproxy/builtins/script.py +++ b/mitmproxy/addons/script.py diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/addons/serverplayback.py index 383e2754..383e2754 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/addons/serverplayback.py diff --git a/mitmproxy/builtins/setheaders.py b/mitmproxy/addons/setheaders.py index 5695e1e8..5695e1e8 100644 --- a/mitmproxy/builtins/setheaders.py +++ b/mitmproxy/addons/setheaders.py diff --git a/mitmproxy/flow/state.py b/mitmproxy/addons/state.py index bb7460b6..bb7460b6 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/addons/state.py diff --git a/mitmproxy/builtins/stickyauth.py b/mitmproxy/addons/stickyauth.py index c0d7893d..c0d7893d 100644 --- a/mitmproxy/builtins/stickyauth.py +++ b/mitmproxy/addons/stickyauth.py diff --git a/mitmproxy/builtins/stickycookie.py b/mitmproxy/addons/stickycookie.py index d89bd92d..d89bd92d 100644 --- a/mitmproxy/builtins/stickycookie.py +++ b/mitmproxy/addons/stickycookie.py diff --git a/mitmproxy/builtins/streambodies.py b/mitmproxy/addons/streambodies.py index b3e5d6b2..b3e5d6b2 100644 --- a/mitmproxy/builtins/streambodies.py +++ b/mitmproxy/addons/streambodies.py diff --git a/mitmproxy/builtins/termlog.py b/mitmproxy/addons/termlog.py index 50c32044..50c32044 100644 --- a/mitmproxy/builtins/termlog.py +++ b/mitmproxy/addons/termlog.py diff --git a/mitmproxy/builtins/wsgiapp.py b/mitmproxy/addons/wsgiapp.py index 9444fcec..d83a1e2e 100644 --- a/mitmproxy/builtins/wsgiapp.py +++ b/mitmproxy/addons/wsgiapp.py @@ -29,7 +29,7 @@ class WSGIApp: **{"mitmproxy.master": ctx.master} ) if err: - ctx.log.warn("Error in wsgi app. %s" % err, "error") + ctx.log.error("Error in wsgi app. %s" % err) flow.reply.kill() raise exceptions.AddonHalt() diff --git a/mitmproxy/builtins/__init__.py b/mitmproxy/builtins/__init__.py deleted file mode 100644 index 54b52a9a..00000000 --- a/mitmproxy/builtins/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -from mitmproxy.builtins import anticache -from mitmproxy.builtins import anticomp -from mitmproxy.builtins import clientplayback -from mitmproxy.builtins import filestreamer -from mitmproxy.builtins import onboarding -from mitmproxy.builtins import replace -from mitmproxy.builtins import script -from mitmproxy.builtins import setheaders -from mitmproxy.builtins import serverplayback -from mitmproxy.builtins import stickyauth -from mitmproxy.builtins import stickycookie -from mitmproxy.builtins import streambodies - - -def default_addons(): - return [ - onboarding.Onboarding(), - anticache.AntiCache(), - anticomp.AntiComp(), - stickyauth.StickyAuth(), - stickycookie.StickyCookie(), - script.ScriptLoader(), - filestreamer.FileStreamer(), - streambodies.StreamBodies(), - replace.Replace(), - setheaders.SetHeaders(), - serverplayback.ServerPlayback(), - clientplayback.ClientPlayback(), - ] diff --git a/mitmproxy/builtins/onboarding/app.py b/mitmproxy/builtins/onboarding/app.py deleted file mode 100644 index c7fcf87b..00000000 --- a/mitmproxy/builtins/onboarding/app.py +++ /dev/null @@ -1,93 +0,0 @@ -import os - -import tornado.template -import tornado.web -import tornado.wsgi - -from mitmproxy import utils -from mitmproxy.proxy import config - -loader = tornado.template.Loader(utils.pkg_data.path("builtins/onboardingapp/templates")) - - -class Adapter(tornado.wsgi.WSGIAdapter): - # Tornado doesn't make the WSGI environment available to pages, so this - # hideous monkey patch is the easiest way to get to the mitmproxy.master - # variable. - - def __init__(self, application): - self._application = application - - def application(self, request): - request.master = self.environ["mitmproxy.master"] - return self._application(request) - - def __call__(self, environ, start_response): - self.environ = environ - return tornado.wsgi.WSGIAdapter.__call__( - self, - environ, - start_response - ) - - -class Index(tornado.web.RequestHandler): - - def get(self): - t = loader.load("index.html") - self.write(t.generate()) - - -class PEM(tornado.web.RequestHandler): - - @property - def filename(self): - return config.CONF_BASENAME + "-ca-cert.pem" - - def get(self): - p = os.path.join(self.request.master.options.cadir, self.filename) - p = os.path.expanduser(p) - self.set_header("Content-Type", "application/x-x509-ca-cert") - self.set_header( - "Content-Disposition", - "inline; filename={}".format( - self.filename)) - - with open(p, "rb") as f: - self.write(f.read()) - - -class P12(tornado.web.RequestHandler): - - @property - def filename(self): - return config.CONF_BASENAME + "-ca-cert.p12" - - def get(self): - p = os.path.join(self.request.master.options.cadir, self.filename) - p = os.path.expanduser(p) - self.set_header("Content-Type", "application/x-pkcs12") - self.set_header( - "Content-Disposition", - "inline; filename={}".format( - self.filename)) - - with open(p, "rb") as f: - self.write(f.read()) - - -application = tornado.web.Application( - [ - (r"/", Index), - (r"/cert/pem", PEM), - (r"/cert/p12", P12), - ( - r"/static/(.*)", - tornado.web.StaticFileHandler, - { - "path": utils.pkg_data.path("onboarding/static") - } - ), - ], - # debug=True -) diff --git a/mitmproxy/console/grideditor/editors.py b/mitmproxy/console/grideditor/editors.py index 7a1ef097..512c2416 100644 --- a/mitmproxy/console/grideditor/editors.py +++ b/mitmproxy/console/grideditor/editors.py @@ -2,7 +2,7 @@ import re import urwid from mitmproxy import exceptions from mitmproxy import flowfilter -from mitmproxy.builtins import script +from mitmproxy.addons import script from mitmproxy.console import common from mitmproxy.console.grideditor import base from mitmproxy.console.grideditor import col_bytes diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index b19c62a2..46dd8254 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -14,7 +14,7 @@ import weakref import urwid from typing import Optional -from mitmproxy import builtins +from mitmproxy import addons from mitmproxy import contentviews from mitmproxy import controller from mitmproxy import exceptions @@ -22,6 +22,7 @@ from mitmproxy import master from mitmproxy import flow from mitmproxy import flowfilter from mitmproxy import utils +from mitmproxy.addons import state import mitmproxy.options from mitmproxy.console import flowlist from mitmproxy.console import flowview @@ -39,10 +40,10 @@ from netlib import tcp, strutils EVENTLOG_SIZE = 500 -class ConsoleState(flow.State): +class ConsoleState(state.State): def __init__(self): - flow.State.__init__(self) + state.State.__init__(self) self.focus = None self.follow_focus = None self.default_body_view = contentviews.get("Auto") @@ -251,7 +252,7 @@ class ConsoleMaster(master.Master): signals.replace_view_state.connect(self.sig_replace_view_state) signals.push_view_state.connect(self.sig_push_view_state) signals.sig_add_log.connect(self.sig_add_log) - self.addons.add(*builtins.default_addons()) + self.addons.add(*addons.default_addons()) self.addons.add(self.state) def __setattr__(self, name, value): diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 27fb4a0c..c5e125ce 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -3,47 +3,6 @@ import queue from mitmproxy import exceptions -class LogEntry: - def __init__(self, msg, level): - self.msg = msg - self.level = level - - -class Log: - """ - The central logger, exposed to scripts as mitmproxy.ctx.log. - """ - def __init__(self, master): - self.master = master - - def debug(self, txt): - """ - Log with level debug. - """ - self(txt, "debug") - - def info(self, txt): - """ - Log with level info. - """ - self(txt, "info") - - def warn(self, txt): - """ - Log with level warn. - """ - self(txt, "warn") - - def error(self, txt): - """ - Log with level error. - """ - self(txt, "error") - - def __call__(self, text, level="info"): - self.master.add_log(text, level) - - class Channel: """ The only way for the proxy server to communicate with the master diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 4731686c..e8b3126f 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -4,10 +4,10 @@ from typing import Optional from mitmproxy import controller from mitmproxy import exceptions from mitmproxy import flow -from mitmproxy import builtins +from mitmproxy import addons from mitmproxy import options from mitmproxy import master -from mitmproxy.builtins import dumper, termlog +from mitmproxy.addons import dumper, termlog from netlib import tcp @@ -37,7 +37,7 @@ class DumpMaster(master.Master): master.Master.__init__(self, options, server) self.has_errored = False self.addons.add(termlog.TermLog()) - self.addons.add(*builtins.default_addons()) + self.addons.add(*addons.default_addons()) self.addons.add(dumper.Dumper()) # This line is just for type hinting self.options = self.options # type: Options diff --git a/mitmproxy/flow/__init__.py b/mitmproxy/flow/__init__.py index 2688966a..69e3ed08 100644 --- a/mitmproxy/flow/__init__.py +++ b/mitmproxy/flow/__init__.py @@ -1,9 +1,7 @@ from mitmproxy.flow import export from mitmproxy.flow.io import FlowWriter, FilteredFlowWriter, FlowReader, read_flows_from_paths -from mitmproxy.flow.state import State, FlowView __all__ = [ "export", "FlowWriter", "FilteredFlowWriter", "FlowReader", "read_flows_from_paths", - "State", "FlowView", ] diff --git a/mitmproxy/log.py b/mitmproxy/log.py new file mode 100644 index 00000000..8c28a9b1 --- /dev/null +++ b/mitmproxy/log.py @@ -0,0 +1,40 @@ + +class LogEntry: + def __init__(self, msg, level): + self.msg = msg + self.level = level + + +class Log: + """ + The central logger, exposed to scripts as mitmproxy.ctx.log. + """ + def __init__(self, master): + self.master = master + + def debug(self, txt): + """ + Log with level debug. + """ + self(txt, "debug") + + def info(self, txt): + """ + Log with level info. + """ + self(txt, "info") + + def warn(self, txt): + """ + Log with level warn. + """ + self(txt, "warn") + + def error(self, txt): + """ + Log with level error. + """ + self(txt, "error") + + def __call__(self, text, level="info"): + self.master.add_log(text, level) diff --git a/mitmproxy/master.py b/mitmproxy/master.py index b6286b89..aa9892e5 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -4,12 +4,13 @@ import contextlib import queue import sys -from mitmproxy import addons +from mitmproxy import addonmanager from mitmproxy import options from mitmproxy import controller from mitmproxy import events from mitmproxy import exceptions from mitmproxy import models +from mitmproxy import log from mitmproxy.flow import io from mitmproxy.protocol import http_replay from netlib import basethread @@ -36,7 +37,7 @@ class Master: """ def __init__(self, opts, server): self.options = opts or options.Options() - self.addons = addons.Addons(self) + self.addons = addonmanager.AddonManager(self) self.event_queue = queue.Queue() self.should_exit = threading.Event() self.server = server @@ -50,7 +51,7 @@ class Master: yield return mitmproxy_ctx.master = self - mitmproxy_ctx.log = controller.Log(self) + mitmproxy_ctx.log = log.Log(self) try: yield finally: @@ -66,7 +67,7 @@ class Master: level: debug, info, warn, error """ with self.handlecontext(): - self.addons("log", controller.LogEntry(e, level)) + self.addons("log", log.LogEntry(e, level)) def start(self): self.should_exit.clear() diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index ef6aaf36..8064f12d 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -1,5 +1,5 @@ import netlib.exceptions -from mitmproxy import controller +from mitmproxy import log from mitmproxy import exceptions from mitmproxy import protocol from mitmproxy.proxy import modes @@ -113,7 +113,7 @@ class RootContext: for i in subs: full_msg.append(" -> " + i) full_msg = "\n".join(full_msg) - self.channel.tell("log", controller.LogEntry(full_msg, level)) + self.channel.tell("log", log.LogEntry(full_msg, level)) @property def layers(self): diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 3d66812f..c2a6a5c3 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -5,7 +5,7 @@ import traceback import netlib.exceptions from mitmproxy import exceptions from mitmproxy import models -from mitmproxy import controller +from mitmproxy import log from mitmproxy.proxy import modes from mitmproxy.proxy import root_context from netlib import tcp @@ -151,4 +151,4 @@ class ConnectionHandler: def log(self, msg, level): msg = "{}: {}".format(repr(self.client_conn.address), msg) - self.channel.tell("log", controller.LogEntry(msg, level)) + self.channel.tell("log", log.LogEntry(msg, level)) diff --git a/mitmproxy/web/master.py b/mitmproxy/web/master.py index 1f0dc709..f07d28c8 100644 --- a/mitmproxy/web/master.py +++ b/mitmproxy/web/master.py @@ -6,10 +6,10 @@ import tornado.ioloop from typing import Optional -from mitmproxy import builtins +from mitmproxy import addons from mitmproxy import controller from mitmproxy import exceptions -from mitmproxy import flow +from mitmproxy.addons import state from mitmproxy import options from mitmproxy import master from mitmproxy.web import app @@ -20,7 +20,7 @@ class Stop(Exception): pass -class WebFlowView(flow.FlowView): +class WebFlowView(state.FlowView): def __init__(self, store): super().__init__(store, None) @@ -57,7 +57,7 @@ class WebFlowView(flow.FlowView): ) -class WebState(flow.State): +class WebState(state.State): def __init__(self): super().__init__() @@ -136,7 +136,7 @@ class WebMaster(master.Master): def __init__(self, options, server): super().__init__(options, server) self.state = WebState() - self.addons.add(*builtins.default_addons()) + self.addons.add(*addons.default_addons()) self.addons.add(self.state) self.app = app.Application( self, self.options.wdebug, self.options.wauthenticator @@ -3,7 +3,7 @@ max-line-length = 140 max-complexity = 25 ignore = E251,C901 exclude = mitmproxy/contrib/*,test/mitmproxy/data/* -builtins = file,open,basestring,xrange,unicode,long,cmp +addons = file,open,basestring,xrange,unicode,long,cmp [tool:pytest] testpaths = test diff --git a/test/mitmproxy/builtins/__init__.py b/test/mitmproxy/addons/__init__.py index e69de29b..e69de29b 100644 --- a/test/mitmproxy/builtins/__init__.py +++ b/test/mitmproxy/addons/__init__.py diff --git a/test/mitmproxy/builtins/test_anticache.py b/test/mitmproxy/addons/test_anticache.py index 790ae97d..f7418f38 100644 --- a/test/mitmproxy/builtins/test_anticache.py +++ b/test/mitmproxy/addons/test_anticache.py @@ -1,5 +1,5 @@ from .. import tutils, mastertest -from mitmproxy.builtins import anticache +from mitmproxy.addons import anticache from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/builtins/test_anticomp.py b/test/mitmproxy/addons/test_anticomp.py index d5a0d6eb..5f95013f 100644 --- a/test/mitmproxy/builtins/test_anticomp.py +++ b/test/mitmproxy/addons/test_anticomp.py @@ -1,5 +1,5 @@ from .. import tutils, mastertest -from mitmproxy.builtins import anticomp +from mitmproxy.addons import anticomp from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/builtins/test_clientplayback.py b/test/mitmproxy/addons/test_clientplayback.py index e2c5be7e..c5407d18 100644 --- a/test/mitmproxy/builtins/test_clientplayback.py +++ b/test/mitmproxy/addons/test_clientplayback.py @@ -1,6 +1,6 @@ import mock -from mitmproxy.builtins import clientplayback +from mitmproxy.addons import clientplayback from mitmproxy import options from .. import tutils, mastertest diff --git a/test/mitmproxy/builtins/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index d5291bc4..ce2d2de9 100644 --- a/test/mitmproxy/builtins/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -2,7 +2,7 @@ import io from .. import tutils, mastertest -from mitmproxy.builtins import dumper +from mitmproxy.addons import dumper from mitmproxy import exceptions from mitmproxy import dump from mitmproxy import models diff --git a/test/mitmproxy/builtins/test_filestreamer.py b/test/mitmproxy/addons/test_filestreamer.py index 35fe1ca2..a85fcd0c 100644 --- a/test/mitmproxy/builtins/test_filestreamer.py +++ b/test/mitmproxy/addons/test_filestreamer.py @@ -2,7 +2,7 @@ from .. import tutils, mastertest import os.path -from mitmproxy.builtins import filestreamer +from mitmproxy.addons import filestreamer from mitmproxy import master from mitmproxy.flow import io from mitmproxy import options diff --git a/test/mitmproxy/builtins/test_onboarding.py b/test/mitmproxy/addons/test_onboarding.py index 3226aec3..63125c23 100644 --- a/test/mitmproxy/builtins/test_onboarding.py +++ b/test/mitmproxy/addons/test_onboarding.py @@ -1,4 +1,4 @@ -from mitmproxy.builtins import onboarding +from mitmproxy.addons import onboarding from .. import tservers diff --git a/test/mitmproxy/builtins/test_replace.py b/test/mitmproxy/addons/test_replace.py index 35f3d430..94c2f832 100644 --- a/test/mitmproxy/builtins/test_replace.py +++ b/test/mitmproxy/addons/test_replace.py @@ -1,5 +1,5 @@ from .. import tutils, mastertest, tservers -from mitmproxy.builtins import replace +from mitmproxy.addons import replace from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/builtins/test_script.py b/test/mitmproxy/addons/test_script.py index ab4343b5..83e60fbd 100644 --- a/test/mitmproxy/builtins/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -7,7 +7,7 @@ import re from mitmproxy import exceptions from mitmproxy import options from mitmproxy import proxy -from mitmproxy.builtins import script +from mitmproxy.addons import script from mitmproxy import master from .. import tutils, mastertest diff --git a/test/mitmproxy/builtins/test_serverplayback.py b/test/mitmproxy/addons/test_serverplayback.py index c51814f5..649b3c22 100644 --- a/test/mitmproxy/builtins/test_serverplayback.py +++ b/test/mitmproxy/addons/test_serverplayback.py @@ -1,7 +1,7 @@ from .. import tutils, mastertest import netlib.tutils -from mitmproxy.builtins import serverplayback +from mitmproxy.addons import serverplayback from mitmproxy import options from mitmproxy import proxy from mitmproxy import exceptions diff --git a/test/mitmproxy/builtins/test_setheaders.py b/test/mitmproxy/addons/test_setheaders.py index bac8b02e..0fbbd4cb 100644 --- a/test/mitmproxy/builtins/test_setheaders.py +++ b/test/mitmproxy/addons/test_setheaders.py @@ -1,6 +1,6 @@ from .. import tutils, mastertest -from mitmproxy.builtins import setheaders +from mitmproxy.addons import setheaders from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/test_flow_state.py b/test/mitmproxy/addons/test_state.py index 05f4cbb4..71c46dcb 100644 --- a/test/mitmproxy/test_flow_state.py +++ b/test/mitmproxy/addons/test_state.py @@ -1,12 +1,13 @@ -from mitmproxy import flow from mitmproxy import proxy from mitmproxy import master -from . import tutils +from mitmproxy.addons import state + +from .. import tutils class TestState: def test_duplicate_flow(self): - s = flow.State() + s = state.State() fm = master.Master(None, proxy.DummyServer()) fm.addons.add(s) f = tutils.tflow(resp=True) diff --git a/test/mitmproxy/builtins/test_stickyauth.py b/test/mitmproxy/addons/test_stickyauth.py index 22523548..459dc5f7 100644 --- a/test/mitmproxy/builtins/test_stickyauth.py +++ b/test/mitmproxy/addons/test_stickyauth.py @@ -1,5 +1,5 @@ from .. import tutils, mastertest -from mitmproxy.builtins import stickyauth +from mitmproxy.addons import stickyauth from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/builtins/test_stickycookie.py b/test/mitmproxy/addons/test_stickycookie.py index c70b03d8..29c9e198 100644 --- a/test/mitmproxy/builtins/test_stickycookie.py +++ b/test/mitmproxy/addons/test_stickycookie.py @@ -1,5 +1,5 @@ from .. import tutils, mastertest -from mitmproxy.builtins import stickycookie +from mitmproxy.addons import stickycookie from mitmproxy import master from mitmproxy import options from mitmproxy import proxy diff --git a/test/mitmproxy/builtins/test_streambodies.py b/test/mitmproxy/addons/test_streambodies.py index 4a8c2474..cf416c86 100644 --- a/test/mitmproxy/builtins/test_streambodies.py +++ b/test/mitmproxy/addons/test_streambodies.py @@ -3,7 +3,7 @@ from mitmproxy import master from mitmproxy import options from mitmproxy import proxy -from mitmproxy.builtins import streambodies +from mitmproxy.addons import streambodies class TestStreamBodies(mastertest.MasterTest): diff --git a/test/mitmproxy/builtins/test_termlog.py b/test/mitmproxy/addons/test_termlog.py index 1564b53f..a9f18a51 100644 --- a/test/mitmproxy/builtins/test_termlog.py +++ b/test/mitmproxy/addons/test_termlog.py @@ -1,8 +1,8 @@ from .. import mastertest import io -from mitmproxy.builtins import termlog -from mitmproxy import controller +from mitmproxy.addons import termlog +from mitmproxy import log from mitmproxy import dump @@ -11,7 +11,7 @@ class TestTermLog(mastertest.MasterTest): t = termlog.TermLog() sio = io.StringIO() t.configure(dump.Options(tfile = sio, verbosity = 2), set([])) - t.log(controller.LogEntry("one", "info")) + t.log(log.LogEntry("one", "info")) assert "one" in sio.getvalue() - t.log(controller.LogEntry("two", "debug")) + t.log(log.LogEntry("two", "debug")) assert "two" not in sio.getvalue() diff --git a/test/mitmproxy/builtins/test_wsgiapp.py b/test/mitmproxy/addons/test_wsgiapp.py index a39ec5c3..760ee460 100644 --- a/test/mitmproxy/builtins/test_wsgiapp.py +++ b/test/mitmproxy/addons/test_wsgiapp.py @@ -1,17 +1,17 @@ import flask from .. import tservers -from mitmproxy.builtins import wsgiapp +from mitmproxy.addons import wsgiapp -testapp = flask.Flask(__name__) +tapp = flask.Flask(__name__) -@testapp.route("/") +@tapp.route("/") def hello(): return "testapp" -@testapp.route("/error") +@tapp.route("/error") def error(): raise ValueError("An exception...") @@ -23,7 +23,7 @@ def errapp(environ, start_response): class TestApp(tservers.HTTPProxyTest): def addons(self): return [ - wsgiapp.WSGIApp(testapp, "testapp", 80), + wsgiapp.WSGIApp(tapp, "testapp", 80), wsgiapp.WSGIApp(errapp, "errapp", 80) ] diff --git a/test/mitmproxy/script/test_concurrent.py b/test/mitmproxy/script/test_concurrent.py index bebd8dea..51c36abf 100644 --- a/test/mitmproxy/script/test_concurrent.py +++ b/test/mitmproxy/script/test_concurrent.py @@ -1,6 +1,6 @@ from test.mitmproxy import tutils, mastertest from mitmproxy import controller -from mitmproxy.builtins import script +from mitmproxy.addons import script from mitmproxy import options from mitmproxy import proxy from mitmproxy import master diff --git a/test/mitmproxy/test_addons.py b/test/mitmproxy/test_addonmanager.py index dcf14398..7a50148e 100644 --- a/test/mitmproxy/test_addons.py +++ b/test/mitmproxy/test_addonmanager.py @@ -1,4 +1,4 @@ -from mitmproxy import addons +from mitmproxy import addonmanager from mitmproxy import options from mitmproxy import master from mitmproxy import proxy @@ -15,7 +15,7 @@ class TAddon: def test_simple(): o = options.Options() m = master.Master(o, proxy.DummyServer(o)) - a = addons.Addons(m) + a = addonmanager.AddonManager(m) a.add(TAddon("one")) assert a.get("one") assert not a.get("two") diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index ee5080e8..7551c1c8 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -5,7 +5,7 @@ import shlex from mitmproxy import options from mitmproxy import contentviews from mitmproxy import proxy -from mitmproxy.builtins import script +from mitmproxy.addons import script from mitmproxy import master import netlib.utils diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 2b387f5c..86cd7d16 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -4,6 +4,7 @@ import io import netlib.utils from netlib.http import Headers from mitmproxy import flowfilter, flow, options +from mitmproxy.addons import state from mitmproxy.contrib import tnetstring from mitmproxy.exceptions import FlowReadException, Kill from mitmproxy.models import Error @@ -110,7 +111,7 @@ class TestHTTPFlow: def test_killall(self): srv = DummyServer(None) - s = flow.State() + s = state.State() fm = master.Master(None, srv) fm.addons.add(s) @@ -190,7 +191,7 @@ class TestTCPFlow: class TestState: def test_backup(self): - c = flow.State() + c = state.State() f = tutils.tflow() c.add_flow(f) f.backup() @@ -202,7 +203,7 @@ class TestState: connect -> request -> response """ - c = flow.State() + c = state.State() f = tutils.tflow() c.add_flow(f) assert f @@ -226,13 +227,13 @@ class TestState: assert c.active_flow_count() == 0 def test_err(self): - c = flow.State() + c = state.State() f = tutils.tflow() c.add_flow(f) f.error = Error("message") assert c.update_flow(f) - c = flow.State() + c = state.State() f = tutils.tflow() c.add_flow(f) c.set_view_filter("~e") @@ -242,7 +243,7 @@ class TestState: assert c.view def test_set_view_filter(self): - c = flow.State() + c = state.State() f = tutils.tflow() assert len(c.view) == 0 @@ -270,7 +271,7 @@ class TestState: assert "Invalid" in c.set_view_filter("~") def test_set_intercept(self): - c = flow.State() + c = state.State() assert not c.set_intercept("~q") assert c.intercept_txt == "~q" assert "Invalid" in c.set_intercept("~") @@ -293,7 +294,7 @@ class TestState: state.add_flow(f) def test_clear(self): - c = flow.State() + c = state.State() f = self._add_request(c) f.intercepted = True @@ -301,7 +302,7 @@ class TestState: assert c.flow_count() == 0 def test_dump_flows(self): - c = flow.State() + c = state.State() self._add_request(c) self._add_response(c) self._add_request(c) @@ -317,7 +318,7 @@ class TestState: assert isinstance(c.flows[0], Flow) def test_accept_all(self): - c = flow.State() + c = state.State() self._add_request(c) self._add_response(c) self._add_request(c) @@ -363,7 +364,7 @@ class TestSerialize: def test_load_flows(self): r = self._treader() - s = flow.State() + s = state.State() fm = master.Master(None, DummyServer()) fm.addons.add(s) fm.load_flows(r) @@ -371,7 +372,7 @@ class TestSerialize: def test_load_flows_reverse(self): r = self._treader() - s = flow.State() + s = state.State() opts = options.Options( mode="reverse", upstream_server="https://use-this-domain" @@ -440,7 +441,7 @@ class TestFlowMaster: assert fm.create_request("GET", "http", "example.com", 80, "/") def test_all(self): - s = flow.State() + s = state.State() fm = master.Master(None, DummyServer()) fm.addons.add(s) f = tutils.tflow(req=None) diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py index 6679625b..7616b5a7 100644 --- a/test/mitmproxy/test_server.py +++ b/test/mitmproxy/test_server.py @@ -5,7 +5,7 @@ import time import netlib.tutils from mitmproxy import controller from mitmproxy import options -from mitmproxy.builtins import script +from mitmproxy.addons import script from mitmproxy.models import HTTPResponse, HTTPFlow from mitmproxy.proxy.config import HostMatcher, parse_server_spec from netlib import tcp, http, socks diff --git a/test/mitmproxy/tools/benchtool.py b/test/mitmproxy/tools/benchtool.py index bc68645c..9e2ab8ee 100644 --- a/test/mitmproxy/tools/benchtool.py +++ b/test/mitmproxy/tools/benchtool.py @@ -38,7 +38,7 @@ def main(profiler, clock_type, concurrency): if profiler == "yappi": yappi.set_clock_type(clock_type) - yappi.start(builtins=True) + yappi.start(addons=True) print("Start mitmdump...") mitmdump(["-k", "-q", "-S", "1024example"]) diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index 254af2f0..1243bca0 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -7,7 +7,7 @@ import sys from mitmproxy.proxy.config import ProxyConfig from mitmproxy.proxy.server import ProxyServer from mitmproxy import master -from mitmproxy.flow import state +from mitmproxy.addons import state import pathod.test import pathod.pathoc from mitmproxy import controller, options diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index 87eb9c35..336dc86d 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -15,7 +15,7 @@ class TestRequestData: class TestRequestCore: """ - Tests for builtins and the attributes that are directly proxied from the data structure + Tests for addons and the attributes that are directly proxied from the data structure """ def test_repr(self): request = treq() diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index 0953f278..725f2b33 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -19,7 +19,7 @@ class TestResponseData: class TestResponseCore: """ - Tests for builtins and the attributes that are directly proxied from the data structure + Tests for addons and the attributes that are directly proxied from the data structure """ def test_repr(self): response = tresp() |