aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.appveyor.yml4
-rw-r--r--mitmproxy/addons/view.py11
-rw-r--r--mitmproxy/proxy/modes/socks_proxy.py2
-rw-r--r--mitmproxy/tools/console/flowlist.py3
-rw-r--r--test/mitmproxy/addons/test_view.py7
-rw-r--r--test/mitmproxy/test_server.py22
-rw-r--r--tox.ini2
7 files changed, 47 insertions, 4 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 31364c4a..53e33614 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -44,12 +44,12 @@ test_script:
if (!(Test-Path "C:\projects\mitmproxy\release\installbuilder-installer.exe")) {
"Download InstallBuilder..."
(New-Object System.Net.WebClient).DownloadFile(
- "https://installbuilder.bitrock.com/installbuilder-enterprise-16.11.1-windows-installer.exe",
+ "https://installbuilder.bitrock.com/installbuilder-enterprise-17.1.0-windows-installer.exe",
"C:\projects\mitmproxy\release\installbuilder-installer.exe"
)
}
Start-Process "C:\projects\mitmproxy\release\installbuilder-installer.exe" "--mode unattended --unattendedmodeui none" -Wait
- & 'C:\Program Files (x86)\BitRock InstallBuilder Enterprise 16.11.1\bin\builder-cli.exe' `
+ & 'C:\Program Files (x86)\BitRock InstallBuilder Enterprise 17.1.0\bin\builder-cli.exe' `
build `
.\release\installbuilder\mitmproxy.xml `
windows `
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py
index 8358a045..d2ab75f3 100644
--- a/mitmproxy/addons/view.py
+++ b/mitmproxy/addons/view.py
@@ -230,6 +230,17 @@ class View(collections.Sequence):
self.sig_view_refresh.send(self)
self.sig_store_refresh.send(self)
+ def clear_not_marked(self):
+ """
+ Clears only the unmarked flows.
+ """
+ for flow in self._store.copy().values():
+ if not flow.marked:
+ self._store.pop(flow.id)
+
+ self._refilter()
+ self.sig_store_refresh.send(self)
+
def add(self, f: mitmproxy.flow.Flow) -> bool:
"""
Adds a flow to the state. If the flow already exists, it is
diff --git a/mitmproxy/proxy/modes/socks_proxy.py b/mitmproxy/proxy/modes/socks_proxy.py
index 3121b731..001a5ed3 100644
--- a/mitmproxy/proxy/modes/socks_proxy.py
+++ b/mitmproxy/proxy/modes/socks_proxy.py
@@ -30,7 +30,7 @@ class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin):
if connect_request.msg != socks.CMD.CONNECT:
raise socks.SocksError(
socks.REP.COMMAND_NOT_SUPPORTED,
- "mitmproxy only supports SOCKS5 CONNECT."
+ "mitmproxy only supports SOCKS5 CONNECT"
)
# We always connect lazily, but we need to pretend to the client that we connected.
diff --git a/mitmproxy/tools/console/flowlist.py b/mitmproxy/tools/console/flowlist.py
index b26289af..39811ce1 100644
--- a/mitmproxy/tools/console/flowlist.py
+++ b/mitmproxy/tools/console/flowlist.py
@@ -35,6 +35,7 @@ def _mkhelp():
("W", "stream flows to file"),
("X", "kill and delete flow, even if it's mid-intercept"),
("z", "clear flow list or eventlog"),
+ ("Z", "clear unmarked flows"),
("tab", "tab between eventlog and flow list"),
("enter", "view flow"),
("|", "run script on this flow"),
@@ -354,6 +355,8 @@ class FlowListBox(urwid.ListBox):
self.master.view.update(f)
elif key == "z":
self.master.view.clear()
+ elif key == "Z":
+ self.master.view.clear_not_marked()
elif key == "e":
self.master.toggle_eventlog()
elif key == "g":
diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py
index 99b12cb4..7145bfc8 100644
--- a/test/mitmproxy/addons/test_view.py
+++ b/test/mitmproxy/addons/test_view.py
@@ -108,6 +108,13 @@ def test_simple():
assert list(v) == [f, f3, f2]
assert len(v._store) == 3
+ f.marked = not f.marked
+ f2.marked = not f2.marked
+ v.clear_not_marked()
+ assert list(v) == [f, f2]
+ assert len(v) == 2
+ assert len(v._store) == 2
+
v.clear()
assert len(v) == 0
assert len(v._store) == 0
diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py
index 272fc0e0..86fc6ba0 100644
--- a/test/mitmproxy/test_server.py
+++ b/test/mitmproxy/test_server.py
@@ -503,6 +503,7 @@ class TestSocks5(tservers.SocksModeTest):
f = p.request("get:/p/200")
assert f.status_code == 502
assert b"SOCKS5 mode failure" in f.content
+ assert b"Invalid SOCKS version. Expected 0x05, got 0x47" in f.content
def test_no_connect(self):
"""
@@ -526,6 +527,27 @@ class TestSocks5(tservers.SocksModeTest):
f = p.request("get:/p/200") # the request doesn't matter, error response from handshake will be read anyway.
assert f.status_code == 502
assert b"SOCKS5 mode failure" in f.content
+ assert b"mitmproxy only supports SOCKS5 CONNECT" in f.content
+
+ def test_with_authentication(self):
+ p = self.pathoc()
+ with p.connect():
+ socks.ClientGreeting(
+ socks.VERSION.SOCKS5,
+ [socks.METHOD.USERNAME_PASSWORD]
+ ).to_file(p.wfile)
+ socks.Message(
+ socks.VERSION.SOCKS5,
+ socks.CMD.BIND,
+ socks.ATYP.DOMAINNAME,
+ ("example.com", 8080)
+ ).to_file(p.wfile)
+
+ p.wfile.flush()
+ f = p.request("get:/p/200") # the request doesn't matter, error response from handshake will be read anyway.
+ assert f.status_code == 502
+ assert b"SOCKS5 mode failure" in f.content
+ assert b"mitmproxy only supports SOCKS without authentication" in f.content
class TestSocks5SSL(tservers.SocksModeTest):
diff --git a/tox.ini b/tox.ini
index 16f4d664..fafa7220 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,7 +15,7 @@ commands =
--full-cov=mitmproxy/addons/ \
--full-cov=mitmproxy/contentviews/ --no-full-cov=mitmproxy/contentviews/__init__.py --no-full-cov=mitmproxy/contentviews/protobuf.py --no-full-cov=mitmproxy/contentviews/wbxml.py --no-full-cov=mitmproxy/contentviews/xml_html.py \
--full-cov=mitmproxy/net/ --no-full-cov=mitmproxy/net/check.py --no-full-cov=mitmproxy/net/socks.py --no-full-cov=mitmproxy/net/tcp.py --no-full-cov=mitmproxy/net/http/cookies.py --no-full-cov=mitmproxy/net/http/encoding.py --no-full-cov=mitmproxy/net/http/message.py --no-full-cov=mitmproxy/net/http/request.py --no-full-cov=mitmproxy/net/http/response.py --no-full-cov=mitmproxy/net/http/url.py \
- --full-cov=mitmproxy/proxy/ --no-full-cov=mitmproxy/proxy/protocol/ --no-full-cov=mitmproxy/proxy/modes/socks_proxy.py --no-full-cov=mitmproxy/proxy/config.py --no-full-cov=mitmproxy/proxy/root_context.py --no-full-cov=mitmproxy/proxy/server.py \
+ --full-cov=mitmproxy/proxy/ --no-full-cov=mitmproxy/proxy/protocol/ --no-full-cov=mitmproxy/proxy/config.py --no-full-cov=mitmproxy/proxy/root_context.py --no-full-cov=mitmproxy/proxy/server.py \
--full-cov=mitmproxy/script/ \
--full-cov=mitmproxy/test/ \
--full-cov=mitmproxy/types/ --no-full-cov=mitmproxy/types/basethread.py \