MCPcopy
hub / github.com/mitmproxy/mitmproxy / Client

Class Client

mitmproxy/connection.py:175–259  ·  view source on GitHub ↗

A connection between a client and mitmproxy.

Source from the content-addressed store, hash-verified

173
174@dataclass(eq=False, repr=False, kw_only=True)
175class Client(Connection): # type: ignore[override]
176 """A connection between a client and mitmproxy."""
177
178 peername: Address
179 """The client's address."""
180 sockname: Address
181 """The local address we received this connection on."""
182
183 mitmcert: certs.Cert | None = None
184 """
185 The certificate used by mitmproxy to establish TLS with the client.
186 """
187
188 proxy_mode: mode_specs.ProxyMode = field(
189 default=mode_specs.ProxyMode.parse("regular")
190 )
191 """The proxy server type this client has been connecting to."""
192
193 timestamp_start: float = field(default_factory=time.time)
194 """*Timestamp:* TCP SYN received"""
195
196 def __str__(self):
197 if self.alpn:
198 tls_state = f", alpn={self.alpn.decode(errors='replace')}"
199 elif self.tls_established:
200 tls_state = ", tls"
201 else:
202 tls_state = ""
203 state = self.state.name
204 assert state
205 return f"Client({human.format_address(self.peername)}, state={state.lower()}{tls_state})"
206
207 @property
208 def address(self): # pragma: no cover
209 """*Deprecated:* An outdated alias for Client.peername."""
210 warnings.warn(
211 "Client.address is deprecated, use Client.peername instead.",
212 DeprecationWarning,
213 stacklevel=2,
214 )
215 return self.peername
216
217 @address.setter
218 def address(self, x): # pragma: no cover
219 warnings.warn(
220 "Client.address is deprecated, use Client.peername instead.",
221 DeprecationWarning,
222 stacklevel=2,
223 )
224 self.peername = x
225
226 @property
227 def cipher_name(self) -> str | None: # pragma: no cover
228 """*Deprecated:* An outdated alias for Connection.cipher."""
229 warnings.warn(
230 "Client.cipher_name is deprecated, use Client.cipher instead.",
231 DeprecationWarning,
232 stacklevel=2,

Callers 9

test_basicMethod · 0.90
test_basicMethod · 0.90
test_upstream_httpsFunction · 0.90
test_next_layerMethod · 0.90
test_next_layerFunction · 0.90
__init__Method · 0.90

Calls 1

parseMethod · 0.45

Tested by 7

test_basicMethod · 0.72
test_basicMethod · 0.72
test_upstream_httpsFunction · 0.72
test_next_layerMethod · 0.72
test_next_layerFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…