ProductPromotion
Logo

Open.Source

made by https://0x3d.site

GitHub - matze/wastebin: wastebin is a pastebin 📝
wastebin is a pastebin 📝. Contribute to matze/wastebin development by creating an account on GitHub.
Visit Site

GitHub - matze/wastebin: wastebin is a pastebin 📝

GitHub - matze/wastebin: wastebin is a pastebin 📝

wastebin

Rust

A minimal pastebin with a design shamelessly copied from bin.

Features

  • axum and sqlite3 backend storing compressed paste data
  • single binary with low memory footprint
  • drag 'n' drop upload
  • deletion after expiration, reading or by owners
  • light/dark mode according to browser settings
  • highlightable line numbers
  • QR code to browse a paste's URL on mobile devices
  • optional encryption with argon2 hashing and ChaCha20Poly1305 encryption

Installation

Build from source

Install a Rust 2021 toolchain containing Rust 1.70 with rustup and run the server binary with

$ cargo run --release

Run pre-built binaries

You can also download pre-built, statically compiled Linux binaries. After extraction run the contained wastebin binary.

Build a container image

It's possible to build a container image using Docker or Podman. Assuming you're in the root directory of repository run

$ sudo docker build -t wastebin:v2.4.3 -f Dockerfile .

for Docker or

$ podman build -t wastebin:v2.4.3 -f Dockerfile

for Podman.

To cross-compile, make sure that your container engine of choice supports it, e.g. Docker:

$ sudo docker buildx ls
NAME/NODE     DRIVER/ENDPOINT   STATUS    BUILDKIT   PLATFORMS
default*      docker
 \_ default    \_ default       running   v0.14.1    linux/amd64, linux/amd64/v2, linux/386, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/mips64le, linux/mips64, linux/loong64, linux/arm/v7, linux/arm/v6

To build an arm64 image on an x86_64 host run

$ sudo docker build --platform linux/arm64 -t wastebin:v2.4.3-arm64 -f Dockerfile.arm .

or

$ podman build --arch=arm64 -t wastebin:v2.4.3-arm64 -f Dockerfile.arm

Run a Docker image

Alternatively, you can run a pre-built Docker image pushed to quxfoo/wastebin. Here is how to persist the database as state.db via the WASTEBIN_DATABASE_PATH environment variable and a bind mount to /path/for/storage:

$ docker run -e WASTEBIN_DATABASE_PATH=/data/state.db -v /path/for/storage:/data quxfoo/wastebin:latest

NOTE: The image is based on scratch which means it neither comes with a shell nor with TMPDIR being set. If database migrations fail with an extended sqlite error code 6410, pass TMPDIR pointing to a location, sqlite can write to.

Run with docker-compose

version: '3.3'
services:
  wastebin:
    environment:
      - WASTEBIN_DATABASE_PATH=/data/state.db
    ports:
      - "8088:8088"
    volumes:
      - './data:/data'
    image: 'quxfoo/wastebin:latest'

Make sure the ./data folder is writable by the user 10001.

Run with Nix

For Nix users, a flake.nix is also provided. Build and execute it directly with:

nix run 'github:matze/wastebin#wastebin'

Or install the provided wastebin package like you normally would.

Usage

Browser interface

When viewing a paste, you can use

  • r to view the raw paste,
  • n to go the index page,
  • y to copy the current URL to the clipboard,
  • q to display the current URL as a QR code and
  • p to view the formatted paste,
  • ? to view the list of keybindings.

To paste some text you can also use the ctrl+s key combination.

Configuration

The following environment variables can be set to configure the server and run-time behavior:

  • WASTEBIN_ADDRESS_PORT string that determines which address and port to bind a. If not set, it binds by default to 0.0.0.0:8088.
  • WASTEBIN_BASE_URL string that determines the base URL for the QR code display. If not set, the user agent's Host header field is used as an approximation.
  • WASTEBIN_CACHE_SIZE number of rendered syntax highlight items to cache. Defaults to 128 and can be disabled by setting to 0.
  • WASTEBIN_DATABASE_PATH path to the sqlite3 database file. If not set, an in-memory database is used.
  • WASTEBIN_HTTP_TIMEOUT maximum number of seconds a request can be processed until wastebin responds with 408, by default it is set to 5 seconds.
  • WASTEBIN_MAX_BODY_SIZE number of bytes to accept for POST requests. Defaults to 1 MB.
  • WASTEBIN_MAX_PASTE_EXPIRATION maximum allowed lifetime of a paste in seconds. Defaults to 0 meaning unlimited.
  • WASTEBIN_PASSWORD_SALT salt used to hash user passwords used for encrypting pastes.
  • WASTEBIN_SIGNING_KEY sets the key to sign cookies. If not set, a random key will be generated which means cookies will become invalid after restarts and paste creators will not be able to delete their pastes anymore.
  • WASTEBIN_TITLE overrides the HTML page title. Defaults to wastebin.
  • RUST_LOG influences logging. Besides the typical trace, debug, info etc. keys, you can also set the tower_http key to some log level to get additional information request and response logs.

API endpoints

POST a new paste to the / endpoint with the following JSON payload:

{
  "text": "<paste content>",
  "extension": "<file extension, optional>",
  "expires": <number of seconds from now, optional>,
  "burn_after_reading": <true/false, optional>
}

After successful insertion, you will receive a JSON response with the path to the newly created paste:

{"path":"/Ibv9Fa.rs"}

To retrieve the raw content, make a GET request on the /:id route and an accept header value that does not include text/html. If you use a client that is able to handle cookies you can delete the paste once again using the cookie in the Set-Cookie header set during redirect after creation.

In case the paste was encrypted, pass the password via the Wastebin-Password header.

Paste from neovim

Use the wastebin.nvim plugin and paste the current buffer or selection with :WastePaste.

Paste from clipboard

We can use the API POST endpoint to paste clipboard data easily from the command line using xclip, curl and jq. Define the following function in your .bashrc and you are good to go:

function paste_from_clipboard() {
    local URL=$(\
        jq -n --arg t "$(xclip -selection clipboard -o)" '{text: $t}' | \
            curl -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld | \
            jq -r '. | "https://wastebin.tld\(.path)"')

    xdg-open $URL
}

Paste from stdin

To paste from stdin use the following function in your .bashrc:

function paste_from_stdin() {
    jq -Rns '{text: inputs}' | \
        curl  -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld | \
        jq -r '. | "wastebin.tld\(.path)"'
}

It can be handy for creating pastes from logs or the output of commands, e.g. cat file.log | paste_from_stdin.

License

MIT

Articles
to learn more about the open-source concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Open-Source.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory