Stars: 132
Forks: 7
Pull Requests: 5
Issues: 0
Watchers: 8
Last Updated: 2023-02-11 18:37:26
:electric_plug: Turn any STDIN/STDOUT into HTTP server
License: Other
Languages: PHP
stdinho
is small command-line tool that creates TCP server, accepts any STDOUT as its STDIN and whoever connects to the server will get this data served as HTTP response.
It was written from frustration of having to share remote resources with my under-priviliged colleagues on semi-regular basis. This typically involves downloading file, uploading file, sending the link, waiting until target finishes downloading file, deleting file. In each stage of the process you would normally have to wait.
Via Composer
composer global require ostrolucky/stdinho
Or grab executable PHAR file from Releases
As simple as just piping some data in:
echo hello world|stdinho
For all options see
stdinho --help
# Server
$ stdinho 0.0.0.0:1337 < /file/to/a/movie.mp4
# Client
$ firefox http://127.0.0.1:1337
# Server
# Server (broadcaster)
$ { while read a; do echo $a; done }|bin/stdinho 127.0.0.1:1337
# Client
curl 127.0.0.1:1337
# Server
$ tail -f project/var/log/*.log|stdinho 0.0.0.0:1337
# Client
$ curl 127.0.0.1:1337
# Bonus: gzip transfer encoding (server)
$ tail -f project/var/*.log|gzip -c|stdinho 0.0.0.0:1337 --http-headers='["Content-Type: text/plain", "Content-Encoding: gzip", "Transfer-Encoding: gzip"]'
# Server
$ zip -qr - project|stdinho 0.0.0.0:1337 -f project.zip
# Client
$ curl 127.0.0.1:1337 -o project.zip # Saves it to project.zip
# Server
$ ssh [email protected] "mysqldump -u root -ptoor database|gzip -c"|stdinho 0.0.0.0:1337 -f "$(date).sql.gz" # also saves the backup locally
# Client
$ curl 127.0.0.1:1337|gunzip|mysql -u root -ptoor database # Import it directly to local DB
# There is bad connectivity between A (public server) and B (user connected to network via special VPN),
# but good connectivity between A and C (on same local network as A, but not public).
# However, B and C are behind NAT in separate networks, so there is no direct connection between them.
# Here D is introduced, which is public server having good connection to both C and B, but no connection to A.
# In final, download stream goes like this: A -> C -> D -> B which bypasses connection problem between A and B and NAT issue at the same time
# This problem is basically animation shown in introduction of this README.
# C:
$ ssh -NR \*:1337:localhost:1337 D #Reverse tunnel. Note: GatewayPorts cannot be set to "no" in D's sshd_config
$ curl http://A.com/big_file.tar.gz|stdinho 0.0.0.0:1337
# B:
$ curl D:1337 -o big_file.tar.gz
GPLv3 license. Please see License File for more information.