simplify Server.sni, fix #4547 (#4660)

This commit is contained in:
Maximilian Hils 2021-06-24 17:03:35 +02:00 committed by GitHub
parent ad7f1d11e4
commit 53ca9dda90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -171,7 +171,7 @@ class TlsConfig:
else: else:
verify = net_tls.Verify.VERIFY_PEER verify = net_tls.Verify.VERIFY_PEER
if server.sni is True: if server.sni is None:
server.sni = client.sni or server.address[0] server.sni = client.sni or server.address[0]
if not server.alpn_offers: if not server.alpn_offers:

View File

@ -2,7 +2,7 @@ import uuid
import warnings import warnings
from abc import ABCMeta from abc import ABCMeta
from enum import Flag from enum import Flag
from typing import Literal, Optional, Sequence, Tuple, Union from typing import Optional, Sequence, Tuple
from mitmproxy import certs from mitmproxy import certs
from mitmproxy.coretypes import serializable from mitmproxy.coretypes import serializable
@ -85,10 +85,9 @@ class Connection(serializable.Serializable, metaclass=ABCMeta):
"""Ciphers accepted by the proxy server on this connection.""" """Ciphers accepted by the proxy server on this connection."""
tls_version: Optional[str] = None tls_version: Optional[str] = None
"""The active TLS version.""" """The active TLS version."""
sni: Union[str, Literal[True], None] sni: Optional[str] = None
""" """
The [Server Name Indication (SNI)](https://en.wikipedia.org/wiki/Server_Name_Indication) sent in the ClientHello. The [Server Name Indication (SNI)](https://en.wikipedia.org/wiki/Server_Name_Indication) sent in the ClientHello.
For server connections, this value may also be set to `True`, which means "use `Server.address`".
""" """
timestamp_start: Optional[float] timestamp_start: Optional[float]
@ -144,8 +143,6 @@ class Client(Connection):
""" """
The certificate used by mitmproxy to establish TLS with the client. The certificate used by mitmproxy to establish TLS with the client.
""" """
sni: Union[str, None] = None
"""The Server Name Indication sent by the client."""
timestamp_start: float timestamp_start: float
"""*Timestamp:* TCP SYN received""" """*Timestamp:* TCP SYN received"""
@ -272,7 +269,6 @@ class Server(Connection):
timestamp_tcp_setup: Optional[float] = None timestamp_tcp_setup: Optional[float] = None
"""*Timestamp:* TCP ACK received.""" """*Timestamp:* TCP ACK received."""
sni: Union[str, Literal[True], None] = True
via: Optional[server_spec.ServerSpec] = None via: Optional[server_spec.ServerSpec] = None
"""An optional proxy server specification via which the connection should be established.""" """An optional proxy server specification via which the connection should be established."""