Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wastebin is a pastebin 📝

License

NotificationsYou must be signed in to change notification settings

matze/wastebin

Repository files navigation

wastebin

Rust

A minimal pastebin with a design shamelessly copied frombin.

DEMO (resets every day)

You are reading the documentation for anunreleased version. You can referto released versions here:

3.4.03.3.03.2.03.1.03.0.02.7.1

Features

  • axum andsqlite3 backend
  • comes as a single binary with low memory footprint
  • compresses pastes usingzstd
  • syntax highlighting for > 170 languages withsyntect
  • comes witheight color themes in light and dark mode
  • encrypts entries using ChaCha20Poly1305 and argon2 hashed passwords
  • allows deletion after expiration, after reading or by anonymous owners
  • shows QR code to browse a paste's URL on mobile devices

Non-features

  • user authentication and admin functionality
  • arbitrary file uploads
  • mitigations for all kinds of DoS attack vectors

Caution

Due to lack of authentication and further DoS mitigations, it is not advisedto run wastebin facing the internetas is. If you plan to do so, you arestrongly advised to rate limit inbound requests via iptables rules or aproperly configured reverse proxy of your choice.

Installation

Run pre-built binaries

You can download pre-built, statically compiledLinux and MacOSbinaries. After extraction run thecontainedwastebin binary.

Run a Docker image

Alternatively, you can run a pre-built Docker image pushed toquxfoo/wastebin:<VERSION> andquxfoo/wastebin:latest respectively. Topersist the database asstate.db via theWASTEBIN_DATABASE_PATH environmentvariable use a bind mount to/path/for/storage like this

docker run \    -e WASTEBIN_DATABASE_PATH=/data/state.db \    -v /path/for/storage:/data \    -u$(id -u):$(id -g) \    quxfoo/wastebin:latest

Note

The image is based on scratch which means it neither comes with a shell norwithTMPDIR being set. If database migrations fail with an extended sqliteerror code 6410, passTMPDIR pointing to a location sqlite can write to.

Run with docker-compose

services:wastebin:restart:alwaysenvironment:      -WASTEBIN_DATABASE_PATH=/data/state.dbports:      -"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, aflake.nix is also provided. Build and execute it directlywith:

nix run'github:matze/wastebin#wastebin'

Or install the providedwastebin package like you normally would.

Build from source

Install a Rust 2024 toolchain containing Rust 1.85 withrustup and run the server binary with

cargo run --release

Build a container image

It is possible to build a container image using Docker or Podman. TheDockerfile is designed to be run on an x86_64 host but capable of buildingimages for both x86_64 and aarch64 via the--target flag:

# Dockerdocker build -t wastebin:v3.0.0 -f Dockerfile --target amd64.docker build -t wastebin:v3.0.0 -f Dockerfile --target arm64.# Podmanpodman build -t wastebin:v3.0.0 -f Dockerfile --target amd64podman build -t wastebin:v3.0.0 -f Dockerfile --target arm64

Note that youcannot build aarch64 images on aarch64 hosts with it.

To interact with a running wastebin instance the bundledwastebin-ctl tool canbe used, e.g.:

podmanexec -e RUST_LOG=debug -it wastebin /app/wastebin-ctl

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,
  • c to copy the content to the clipboard,
  • q to display the current URL as a QR code,
  • p to view the formatted paste and
  • w to toggle line wrapping on and off (off by default)
  • ? to view the list of keybindings.

To paste some text you can also use thectrl+s keycombination.

Configuration

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

VariableDescriptionDefault
WASTEBIN_ADDRESS_PORTAddress and port to bind the server to.0.0.0.0:8088
WASTEBIN_BASE_URLBase URL for the QR code display.
WASTEBIN_CACHE_SIZENumber of rendered items to cache. Disable with 0.128
WASTEBIN_DATABASE_PATHPath to the sqlite3 database file.:memory:
WASTEBIN_HTTP_TIMEOUTMaximum number of seconds a request is processed until wastebin responds with 408.5
WASTEBIN_MAX_BODY_SIZENumber of bytes to accept for POST requests.1048576, i.e. 1 MB
WASTEBIN_PASSWORD_SALTSalt used to hash user passwords used for encrypting pastes.somesalt
WASTEBIN_PASTE_EXPIRATIONSPossible paste expirations as a comma-separated list of seconds or values with duration magnitudes (s,m,h,d,M,y for seconds, minutes, hours, days, months and years respectively). Appending=d to one of the value makes it the default selection.seehere
WASTEBIN_SIGNING_KEYKey to sign cookies. Must be at least 64 bytes long.Random key generated at startup, i.e. cookies will become invalid after restarts and paste creators will not be able to delete their pastes.
WASTEBIN_THEMETheme colors, one ofayu,base16ocean,catppuccin,coldark,gruvbox,monokai,onehalf,solarized. Seethis page for a preview.ayu
WASTEBIN_TITLEHTML page title.wastebin
WASTEBIN_UNIX_SOCKET_PATHPath to a Unix socket to accept connections from.
RUST_LOGLog level. Besides the typicaltrace,debug,info etc. keys, you can also set thetower_http key to a log level to get additional request and response logs.

Note

WASTEBIN_ADDRESS_PORT andWASTEBIN_UNIX_SOCKET_PATH are mutuallyexclusive, which means that setting both will lead to an error. Settingneither will implicitly bind via TCP on0.0.0.0:8088.

API endpoints

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

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

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

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

To retrieve the raw content, make a GET request on the/raw/:id route. In casethe paste was encrypted, pass the password via thewastebin-password header.

To delete a paste, make a DELETE request on the/:id route with theuidcookie set that was sent back in theSet-Cookie header of the redirectresponse after creation.

wastebin-ctl command line tool

wastebin-ctl is a command line tool to interact directly with the wastebindatabase. It can be used tolist all entries,purge entries which haveexpired ordelete specific entries. To specify the database either use the--database option or set theWASTEBIN_DATABASE_PATH environment variable asusual.

Paste from neovim

Use thewastebin.nvim plugin and pastethe current buffer or selection with:WastePaste.

Paste from clipboard

To paste clipboard data from the command line you can use the aforementioned APIcalls together withxclip,curl andjq. Define the following function inyour.bashrc and you are good to go:

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

For wayland users, consider replace thexclip ... withwl-paste fromwl-clipboard.

Paste from stdin

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

functionpaste_from_stdin() {local API_URL="https://wastebin.tld"    jq -Rns'{text: inputs}'| \        curl  -s -H'Content-Type: application/json' --data-binary @-${API_URL}/| \        jq -r'. | "'${API_URL}'\(.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


[8]ページ先頭

©2009-2026 Movatter.jp