mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-27 07:10:51 +00:00
Fix server addr issue in tls_passthrough example. (#5904)
* fix server peername is None issue peername would be None, we should use other not None property as key. * Update tls_passthrough.py --------- Co-authored-by: Maximilian Hils <github@maximilianhils.com>
This commit is contained in:
parent
b9f3574728
commit
430833e3d9
@ -2,6 +2,9 @@
|
||||
|
||||
## Unreleased: mitmproxy next
|
||||
|
||||
* Fix a bug where peername would be None in tls_passthrough script, which would make it not working.
|
||||
([#5904](https://github.com/mitmproxy/mitmproxy/pull/5904), @truebit)
|
||||
|
||||
* Add experimental QUIC support.
|
||||
([#5435](https://github.com/mitmproxy/mitmproxy/issues/5435), @meitinger)
|
||||
* ASGI/WSGI apps can now listen on all ports for a specific hostname.
|
||||
|
@ -95,22 +95,27 @@ class MaybeTls:
|
||||
else:
|
||||
self.strategy = ConservativeStrategy()
|
||||
|
||||
@staticmethod
|
||||
def get_addr(server: connection.Server):
|
||||
# .peername may be unset in upstream proxy mode, so we need a fallback.
|
||||
return server.peername or server.address
|
||||
|
||||
def tls_clienthello(self, data: tls.ClientHelloData):
|
||||
server_address = data.context.server.peername
|
||||
server_address = self.get_addr(data.context.server)
|
||||
if not self.strategy.should_intercept(server_address):
|
||||
logging.info(f"TLS passthrough: {human.format_address(server_address)}.")
|
||||
data.ignore_connection = True
|
||||
self.strategy.record_skipped(server_address)
|
||||
|
||||
def tls_established_client(self, data: tls.TlsData):
|
||||
server_address = data.context.server.peername
|
||||
server_address = self.get_addr(data.context.server)
|
||||
logging.info(
|
||||
f"TLS handshake successful: {human.format_address(server_address)}"
|
||||
)
|
||||
self.strategy.record_success(server_address)
|
||||
|
||||
def tls_failed_client(self, data: tls.TlsData):
|
||||
server_address = data.context.server.peername
|
||||
server_address = self.get_addr(data.context.server)
|
||||
logging.info(f"TLS handshake failed: {human.format_address(server_address)}")
|
||||
self.strategy.record_failure(server_address)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user