2017 © Pedro Peláez
 

project stdinho

Open HTTP portal to your standard input stream

image

ostrolucky/stdinho

Open HTTP portal to your standard input stream

  • Sunday, May 13, 2018
  • by ostrolucky
  • Repository
  • 3 Watchers
  • 89 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

stdinho

Latest Version on Packagist ![Software License][ico-license] Build Status, (*1)

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., (*2)

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., (*3)

Diagram below compares the usual approach from above (having to wait in each stage) vs. streaming approach stdinho provides., (*4)

stdinho animation, (*5)

Install

Via Composer, (*6)

composer global require ostrolucky/stdinho

Or grab executable PHAR file from Releases, (*7)

Usage

As simple as just piping some data in:, (*8)

echo hello world|stdinho

For all options see, (*9)

stdinho --help

Features

  • async. Yep, in PHP. No restriction on clients downloading simultaneusly
  • buffers to temp file before client is connected, so no time or data in between is lost
  • cross-platform: Linux/MacOS/Windows
  • detects MIME type and attaches it to HTTP response
  • neat progress bar showing status of buffering and client downloads.

Examples

Video streaming
, (*10)

```bash # Server $ stdinho 0.0.0.0:1337 , (*11)

Simple one-way chat
, (*12)

```bash # Server # Server (broadcaster) $ { while read a; do echo $a; done }|bin/stdinho 127.0.0.1:1337 # Client curl 127.0.0.1:1337 ``` , (*13)

Tail application logs in realtime
, (*14)

```bash # 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"]' ``` , (*15)

Stream a folder, including compression
, (*16)

```bash # 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 ``` , (*17)

Dump remote database and stream it to different database on the fly via middle man
, (*18)

```bash # Server $ ssh admin@example.com "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 ``` , (*19)

Use case from GIF in this README
, (*20)

```bash # 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 ``` , (*21)

, (*22)

Licensing

GPLv3 license. Please see License File for more information., (*23)

The Versions

13/05 2018

dev-master

9999999-dev

Open HTTP portal to your standard input stream

  Sources   Download

GPL-3.0

The Requires

 

by Gabriel Ostrolucký

12/05 2018

0.2.1

0.2.1.0

Open HTTP portal to your standard input stream

  Sources   Download

GPL-3.0

The Requires

 

by Gabriel Ostrolucký

12/05 2018

0.2

0.2.0.0

Open HTTP portal to your standard input stream

  Sources   Download

GPL-3.0

The Requires

 

by Gabriel Ostrolucký

11/03 2018

0.1

0.1.0.0

Open HTTP portal to your standard input stream

  Sources   Download

GPL-3.0

The Requires

 

by Gabriel Ostrolucký