~shtrophic/notesock

Yet another terminal pastebin server
notesock: v0.2.2
03cb6be2 — Sir-Photch 1 year, 3 days ago
include hours and days in expiry message
7bbdd8d8 — Sir-Photch 1 year, 13 days ago
v0.2.1

clone

read-only
https://git.sr.ht/~shtrophic/notesock
read/write
git@git.sr.ht:~shtrophic/notesock

You can also use your local clone with git send-email.

notesock icon

notesock

Terminal pastebin server utilizing unix sockets, with exact expiry per paste to alleviate filesystem clutter.

It is meant to be used with netcat:

$ echo "Hello world" | ncat notesock.example.org 1234
https://notesock.example.org/abc123 | expires in 5m

This saves the paste do /configured/dir/abc123/index.txt which makes sure that browsers accessing the URL will interpret the file as .txt only, as only UTF-8 encoded data is accepted by the server.

To receive the paste:

$ curl https://notesock.example.org/abc123
Hello world

The files are stored unencrypted, thus, the user is made responsible to make their information private, e.g. by using gpg:

$ echo "hehe" > mysecret.file
$ gpg -cao mysecret.file.gpg mysecret.file
$ ncat notesock.example.org 1234 < mysecret.file.gpg  
https://notesock.example.org/def456 ...
$ curl https://notesock.example.org/def456 | gpg -d
hehe

#Getting started:

[!IMPORTANT] Because this server listens on an unix socket, a reverse proxy is necessary if it is supposed to be reachable from the interwebz. (Benefits of this are advanced rate-limiting features of the reverse proxy, with a lean-and-mean backend server that only manages validation, id generation and saving of the pastes.)

#Packages

#Build

$ git clone https://git.sr.ht/~shtrophic/notesock && cd notesock
$ cargo build --release
$ target/release/notesock -h

Inspect possible arguments and choose sensible values for your setup.

#Reverse proxy

The same webserver that you would need for serving the pastes via http can be used for this. You just need to forward a network port of your choice to the unix socket created by notesock.

[!TIP] For nginx, you can refer to the example configuration.

#systemd

This pastebin implementation does not rely on dropping privileges for fool-proofing, rather, usage via a systemd unit is preferred.

[!TIP] If you like to use systemd, you can refer to the example unit.

#Useful terminal shenanigans

Some commands that you can alias in your shell's resource file to save you some time.

#fish on wayland

Fits right into your ~/.config/fish/config.fish!

Workflow: copy something on your desktop (Ctrl+C, or rightclick -> copy), execute this pipe (preferably with an alias) and observe Ctrl+V now inserting the link to the paste!

$ wl-paste | string trim | ncat notesock.example.org 1234 | tee /dev/tty | string split -f1 '|' | string trim | wl-copy

With encryption:

$ ncat notesock.example.org 1234 <(wl-paste | gpg -ca | psub) | tee /dev/tty | string split -f1 '|' | string trim | wl-copy