A pastebin that does just enough to be really useful.

Related tags

Command-line rktpb
Overview

Rocket Powered Pastebin (rktpb | paste.rs)

A pastebin that does just enough to be really useful.

  • Really fast, really lightweight.
  • Renders markdown like GitHub.
  • Highlights source code.
  • Returns plain text, too.
  • Has a simple API usable via CLI.
  • Has support for CORS.
  • Limits paste upload sizes.
  • No database: uses the file system.
  • Automatically deletes stale pastes.

This pastebin powers paste.rs, a public instance. Further usage details can be found there.

Usage

Rocket Powered Pastebin (rktpb) is written in Rust with Rocket. To start the server, use cargo:

# clone the repository
git clone https://github.com/SergioBenitez/rktpb

# change into directory: the `static` folder needs to be in CWD before running
cd rktpb

# compile and start the server with the default config
cargo run

Configuration

Configuration is provided via environment variables or a TOML file. A set of defaults is always provided.

The complete list of configurable parameters is below:

Name Default Value Description
id_length 3 paste ID length
upload_dir "upload" directory to save uploads in
paste_limit "384KiB" maximum paste upload file size
max_age "30 days" how long a paste is considered fresh
reap_interval "5 minutes" how often to reap stale uploads
server_url "http://{address}:{port}" URL server is reachable at
cors.{host} ["{HTTP method}"..] allow CORS {HTTP methods} for {host}
address "127.0.0.1" address to listen on
port 8000 port to listen on
keep_alive 5 HTTP keep-alive in seconds
ident "Rocket" server Ident header
ip_header "X-Real-IP" header to inspect for client IP
log_level "normal" console log level
cli_colors true enable (detect TTY) or disable CLI colors
shutdown.ctrlc true whether <ctrl-c> initiates a shutdown
shutdown.signals ["term", "hup"] signals that initiate a shutdown
shutdown.grace 5 grace period length in seconds
shutdown.mercy 5 mercy period length in seconds

You'll definitely want to configure the values in the first two categories, from id_length to cors.

You should likely use the defaults for the rest.

Environment Variables

Use an environment variable name equivalent to the parameter name prefixed with PASTE_:

PASTE_ID_LENGTH=10 PASTE_MAX_AGE="1 year" ./rktpb

To set structured data via environment variables, such as CORS, use TOML-like syntax:

PASTE_CORS='{"http://example.com"=["get", "post"]}' ./rktpb

TOML File

See Paste.toml.template for a template with all of the defaults set as well as a dummy cors configuration for http://example.com that allows the options, get, post, and delete HTTP methods.

mv Paste.toml.template Paste.toml

By default, the application searches for a file called Paste.toml in the CWD. The path to the file can be overridden by setting PASTE_CONFIG. For example, to use a file named rktpb.toml, use PASTE_CONFIG="rktpb.toml" ./rktpb.

Deploying

To deploy, build in release mode and ship/run the resulting binary along with static/, templates/, and any config:

# build in release mode for `${TARGET}`
cargo build --release --target ${TARGET}

# create a tarball of everything that's needed
tar -cvzf "rktpb.tar.gz" \
    Paste.toml static templates \
    -C target/${TARGET}/release rktpb

However you choose to deploy, you'll need to ensure that the CWD at the time the server is started contains the static and templates directories as well as the config file, if one is used.

Note that when the server is compiled in release mode, the [release] section of a TOML config file can be used to override config values; the same is true when compiled in debug mode with [debug].

License

Rocket Powered Pastebin (rktpb | paste.rs)
Copyright © 2020 Sergio Benitez

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 (GNU AGPLv3) as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPLv3 LICENSE for more details.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project shall be licensed under the GNU AGPLv3 License, without any additional terms or conditions.

You might also like...
Structopt derived ethers-rs types, useful for building Ethereum CLIs

ethers-structopt Provides ethers-compatible Structopt derives, useful for building Ethereum CLIs. Contributing Pull requests are welcome. For major ch

Rust command line utility to quickly display useful secrets in a Kubernetes namespace
Rust command line utility to quickly display useful secrets in a Kubernetes namespace

kube-secrets This is a command line utility for quickly looking at secrets in a Kubernetes namespace that are typically looked at by humans. It specif

A CLI tool which can help you automatically kill process of your choice. Useful for freeing up memory and CPU usage!
A CLI tool which can help you automatically kill process of your choice. Useful for freeing up memory and CPU usage!

Quickiller There are always programs such as chrome that keep eating up your resources even when closed! The only way to prevent this is to kill all o

A collection of semi-useful tools made for GNU/Linux

DECTOOLS A collection of semi-useful tools made for GNU/Linux. Some may work on macOS, though functionality isn't a priority. Depenencies: python, bas

Tool that was built quickly for personal needs, you might find it useful though
Tool that was built quickly for personal needs, you might find it useful though

COPYCAT Produced with stable-diffusion Clipboard (copy/paste) history buffer for terminal emulators, MAC OS gui and VIM* environment usage. Rrequireme

Bruteforce connecting to a specific Sea of Thieves server. Useful if you want to be in the same server as your friends.

SoT Server Finder Find which Sea of Thieves server you're connected to. Useful if you want to be in the same server as your friends. Setup Download so

This library contains collection of all sorts of useful information for every country.

Keshvar This library contains collection of all sorts of useful information for every country. Package | Documentation | Repository Demo use keshvar::

🤖 just is a handy way to save and run project-specific commands.

just just is a handy way to save and run project-specific commands. (非官方中文文档,这里,快看过来!) Commands, called recipes, are stored in a file called justfile

2048 in `tui`, just for fun
2048 in `tui`, just for fun

TUI 2048 - Have a relax at anytime - 😎 ^_^ How to run repo clone this repo, git clone https://github.com/WanderHuang/game-2048-tui.git cd game-2048-t

Releases(v1.0.0)
Owner
Sergio Benitez
Sergio Benitez
Technically, this does exactly what sleep does but completes much faster!

hypersleep Technically does everything that sleep does but it is "blazingly fast!" For example, $ time sleep 1 real 0m1.005s user 0m0.001s sys

Nigel 4 Oct 27, 2022
Really useful hacking tools.

A Remake of Hax in Rust™ - Port-scanner(Powered by nmap) ✅ - URL-Masker ✅ - Phisher(Powered by ZPhisher) ☑️ (WIP ?? ) For Linux Enthusiasts: You need

skyline 4 May 13, 2023
A cli based pastebin in Rust, but very insecure

pasta A cli based pastebin in Rust, but very insecure Use nightly toolchain to build rustup override set nightly When this program is running, you can

Snehit Sah 3 Mar 25, 2022
a simple program that you can scrap, is shit and really simple but is cool.

if you want to run it you need to have installed curl by default scrap youtube, but you can change it, also change the number of threads and run: carg

pai 7 Oct 15, 2021
A simple (but really fast!) CLI tool to convert an epub into a text file.

epub_to_txt A simple (but really fast!) CLI tool written in Rust to convert an epub into a text file (in Markdown format). Usage epub_to_txt filename.

Darren Mothersele 3 Jul 30, 2023
Human numeric sorting program — does what `sort -h` is supposed to do!

hns — Human Numeric Sort v0.1.0 (⏫︎2022-09-20) © 2022 Fredrick R. Brennan and hns Authors Apache 2.0 licensed, see LICENSE. man page Packages hns_0.1.

Fredrick Brennan 7 Sep 25, 2022
Parallel iteration of FASTA/FASTQ files, for when sequence order doesn't matter but speed does

Rust-parallelfastx A truly parallel parser for FASTA/FASTQ files. Principle The input file is memory-mapped then virtually split into N chunks. Each c

Rayan Chikhi 8 Oct 24, 2022
A BASIC language interpreter. Does not conform to existing standards. Mostly a toy.

JW-Basic A toy language that is somewhat like QBasic. Features: Graphics: 160x96 (255 colors & transparent) Text: 32x16 (4x5 font) Character set: ASCI

John Wells 8 Feb 15, 2023
Use your computer as a cosmic ray detector! One of the memory errors Rust does not protect against.

Your computer can double up as a cosmic ray detector. Yes, really! Cosmic rays hit your computer all the time. If they hit the RAM, this can sometimes

Johanna Sörngård 110 Jun 16, 2023
`ls` alternative with useful info and a splash of color 🎨

?? Natls ?? Why Natls? Showing file permissions Showing file size Showing the date that the file was modified last Showing the user that the file belo

Will 1.2k Dec 19, 2022