If the proxy responds to the client, let the client believe the target server sent the packets.
(self, packet: pydivert.Packet)
| 518 | self.response.windivert.send(packet) |
| 519 | |
| 520 | def redirect_response(self, packet: pydivert.Packet): |
| 521 | """ |
| 522 | If the proxy responds to the client, let the client believe the target server sent the |
| 523 | packets. |
| 524 | """ |
| 525 | # print(" * Adjust proxy -> client") |
| 526 | client = (packet.dst_addr, packet.dst_port) |
| 527 | try: |
| 528 | packet.src_addr, packet.src_port = self.client_server_map[client] |
| 529 | except KeyError: |
| 530 | print(f"Warning: Previously unseen connection from proxy to {client}") |
| 531 | else: |
| 532 | packet.recalculate_checksums() |
| 533 | |
| 534 | self.response.windivert.send(packet, recalculate_checksum=False) |
| 535 | |
| 536 | @contextlib.contextmanager |
| 537 | def exempt(self, pid: int): |