This is a fork of repository https://github.com/maxmcd/tcp-proxy adding proxy handling.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Darshil Chanpura bd8a1b8cd0 Added metrics endpoint 4 months ago
blocker Minor edits in block logic 4 months ago
docs Added docs and some minor improvements to code 10 months ago
README.md Added docs and some minor improvements to code 10 months ago
go.mod Added metrics endpoint 4 months ago
go.sum Added metrics endpoint 4 months ago
gokrazy.tar.gz Added example gokrazy.tar.gz 10 months ago
main.go Added metrics endpoint 4 months ago

README.md

Tun-Tana-Tun (टन-टन-टन)

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

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 net.Dialer using 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.

diagram