Project Structure
Because there were so many shared elements between the server and client programs, I decided to restructure the project into a workspace with common, client, and server folders. In the common library I included the VpnEngine which handles the main connection between client and server and proxies requests. The code for client and server is so similar that it was easy to put it all into one VpnEngine.
NetworkConfigurator
I then made a trait in the common library called NetworkConfigurator which handles setting up and tearing down network rules like forwarding and NAT. The server and client programs define there own network configurators using that trait and implement their own custom setup and teardown. It also uses a Drop trait to ensure that teardown happens if the object is dropped.
Testing
Like before, I’m testing this on a single machine using Docker containers. I recently found out about the traceroute command and although I still don’t understand how it works, it did show that my client’s packets are being routed through the VPS. I attached an image below. 10.0.0.2 is the tun ip of the VPS btw (the client is 10.0.0.1). I executed traceroute on the client and it shows it routes through 10.0.0.2. Pretty cool :)
Next Steps
I still have to implement some more checks like for the nonce. After that I might actually test it for real but first I need to make it into a CLI tool. I’m thinking proxy connect <ip:port>, proxy disconnect, proxy serve. And maybe something like -d for detached. I don’t have a lot of time left though. I still intend to keep the docker setup so people don’t have to test the demo by exposing their computers to the internet. Which reminds me, I also need to find a better way to input the access key.