Python PPPTP library (or another way to reroute traffic through process)

357 Views Asked by At

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:

  1. Traffic destined for the default route is routed out the ppp tunnel interface (endpoint is localhost:P1)
  2. Process listening on localhost:p1 gets a packet.
  3. Process listening on localhost:p1 uses a previously established socket with server1 listening on p2 to send data.
  4. Process listening on localhost sends data over socket to server1:p2
  5. 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?

0

There are 0 best solutions below