I have a process that listens for traffic on a certain port, and performs some manipulation before sending it on its way to a specific server. I would like to redirect all traffic through this process. Since I do not know of a way to send traffic to a port I was thinking I could establish a PPPTP server on localhost, listen for traffic, then send it on it's way. The user would have to create a VPN with the destination being localhost:P1. The flow would be as follows:
- Traffic destined for the default route is routed out the ppp tunnel interface (endpoint is localhost:P1)
- Process listening on localhost:p1 gets a packet.
- Process listening on localhost:p1 uses a previously established socket with server1 listening on p2 to send data.
- Process listening on localhost sends data over socket to server1:p2
- Response flows in reverse
I could accomplish this using a PPPTP library for Python if anyone knows of any library. Is there a better way to accomplish this?