port=<port> # Choose your local port that your server will listen to
file=<filename> # Choose file where <subdomain.localhost.run> will be stored
# Create tunnel in background
ssh -n -R 80:localhost:$port [email protected] -- --output json --no-inject-http-proxy-headers --no-inject-proxy-protocol-header 2>/dev/null | jq --unbuffered -r '.address' > ${file} &
# Pass the contents of $file to client
cat <(echo -e "HTTP/1.1 200 OK\r\n") - | nc -l $port
Pubsub is when authenticated/priviledged user(s) publish(es) and unauthenticated users subscribe. In reverse pubsub, unautheticated users publish and authenticated/priviledged user subscribes.
echo -e "HTTP/1.1 200 OK\r\n" | nc -l $port
hostname=<as sent by server> # Server is supposed to send client subdomain.localhost.run
curl -sf -o - -T . $hostname
# Or, you may also use nc to the same effect as follows. Note the use of CRLF instead of LF
cat <(echo -e "GET / HTTP/1.1\r\nHost:$hostname\r\n") - | nc -N $hostname 80
Note: Free port-forwarding at localhost.run times out at 1 hour. Then, both curl
and nc
will terminate. In case curl
can't connect to subdomain.localhost.run because the server's tunnel has timed-out, curl
will exit with non-zero exit-code (22) by virtue of the -f
option.