Coder Social home page Coder Social logo

miguelmota / streamhut Goto Github PK

View Code? Open in Web Editor NEW
899.0 16.0 38.0 26.83 MB

Stream your terminal to web without installing anything ๐ŸŒ

Home Page: https://streamhut.io

License: Apache License 2.0

Makefile 2.69% Dockerfile 0.76% Ruby 5.43% Go 91.12%
stream javascript real-time cli terminal websockets netcat telnet web terminal-share

streamhut's Introduction


logo


streamhut

Stream and send data, terminal to web and vice versa.

License Build Status Go Report Card GoDoc

Synopsis

  • Stream your terminal to anyone without installing anything.
  • Path names map to channels.
  • Anyone in the same channel can view what's streamed.
  • Easily self-host your own streamhut server.

Streamhut allows you to stream (pipe) realtime data from your terminal stdout/stderr to a web xterm UI or even to another terminal. It also allow you to quickly share data and files between devices.

As long as you have netcat which comes pre-installed in most *nix systems than you can use streamhut! If you can't install netcat, you may also use the streamhut CLI client.

โš ๏ธ Disclaimer: This software is alpha quality and not production ready. Use at your own risk!

Demo

https://streamhut.io

Demo

Getting Started (without installing anything)

One liner to stream your terminal:

$ exec &> >(nc stream.ht 1337)

The above command pipes stdout and stderr of new bash shell to streamhut.

Stream to a custom channel name:

$ exec &> >(nc stream.ht 1337);echo \#mychannel

Example of streaming tail of file:

# terminal 1
$ cat > data.txt
# terminal 2
$ tail -F data.txt | nc stream.ht 1337

Stream the current date every second:

$ while true; do date; sleep 1; done | nc stream.ht 1337

Stream output of a program (delay is required to see share url):

$ (sleep 5; htop) | nc stream.ht 1337
# waits 5 seconds, and then send contents of program.

Example of piping a program to both stdout and streamhut:

$ (echo -n; sleep 5; htop) | tee >(nc stream.ht 1337)

Don't have netcat available? Pipe to a file descriptor with an open TCP connection:

$ exec 3<>/dev/tcp/stream.ht/1337 && head -1 <&3 && exec &> >(tee >(cat >&3))

Install

$ go get github.com/streamhut/streamhut

CLI

Example of using streamhut CLI:

Stream to server

Piping commands:

$ htop | streamhut

Add delay to see share url:

$ htop | streamhut -d 5

Open url in browser:

$ htop | streamhut -o

Stream to different server:

$ htop | streamhut -h example.com -p 1337

Stream to custom channel:

$ htop | streamhut -c mychannel

For more options, run streamhut --help

Run your own server:

$ streamhut server

Starting server...
HTTP/WebSocket port: 8080
TCP port: 1337

Run server with SSL/TLS:

$ mkcert localhost

$ sudo streamhut server --tls --tls-cert=localhost.pem --tls-key=localhost-key.pem -p 443

For more options, run streamhut server --help

Connecting to a channel

# terminal 1
$ streamhut connect -c mychannel

For more options, run streamhut connect --help

Docker

You can run streamhut as a Docker container:

$ docker pull streamhut/streamhut
$ docker run -e PORT=8080 -e TCP_PORT=1337 -p 8080:8080 -p 1337:1337 --restart unless-stopped streamhut/streamhut:latest

Self-host (docker one-liner)

One-liner to self-host using Docker:

docker run -p 8080:8080 -p 1337:1337 streamhut/streamhut

Test

make test

Development

Start server:

make start

Run migrations:

make migrate

Web App

The web app source code is found on https://github.com/streamhut/web.

FAQ

  • Q: How is the stream log data stored?

    • A: Currently it's stored in a local sqlite3 database. You can disable storage with the --no-storage flag, e.g. streamhut server --no-storage.
  • Q: What happened to the streamhut NPM module?

  • Q: Can the same channel be used more than once?

    • A: Yes! send #{channel} (ie #mychannel) as the first stream text to use that channel.

      Example:

      exec &> >(nc stream.ht 1337);echo \#mychannel
  • Q: What's the difference between stream.ht and streamhut.io?

    • A: The domain stream.ht is an alias for streamhut.io, meaning you can type stream.ht as the domain for convenience. Other aliases are streamhut.net and streamhut.org.
  • Q: What is the difference between exec > >(nc stream.ht 1337) 2>&1 and exec &> >(nc stream.ht 1337)

    • A: They are the same in that they both stream stdout and stderr to the server.

License

Released under the Apache 2.0 license.

ยฉ Miguel Mota

streamhut's People

Contributors

angristan avatar lukaszlach avatar miguelmota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

streamhut's Issues

Options are not working

I can only get the binary to react to --help, but no of the other options work.

As stated in the docs, there should be a streamhut server --help option. But it only starts the server process on my Arch and an alpine-docker container I tried. Also the information I obtained from source code are not interpreted:
https://github.com/streamhut/streamhut/blob/78b537f31834b234deca19434a2f74ad73741346/cmd/streamhut/main.go#L132-L140

Since I barely know anything about Go, I cannot provide any more hints... If I can help out with testing, just drop a note.


Additional Infomation

Locally I tried the following commands (which result in a events.js:282: throw er; // Unhandled 'error' event because :9000 is in use on my host):

streamhut server --port 9247
streamhut server --port=9247
streamhut server -p 9247

streamhut -p 9247 server
streamhut --port 9247 server
streamhut --port=9247 server

If you'd like to try it your own, here is my minimized docker example:

FROM alpine:latest

RUN apk --no-cache add npm ruby python \
    && npm config set user 0 \
    && npm config set unsafe-perm true \
    && npm install -g streamhut

EXPOSE 1337 9000

CMD ["/usr/bin/streamhut","server","--share-base-url=https://foo.example.com/"]

Result: Server starts but provides wrong share base url.

Doesn't work for me!

I don't know what's wrong, but the command(s) doesn't work for me. I tried using zsh/bash on gnome terminal, but nothing is streamed to the given link. (Also nothing happens on my shell after running the command!).

Feedback

Please leave feedback for streamhut here!

Dockerfile does not build

Building of the supplied Dockerfile results in:

pkg/tcpserver/tcpserver.go:15:2: cannot find package "github.com/patrickmn/go-cache" in any of:
	/go/src/github.com/streamhut/streamhut/vendor/github.com/patrickmn/go-cache (vendor tree)
	/usr/local/go/src/github.com/patrickmn/go-cache (from $GOROOT)
	/go/src/github.com/patrickmn/go-cache (from $GOPATH)

Full Log at https://gist.github.com/boppy/ff44e290d663eda4c31d72dd015a571e

PowerShell support

I tried this in powershell and it didn't work, could you explain how I could get it to work with PowerShell?

Doesn't work / what am I doing wrong?

[browse@ashryn ~]$ while true; do date; sleep 1; done | nc stream.ht 1337
Thu Sep 10 08:17:46 PM EDT 2020
streamhut: streaming to https://stream.ht/ecjobt
Thu Sep 10 08:17:47 PM EDT 2020
Thu Sep 10 08:17:48 PM EDT 2020
Thu Sep 10 08:17:49 PM EDT 2020
Thu Sep 10 08:17:50 PM EDT 2020
Thu Sep 10 08:17:51 PM EDT 2020
Thu Sep 10 08:17:52 PM EDT 2020
Thu Sep 10 08:17:53 PM EDT 2020
Thu Sep 10 08:17:54 PM EDT 2020
^C
[browse@ashryn ~]$

but https://streamhut.io/s/ecjobt still shows

To get started, run in your terminal:

exec &> >(nc stream.ht 1337);echo \#ecjobt

I hope I am just doing something wrong, though -- ๐Ÿคฆ?

Troubles with nano

Hi! I tried to start stream and work in nano. So... for example ctrl+x doesn't work, scrolling via mouse does't work.

Roundtripping command outputs

The front page lists two commands:

  • exec > >(nc streamhut.io 1337) 2>&1
  • exec 3<>/dev/tcp/streamhut.io/1337 && head -1 <&3 && exec &> >(tee >(cat >&3))

However those work very differently, since the second one will only write to the socket (cat >&3) and duplicate the terminal output to the socket and terminal (tee), leaving streamhut's socket output on fd 3 (which doesn't go to the terminal), while the first one prints pipes all output through streamhut, relying on it printing back everything it gets.

This means that the first command:

  • introduces a noticeable delay
  • needs streamhut.io to send back everything it receives (wasting bandwidth)
  • it's technically possible for streamhut to subvert your command outputs (not just changing what's printed on the website, but changing what's printed to your terminal)

I'm not completely sure how to fix the command since exec 3<>(nc streamhut.io 1337) won't work ๐Ÿค”

Otherwise this app looks very nice! I was just surprised to see that those two commands, which are presented as equivalent (just the "no nc alternative") are in fact not (second is much better) and that the workings of the first one puts more demand on your infrastructure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.