This is a basic service to workaround a limitation in Tailscale Funnel. Basically I wanted to expose a Minecraft server to play with the boys but Minecraft doesn’t support TCP over TLS sockets.
GetFreePort is inherently racy and not a pattern you should copy. It’s better to just pass 0 to listen and then get the socket’s local address if you need to know it.
Like stunnel?
socat can do this too, using an
OPENSSL
address on one side.It doesn’t listen a TLS socket.
It connects to a TLS socket and reexpose as a unencrypted TCP socket on localhost
Stunnel can be either a client or a server: https://gist.github.com/ohpe/e02596a2c2247ea1a212e019c355e2c3
GetFreePort
is inherently racy and not a pattern you should copy. It’s better to just pass 0 to listen and then get the socket’s local address if you need to know it.I have a small suggestion. You may want to use a
bytes.Buffer
here where you callReset
after acquiring one from the pool.Thanks for sharing!