GithubHelp home page GithubHelp logo

rbino / live_bin Goto Github PK

View Code? Open in Web Editor NEW
34.0 4.0 3.0 260 KB

A self-hostable request bin that doesn't get in your way, powered by Phoenix LiveView

Home Page: https://liveb.in

Elixir 68.81% CSS 18.77% JavaScript 6.88% HTML 1.75% Dockerfile 3.60% Shell 0.11% Batchfile 0.07%
elixir phoenix liveview postbin requestbin

live_bin's Introduction

LiveBin

LiveBin is a simple tool used to inspect HTTP requests.

It tries not to get in your way, it doesn't parse the body or do other fancy stuff with your request. This way you see exactly what was sent. The idea is basically having the same output you would get by doing HTTP requests to a listening instance of netcat.

Under the hood it uses the super cool Phoenix Live View, so new requests are prepended at the top of the page without the need of refreshing.

You can visit liveb.in to try it live.

Running your instance (with Docker)

You can run your instance using the Docker image

export SECRET_KEY_BASE=$(mix phx.gen.secret)
# or `openssl rand -base64 48` if you don't have phx generators installed
docker run -e SECRET_KEY_BASE -p 4000:4000 rbino/live_bin:0.3.0

Now you can visit localhost:4000 from your browser.

Additional environment variables

live_bin accepts these additional environment variables, that you can pass with -e to docker run:

  • PORT: the listening port, that will have to be exposed from the container. Defaults to 4000.
  • PHX_HOST: base host (e.g. example.com) where live_bin is served. Needed to make websockets work and to correctly generate links. Defaults to example.com.
  • LIVE_BIN_INACTIVITY_TIMEOUT: the timeout after which a bin will be deleted if there's no activity on it, in milliseconds. Defaults to infinity.
  • LIVE_BIN_MAX_REQUESTS: the max number of requests that a bin can receive before being deleted. Defaults to nil, which means unlimited.
  • LIVE_BIN_USE_BIN_SUBDOMAINS: if true, generates request URLs appear as <bin_id>.<host> instead of <host>/r/<bin_id>. This just changes the way URLs are generated, to make it work, the reverse proxy must perform the appropriate URL rewriting (taking <bin_id> from the subdomain and putting it in the path).

nginx configuration example

In priv/examples/nginx-example.conf you can find a sample nginx conf to serve as reverse proxy for live_bin, with bin subdomains support. You should just be able to replace live_b.in with your URL and, after obtaining SSL certificates, you should be good to go.

Developing and building

You can run your local instance (to test modifications) simply with:

$ mix deps.get
$ npm install --prefix assets
$ iex -S mix phx.server

Alternatively, you can also rebuild the Docker image with:

$ docker build .

License

Copyright (c) 2019-2022 Riccardo Binetti [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

live_bin's People

Contributors

rbino 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

Watchers

 avatar  avatar  avatar  avatar

live_bin's Issues

Allow passing a memory limit for bins

Currently the only variables controlling a bin lifetime are LIVE_BIN_INACTIVITY_TIMEOUT and LIVE_BIN_MAX_REQUESTS. Those two don't protect from the fact that a bin could receive very big requests, possibly bringing down the whole BEAM if it gets killed by the OOM.

Another env variable must be added to handle this, allowing to set the max number of bytes a bin can receive

Reverse the display order of the requests and add auto-follow

Right now requests are appended on the top. This makes it easy to see new requests, but it's also an hassle if the user is looking at a request in the middle since a new request scrolls everything. The issue is even worse if there's a constant stream of incoming requests.

The proposed new mechanism is this:

  • New requests are appended at the end of the list
  • As soon as the list has to be scrolled, the view automatically follows new incoming request
  • If the user manually scrolls up, auto-follow is disabled
  • A button is shown to indicate new incoming requests, and if clicked it scrolls to the bottom and resumes auto-follow

Cant build container image

Greetings,

i was trying to build your project but couldn't find a setup instructions for it, so i tried to build your container image (docker build .) resulting in the following error:

 => ERROR [builder 13/17] RUN mix assets.deploy                                                                                                                                                                                                                                                                    4.1s
------
 > [builder 13/17] RUN mix assets.deploy:
#0 1.025 
#0 1.025 20:02:42.347 [debug] Downloading tailwind from https://github.com/tailwindlabs/tailwindcss/releases/download/v3.0.23/tailwindcss-linux-x64
#0 3.029 Browserslist: caniuse-lite is outdated. Please run:
#0 3.029   npx browserslist@latest --update-db
#0 3.029   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
#0 3.471 
#0 3.471 Done in 298ms.
#0 3.485 
#0 3.485 20:02:44.810 [debug] Downloading esbuild from https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.0.tgz
#0 3.819  > js/app.js:24:7: error: Could not resolve "@github/clipboard-copy-element" (mark it as external to exclude it from the bundle)
#0 3.819     24 │ import '@github/clipboard-copy-element'
#0 3.819        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#0 3.819 
#0 3.828 1 error
#0 3.835 ** (Mix) `mix esbuild default --minify` exited with 1
------
Dockerfile:54
--------------------
  52 |     
  53 |     # compile assets
  54 | >>> RUN mix assets.deploy
  55 |     
  56 |     # Compile the release
--------------------
ERROR: failed to solve: process "/bin/sh -c mix assets.deploy" did not complete successfully: exit code: 1

Did i miss something?

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.