Merge pull request #4337 from mhils/sans-io-adjustments

Sans-IO Adjustments
This commit is contained in:
Maximilian Hils 2020-12-11 11:10:56 +01:00 committed by GitHub
commit 39b0b6c110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 16 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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_*