(self, packet)
| 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 | |
| 343 | TConnection = tuple[str, int] |
no test coverage detected