MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / dtls_parse_client_hello

Function dtls_parse_client_hello

mitmproxy/proxy/layers/tls.py:139–158  ·  view source on GitHub ↗

Check if the supplied bytes contain a full ClientHello message, and if so, parse it. Returns: - A ClientHello object on success - None, if the TLS record is not complete Raises: - A ValueError, if the passed ClientHello is invalid

(data: bytes)

Source from the content-addressed store, hash-verified

137
138
139def dtls_parse_client_hello(data: bytes) -> ClientHello | None:
140 """
141 Check if the supplied bytes contain a full ClientHello message,
142 and if so, parse it.
143
144 Returns:
145 - A ClientHello object on success
146 - None, if the TLS record is not complete
147
148 Raises:
149 - A ValueError, if the passed ClientHello is invalid
150 """
151 # Check if ClientHello is complete
152 client_hello = get_dtls_client_hello(data)
153 if client_hello:
154 try:
155 return ClientHello(client_hello[12:], dtls=True)
156 except EOFError as e:
157 raise ValueError("Invalid ClientHello") from e
158 return None
159
160
161HTTP1_ALPNS = (b"http/1.1", b"http/1.0", b"http/0.9")

Callers 2

_get_client_helloMethod · 0.90

Calls 2

ClientHelloClass · 0.90
get_dtls_client_helloFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…