|Darshil Chanpura bd8a1b8cd0|
This project is a simple TCP Proxy allows bring remote ports listening on localhost.
This main reason why this project exists is to be used with gokrazy on Raspberry Pi.
Usage of tuntanatun: -debug Enable Logs -local string Local Address (default "localhost:9999") -remote string Remote Address (default "localhost:80")
A simple use case
By using gokrazy there are challenges in creating a network interface and running Tailscale on it, so we use userspace networking mode of Tailscale.
There are work-arounds in accessing the peers using HTTP_PROXY variable, like most of the HTTP Requests can use this variable and proxy it through, the problem comes when there is a need to connect to a port with non-HTTP like connecting to a Database.
The simple solution is to use
SOCKS proxy, which allows all traffic to be proxied, and fortunately
tailscaled allows setting a
SOCKS5 proxy listener/server through command line arguments.
Now we can try to connect to the desired service/server in VPN, but alas, there's one more problem.
To use this proxy the program should respect the proxy variable like
ALL_PROXY, we know
HTTP_PROXY is always used for any
net/http functions but as this
SOCKS proxy implementation is not yet in standard library normal packages don't use it.
One option is to change the service code to use this proxy implementation, which is simply a change in
proxy.FromEnvironment(). Which requires changes in possibly everything and building again.
Another option is to bring that port, from remote server to
localhost. This is also called tunneling, or port forwarding. We use a local port and connect to remote host:port and proxy it.
Following diagram shows this in action.