diff --git a/mitmproxy/addons/proxyauth.py b/mitmproxy/addons/proxyauth.py index e5e4f42f9..b10f4eed2 100644 --- a/mitmproxy/addons/proxyauth.py +++ b/mitmproxy/addons/proxyauth.py @@ -1,18 +1,18 @@ import binascii import weakref -import ldap3 +from typing import MutableMapping from typing import Optional -from typing import MutableMapping # noqa from typing import Tuple +import ldap3 import passlib.apache import mitmproxy.net.http -from mitmproxy import connections # noqa +from mitmproxy import ctx from mitmproxy import exceptions from mitmproxy import http -from mitmproxy import ctx from mitmproxy.net.http import status_codes +from mitmproxy.utils import compat REALM = "mitmproxy" @@ -49,7 +49,7 @@ class ProxyAuth: self.singleuser = None self.ldapconn = None self.ldapserver = None - self.authenticated: MutableMapping[connections.ClientConnection, Tuple[str, str]] = weakref.WeakKeyDictionary() + self.authenticated: MutableMapping[compat.Client, Tuple[str, str]] = weakref.WeakKeyDictionary() """Contains all connections that are permanently authenticated after an HTTP CONNECT""" def load(self, loader): diff --git a/mitmproxy/tools/console/flowdetailview.py b/mitmproxy/tools/console/flowdetailview.py index d89078010..b61f2476a 100644 --- a/mitmproxy/tools/console/flowdetailview.py +++ b/mitmproxy/tools/console/flowdetailview.py @@ -50,7 +50,7 @@ def flowdetails(state, flow: mitmproxy.flow.Flow): if resp: parts.append(("HTTP Version", resp.http_version)) if sc.alpn_proto_negotiated: - parts.append(("ALPN", sc.alpn_proto_negotiated)) + parts.append(("ALPN", strutils.bytes_to_escaped_str(sc.alpn_proto_negotiated))) text.extend( common.format_keyvals(parts, indent=4) @@ -113,11 +113,12 @@ def flowdetails(state, flow: mitmproxy.flow.Flow): if cc.tls_version: parts.append(("TLS Version", cc.tls_version)) if cc.sni: - parts.append(("Server Name Indication", cc.sni)) + parts.append(("Server Name Indication", + strutils.bytes_to_escaped_str(strutils.always_bytes(cc.sni, "idna")))) if cc.cipher_name: parts.append(("Cipher Name", cc.cipher_name)) if cc.alpn_proto_negotiated: - parts.append(("ALPN", cc.alpn_proto_negotiated)) + parts.append(("ALPN", strutils.bytes_to_escaped_str(cc.alpn_proto_negotiated))) text.extend( common.format_keyvals(parts, indent=4) diff --git a/mitmproxy/utils/compat.py b/mitmproxy/utils/compat.py index 6397dcdea..cce49e435 100644 --- a/mitmproxy/utils/compat.py +++ b/mitmproxy/utils/compat.py @@ -4,10 +4,10 @@ new_proxy_core = False if new_proxy_core: # pragma: no cover from mitmproxy.proxy2 import context - Client = context.Client - Server = context.Server + Client = context.Client # type: ignore + Server = context.Server # type: ignore else: # pragma: no cover from mitmproxy import connections - Client = connections.ClientConnection - Server = connections.ServerConnection + Client = connections.ClientConnection # type: ignore + Server = connections.ServerConnection # type: ignore diff --git a/tox.ini b/tox.ini index acae7ce11..2563fbb42 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ commands = [testenv:flake8] deps = flake8==3.8.4 commands = - flake8 --jobs 8 mitmproxy pathod examples test release + flake8 --jobs 8 mitmproxy pathod examples test release {posargs} [testenv:filename_matching] commands = @@ -26,18 +26,18 @@ commands = [testenv:mypy] deps = mypy==0.782 commands = - mypy . + mypy . {posargs} [testenv:rstcheck] deps = rstcheck>=2.2,<4.0 commands = - rstcheck README.rst + rstcheck README.rst {posargs} [testenv:individual_coverage] deps = -rrequirements.txt commands = - python ./test/individual_coverage.py + python ./test/individual_coverage.py {posargs} [testenv:cibuild] passenv = CI_* GITHUB_* AWS_* TWINE_* DOCKER_*