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:
verify = net_tls.Verify.VERIFY_PEER
if server.sni is True:
if server.sni is None:
server.sni = client.sni or server.address[0]
if not server.alpn_offers:

View File

@ -2,7 +2,7 @@ import uuid
import warnings
from abc import ABCMeta
from enum import Flag
from typing import Literal, Optional, Sequence, Tuple, Union
from typing import Optional, Sequence, Tuple
from mitmproxy import certs
from mitmproxy.coretypes import serializable
@ -85,10 +85,9 @@ class Connection(serializable.Serializable, metaclass=ABCMeta):
"""Ciphers accepted by the proxy server on this connection."""
tls_version: Optional[str] = None
"""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.
For server connections, this value may also be set to `True`, which means "use `Server.address`".
"""
timestamp_start: Optional[float]
@ -144,8 +143,6 @@ class Client(Connection):
"""
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:* TCP SYN received"""
@ -272,7 +269,6 @@ class Server(Connection):
timestamp_tcp_setup: Optional[float] = None
"""*Timestamp:* TCP ACK received."""
sni: Union[str, Literal[True], None] = True
via: Optional[server_spec.ServerSpec] = None
"""An optional proxy server specification via which the connection should be established."""