MCPcopy
hub / github.com/mitmproxy/mitmproxy / handle

Method handle

mitmproxy/platform/windows.py:325–340  ·  view source on GitHub ↗
(self, packet)

Source from the content-addressed store, hash-verified

323 super().__init__(self.handle, filter)
324
325 def handle(self, packet):
326 client = (packet.src_addr, packet.src_port)
327
328 if client not in self.tcp_connections:
329 self.tcp_connections.refresh()
330
331 # If this fails, we most likely have a connection from an external client.
332 # In this, case we always want to proxy the request.
333 pid = self.tcp_connections.get(client, None)
334
335 if pid not in self.trusted_pids:
336 self.redirect_request(packet)
337 else:
338 # It's not really clear why we need to recalculate the checksum here,
339 # but this was identified as necessary in https://github.com/mitmproxy/mitmproxy/pull/3174.
340 self.windivert.send(packet, recalculate_checksum=True)
341
342
343TConnection = tuple[str, int]

Callers 1

runMethod · 0.45

Calls 4

redirect_requestMethod · 0.80
refreshMethod · 0.45
getMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected