diff options
-rw-r--r-- | mitmproxy/console/options.py | 54 | ||||
-rw-r--r-- | mitmproxy/console/statusbar.py | 10 | ||||
-rw-r--r-- | mitmproxy/flow/master.py | 13 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 9 |
4 files changed, 27 insertions, 59 deletions
diff --git a/mitmproxy/console/options.py b/mitmproxy/console/options.py index e1dd29ee..62564a60 100644 --- a/mitmproxy/console/options.py +++ b/mitmproxy/console/options.py @@ -42,8 +42,8 @@ class Options(urwid.WidgetWrap): select.Option( "Ignore Patterns", "I", - lambda: master.server.config.check_ignore, - self.ignorepatterns + lambda: master.options.ignore_hosts, + self.ignore_hosts ), select.Option( "Replacement Patterns", @@ -82,14 +82,14 @@ class Options(urwid.WidgetWrap): select.Option( "No Upstream Certs", "U", - lambda: master.server.config.no_upstream_cert, - self.toggle_upstream_cert + lambda: master.options.no_upstream_cert, + master.options.toggler("no_upstream_cert") ), select.Option( "TCP Proxying", "T", - lambda: master.server.config.check_tcp, - self.tcp_proxy + lambda: master.options.tcp_hosts, + self.tcp_hosts ), select.Heading("Utility"), @@ -152,21 +152,20 @@ class Options(urwid.WidgetWrap): return super(self.__class__, self).keypress(size, key) def clearall(self): - self.master.server.config.no_upstream_cert = False - self.master.set_ignore_filter([]) - self.master.set_tcp_filter([]) - self.master.options.update( anticache = False, anticomp = False, + ignore_hosts = (), + tcp_hosts = (), kill = False, + no_upstream_cert = False, refresh_server_playback = True, replacements = [], scripts = [], setheaders = [], showhost = False, stickyauth = None, - stickycookie = None + stickycookie = None, ) self.master.state.default_body_view = contentviews.get("Auto") @@ -177,10 +176,6 @@ class Options(urwid.WidgetWrap): expire = 1 ) - def toggle_upstream_cert(self): - self.master.server.config.no_upstream_cert = not self.master.server.config.no_upstream_cert - signals.update_settings.send(self) - def setheaders(self): self.master.view_grideditor( grideditor.SetHeadersEditor( @@ -190,14 +185,21 @@ class Options(urwid.WidgetWrap): ) ) - def ignorepatterns(self): - def _set(ignore): - self.master.set_ignore_filter(ignore) + def tcp_hosts(self): self.master.view_grideditor( grideditor.HostPatternEditor( self.master, - self.master.get_ignore_filter(), - _set + self.master.options.tcp_hosts, + self.master.options.setter("tcp_hosts") + ) + ) + + def ignore_hosts(self): + self.master.view_grideditor( + grideditor.HostPatternEditor( + self.master, + self.master.options.ignore_hosts, + self.master.options.setter("ignore_hosts") ) ) @@ -229,18 +231,6 @@ class Options(urwid.WidgetWrap): def has_default_displaymode(self): return self.master.state.default_body_view.name != "Auto" - def tcp_proxy(self): - def _set(tcp): - self.master.set_tcp_filter(tcp) - signals.update_settings.send(self) - self.master.view_grideditor( - grideditor.HostPatternEditor( - self.master, - self.master.get_tcp_filter(), - _set - ) - ) - def sticky_auth(self): signals.status_prompt.send( prompt = "Sticky auth filter", diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index e1c65714..f0da9dcd 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -156,14 +156,14 @@ class StatusBar(urwid.WidgetWrap): r.append(":%s in file]" % self.master.server_playback.count()) else: r.append(":%s to go]" % self.master.server_playback.count()) - if self.master.get_ignore_filter(): + if self.master.options.ignore_hosts: r.append("[") r.append(("heading_key", "I")) - r.append("gnore:%d]" % len(self.master.get_ignore_filter())) - if self.master.get_tcp_filter(): + r.append("gnore:%d]" % len(self.master.options.ignore_hosts)) + if self.master.options.tcp_hosts: r.append("[") r.append(("heading_key", "T")) - r.append("CP:%d]" % len(self.master.get_tcp_filter())) + r.append("CP:%d]" % len(self.master.options.tcp_hosts)) if self.master.state.intercept_txt: r.append("[") r.append(("heading_key", "i")) @@ -200,7 +200,7 @@ class StatusBar(urwid.WidgetWrap): opts.append("norefresh") if self.master.options.kill: opts.append("killextra") - if self.master.server.config.no_upstream_cert: + if self.master.options.no_upstream_cert: opts.append("no-upstream-cert") if self.master.state.follow_focus: opts.append("following") diff --git a/mitmproxy/flow/master.py b/mitmproxy/flow/master.py index a31840d9..088375fe 100644 --- a/mitmproxy/flow/master.py +++ b/mitmproxy/flow/master.py @@ -13,7 +13,6 @@ from mitmproxy.flow import io from mitmproxy.flow import modules from mitmproxy.onboarding import app from mitmproxy.protocol import http_replay -from mitmproxy.proxy.config import HostMatcher class FlowMaster(controller.Master): @@ -48,18 +47,6 @@ class FlowMaster(controller.Master): port ) - def get_ignore_filter(self): - return self.server.config.check_ignore.patterns - - def set_ignore_filter(self, host_patterns): - self.server.config.check_ignore = HostMatcher(host_patterns) - - def get_tcp_filter(self): - return self.server.config.check_tcp.patterns - - def set_tcp_filter(self, host_patterns): - self.server.config.check_tcp = HostMatcher(host_patterns) - def set_stream_large_bodies(self, max_size): if max_size is not None: self.stream_large_bodies = modules.StreamLargeBodies(max_size) diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index ee588a5c..e17a125c 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -12,7 +12,6 @@ from mitmproxy.models import Flow from mitmproxy.models import HTTPFlow from mitmproxy.models import HTTPRequest from mitmproxy.models import HTTPResponse -from mitmproxy.proxy.config import HostMatcher from mitmproxy.proxy import ProxyConfig from mitmproxy.proxy.server import DummyServer from mitmproxy.models.connections import ClientConnection @@ -690,14 +689,6 @@ class TestSerialize: class TestFlowMaster: - def test_getset_ignore(self): - p = mock.Mock() - p.config.check_ignore = HostMatcher() - fm = flow.FlowMaster(None, p, flow.State()) - assert not fm.get_ignore_filter() - fm.set_ignore_filter(["^apple\.com:", ":443$"]) - assert fm.get_ignore_filter() - def test_replay(self): s = flow.State() fm = flow.FlowMaster(None, None, s) |