diff options
-rw-r--r-- | README.rst | 18 | ||||
-rw-r--r-- | docs/src/content/howto-transparent.md | 2 | ||||
-rw-r--r-- | mitmproxy/connections.py | 19 | ||||
-rw-r--r-- | mitmproxy/utils/human.py | 4 | ||||
-rw-r--r-- | setup.py | 6 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_onboarding.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/test_connections.py | 6 | ||||
-rw-r--r-- | test/mitmproxy/utils/test_human.py | 1 |
8 files changed, 37 insertions, 23 deletions
@@ -26,9 +26,9 @@ and pathod websites. |mitmproxy_site| -The latest documentation for mitmproxy is available on our website. +The documentation for mitmproxy is available on our website: -|mitmproxy_docs| +|mitmproxy_docs_stable| |mitmproxy_docs_master| Join our discussion forum on Discourse to ask questions, help @@ -45,7 +45,7 @@ Join our developer chat on Slack if you would like to contribute to mitmproxy it Installation ------------ -The installation instructions are `here <https://mitmproxy.org/docs/latest/overview-installation>`__. +The installation instructions are `here <https://docs.mitmproxy.org/stable/overview-installation>`__. If you want to contribute changes, keep on reading. Contributing @@ -150,9 +150,13 @@ with the following command: :target: https://mitmproxy.org/ :alt: mitmproxy.org -.. |mitmproxy_docs| image:: https://shields.mitmproxy.org/api/docs-latest-brightgreen.svg - :target: https://mitmproxy.org/docs/latest/ - :alt: mitmproxy documentation +.. |mitmproxy_docs_stable| image:: https://shields.mitmproxy.org/api/docs-stable-brightgreen.svg + :target: https://docs.mitmproxy.org/stable/ + :alt: mitmproxy documentation stable + +.. |mitmproxy_docs_master| image:: https://shields.mitmproxy.org/api/docs-master-brightgreen.svg + :target: https://docs.mitmproxy.org/master/ + :alt: mitmproxy documentation master .. |mitmproxy_discourse| image:: https://shields.mitmproxy.org/api/https%3A%2F%2F-discourse.mitmproxy.org-orange.svg :target: https://discourse.mitmproxy.org @@ -182,7 +186,7 @@ with the following command: :target: https://pypi.python.org/pypi/mitmproxy :alt: Supported Python versions -.. _`advanced installation`: https://mitmproxy.org/docs/latest/overview-installation/#advanced-installation +.. _`advanced installation`: https://docs.mitmproxy.org/stable/overview-installation/#advanced-installation .. _virtualenv: https://virtualenv.pypa.io/ .. _`pytest`: http://pytest.org/ .. _tox: https://tox.readthedocs.io/ diff --git a/docs/src/content/howto-transparent.md b/docs/src/content/howto-transparent.md index 00db189e..ee5b9f57 100644 --- a/docs/src/content/howto-transparent.md +++ b/docs/src/content/howto-transparent.md @@ -172,7 +172,7 @@ rdr on en0 inet proto tcp to any port {80, 443} -> 127.0.0.1 port 8080 These rules tell pf to redirect all traffic destined for port 80 or 443 to the local mitmproxy instance running on port 8080. You should replace -`en2` with the interface on which your test device will appear. +`en0` with the interface on which your test device will appear. ### 3. Configure pf with the rules. diff --git a/mitmproxy/connections.py b/mitmproxy/connections.py index 29ab6ab5..9c26b44f 100644 --- a/mitmproxy/connections.py +++ b/mitmproxy/connections.py @@ -1,18 +1,18 @@ -import time - import os +import time import typing import uuid -from mitmproxy import stateobject, exceptions from mitmproxy import certs +from mitmproxy import exceptions +from mitmproxy import stateobject from mitmproxy.net import tcp from mitmproxy.net import tls +from mitmproxy.utils import human from mitmproxy.utils import strutils class ClientConnection(tcp.BaseHandler, stateobject.StateObject): - """ A client connection @@ -72,11 +72,10 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): else: alpn = "" - return "<ClientConnection: {tls}{alpn}{host}:{port}>".format( + return "<ClientConnection: {tls}{alpn}{address}>".format( tls=tls, alpn=alpn, - host=self.address[0], - port=self.address[1], + address=human.format_address(self.address), ) def __eq__(self, other): @@ -161,7 +160,6 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): class ServerConnection(tcp.TCPClient, stateobject.StateObject): - """ A server connection @@ -209,11 +207,10 @@ class ServerConnection(tcp.TCPClient, stateobject.StateObject): ) else: alpn = "" - return "<ServerConnection: {tls}{alpn}{host}:{port}>".format( + return "<ServerConnection: {tls}{alpn}{address}>".format( tls=tls, alpn=alpn, - host=self.address[0], - port=self.address[1], + address=human.format_address(self.address), ) def __eq__(self, other): diff --git a/mitmproxy/utils/human.py b/mitmproxy/utils/human.py index b21ac0b8..5c02b072 100644 --- a/mitmproxy/utils/human.py +++ b/mitmproxy/utils/human.py @@ -73,11 +73,13 @@ def format_timestamp_with_milli(s): return d.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] -def format_address(address: tuple) -> str: +def format_address(address: typing.Optional[tuple]) -> str: """ This function accepts IPv4/IPv6 tuples and returns the formatted address string with port number """ + if address is None: + return "<no address>" try: host = ipaddress.ip_address(address[0]) if host.is_unspecified: @@ -65,7 +65,7 @@ setup( "brotlipy>=0.7.0,<0.8", "certifi>=2015.11.20.1", # no semver here - this should always be on the last release! "click>=6.2, <7", - "cryptography>=2.1.4,<2.2", + "cryptography>=2.1.4,<2.3", "h2>=3.0.1,<4", "hyperframe>=5.1.0,<6", "kaitaistruct>=0.7,<0.9", @@ -77,7 +77,7 @@ setup( "pyperclip>=1.6.0, <1.7", "ruamel.yaml>=0.13.2, <0.16", "sortedcontainers>=1.5.4, <1.6", - "tornado>=4.3, <4.6", + "tornado>=4.3,<5.1", "urwid>=2.0.1,<2.1", "wsproto>=0.11.0,<0.12.0", ], @@ -88,7 +88,7 @@ setup( 'dev': [ "flake8>=3.5, <3.6", "Flask>=0.10.1, <0.13", - "mypy>=0.570,<0.571", + "mypy>=0.580,<0.581", "pytest-cov>=2.5.1,<3", "pytest-faulthandler>=1.3.1,<2", "pytest-timeout>=1.2.1,<2", diff --git a/test/mitmproxy/addons/test_onboarding.py b/test/mitmproxy/addons/test_onboarding.py index 810ddef1..0d99b1ff 100644 --- a/test/mitmproxy/addons/test_onboarding.py +++ b/test/mitmproxy/addons/test_onboarding.py @@ -4,6 +4,10 @@ from mitmproxy.addons import onboarding from mitmproxy.test import taddons from .. import tservers +import asyncio +import tornado.platform.asyncio +asyncio.set_event_loop_policy(tornado.platform.asyncio.AnyThreadEventLoopPolicy()) + class TestApp(tservers.HTTPProxyTest): def addons(self): diff --git a/test/mitmproxy/test_connections.py b/test/mitmproxy/test_connections.py index 00cdbc87..845a9043 100644 --- a/test/mitmproxy/test_connections.py +++ b/test/mitmproxy/test_connections.py @@ -38,6 +38,9 @@ class TestClientConnection: assert 'ALPN' not in repr(c) assert 'TLS' in repr(c) + c.address = None + assert repr(c) + def test_tls_established_property(self): c = tflow.tclient_conn() c.tls_established = True @@ -110,6 +113,9 @@ class TestServerConnection: c.tls_established = False assert 'TLS' not in repr(c) + c.address = None + assert repr(c) + def test_tls_established_property(self): c = tflow.tserver_conn() c.tls_established = True diff --git a/test/mitmproxy/utils/test_human.py b/test/mitmproxy/utils/test_human.py index 947cfa4a..faf35f72 100644 --- a/test/mitmproxy/utils/test_human.py +++ b/test/mitmproxy/utils/test_human.py @@ -56,3 +56,4 @@ def test_format_address(): assert human.format_address(("example.com", "54010")) == "example.com:54010" assert human.format_address(("::", "8080")) == "*:8080" assert human.format_address(("0.0.0.0", "8080")) == "*:8080" + assert human.format_address(None) == "<no address>" |