• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 2 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

wastebin is a pastebin

wastebin

Rust

A minimal pastebin with a design shamelessly copied from bin.

DEMO (resets every day)

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
  • 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.

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.

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.

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_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 waste-paste() {
    local URL=$(\
        jq -n --arg t "$(xclip -selection clipboard -o)" '{text: $t}' | \
        curl -s -H 'Content-Type: application/json' --data-binary @- http://0.0.0.0:8088 | \
        jq -r '. | "http://0.0.0.0:8088\(.path)"')

    xdg-open $URL
}

License

MIT

More Repositories

1

mtheme

A modern LaTeX Beamer theme
TeX
6,066
star
2

vim-move

Plugin to move lines and selections up and down
Vim Script
1,176
star
3

inkdrop

Artsy pixel image to vector graphics converter
Rust
66
star
4

iridium

Standard Notes client written in Rust and GTK
Rust
66
star
5

pkgconfig

A Python interface to the pkg-config command line tool
Python
59
star
6

vim-tex-fold

File type plugin for folding TeX files
Vim Script
48
star
7

jekyll-ditaa

Jekyll ditaa Plugin
Ruby
29
star
8

python-phant

Python client library for Sparkfun's Phant
Python
25
star
9

ranger-annex

git annex plugin for ranger
Python
22
star
10

oclkit

A small C OpenCL wrapper
C
16
star
11

zk-spaced

Spaced repetition for zk
Rust
15
star
12

configs

Dot files
Lua
15
star
13

tree-painter

tree-sitter based syntax highlighting HTML rendering
Rust
13
star
14

beancount-language-server

Beancount language server
Rust
10
star
15

python-standardfile

Standard File client implementation in Python
Python
8
star
16

vim-ini-fold

Fold expression for ini-like files
Vim Script
5
star
17

vim-lilypond

LilyPond Vim plugin
Vim Script
4
star
18

pandoc-notes

Templates for a single HTML page
4
star
19

git-utils

Small TUI programs to ease a few Git annoyances
Rust
4
star
20

wastebin.nvim

A neovim plugin for the wastebin pastebin
Lua
3
star
21

qperf

Measure performance impact of OpenCL profiling queues
C
3
star
22

books

Gtk+ 3.0 EPUB viewer
C
3
star
23

EggPropertyTreeView

A Gtk+ tree view widget and cell renderer for displaying GObject properties
C
2
star
24

ocl-regressions

OpenCL regression test suite
C
2
star
25

tope-fft

Mirror of https://code.google.com/p/tope-fft/ with small adaptions
C
2
star
26

splat

Static photo gallery generator
Rust
2
star
27

tokio-net-vs-uring

Stupid tokio vs tokio-uring benchmarks
Rust
2
star
28

git-pick-from

Text user interface for the Git cherry-pick command
Python
2
star
29

passport

GTK4 frontend for GNU pass
Rust
2
star
30

protoc-gen-mdbook

protoc plugin to generate mdBook pages
Rust
2
star
31

inkscape-flatpak

Flatpak build recipe for Inkscape
Makefile
2
star
32

gir2rst

Generate Sphinx documentation from GIR files
Python
2
star
33

clib-doc

Documentation generator for clib modules
Python
2
star
34

kseta-dvcs-talk

Sources for the Git talk given at KSETA PhD student workshop 2013
2
star
35

gotham

A collection of pgfplots styles
TeX
2
star
36

chromazone

A terminal colorizer
Rust
1
star
37

professorenrunde

Letter series for KIT CS Professorenrunde
TeX
1
star
38

quotes

Displays quotations loaded from quote webpages.
Python
1
star
39

ocl-stat

OpenCL resource tracker
C
1
star
40

darktable-flatpak

Flatpak recipe for Darktable
Makefile
1
star
41

pyl

Almoste literate Python with Pandoc Markdown.
Python
1
star
42

advent-of-code-2021

Advent of Code 2021
Rust
1
star
43

vim-meson

Vim syntax highlighting for meson
Vim Script
1
star
44

refp

Minimal reference counted pointers
C
1
star
45

kseta-opencl-talk

Sources for the OpenCL talk given at KSETA PhD student workshop 2013
1
star
46

rigal

Static photo gallery generator – similar to Sigal 1.4
Rust
1
star
47

matrix-ticker

Matrix client for the Raspberry Pi Zero + 128x64 OLED display
Rust
1
star
48

axum-notes

axum notes, examples and tutorials
Rust
1
star
49

meater

MEATER crate + app
Rust
1
star
50

mdbook-split

Split first-level heading content into individual chapters
Rust
1
star
51

multithreaded-lame-frontend

Toy example that encodes PCM data in WAVE containers to MP3 using lame
C
1
star
52

zk-pub

Zettelkasten static publisher
Rust
1
star
53

staticrss

Static site generator for RSS and Atom feeds
Python
1
star
54

phgen

Phantom and Sinogram Generator
C
1
star
55

EggPiecewiseLinearView

A piecewise linear view widget for Gtk+ adapted from GIMP
C
1
star
56

bass-patterns

Finger patterns for electric bass guitar
Makefile
1
star
57

af

Python
1
star