- Go 87.7%
- Shell 12.1%
- Makefile 0.2%
| .gitignore | Revise example systemd unit | |
| go.mod | Remove external dep | |
| go.sum | Remove external dep | |
| ja | Make it only for extraargs | |
| jabeh.service | Revise example systemd unit | |
| main.go | Handle "raw" POST | |
| Makefile | Init | |
| README.md | Rework to accept actual form keys, instead of raw data | |
Jabeh / جعبه [a box]
Minimal pastebin box for personal use. Too understand how to run it,
see jabeh.service -- note the setting of allowed
authentication tokens using EnvironmentFile. If you then use Caddy
as reverse proxy, a line like reverse_proxy /bin/ localhost:40002
should then be enough.
You can put a file in the box like this (using HTTP Basic Auth; jabeh ignores the username):
curl -u :toomanysecrets -T ./somefile https://example.com/bin/
If everything went ok the URL to the box is returned in the HTTP body. Ready to be curled somewhere else. NOTE: no authentication on downloads.
The file is stored by a random ID of 8 characters using the Crockford
base32 alphabet (5 bits per character). This gives us 40 bits of
entropy, so 2^{40} possible ids, or around 1 trillion (10^{12}).
For personal use this should be well enough for avoiding collisions.
Jabeh accepts HTTP PUT. This can be done with curl -T (or
--upload-file), which also automatically sends a filename (see curl
man page). That filename can be overridden by the HTTP header
filename (curl -H "filename: foo.txt").
Jabeh also accepts a HTTP POST, set the form key file: curl -F file=@somefile. The filename can be overridden by setting the form
key filename (-F filename=foo.txt), or using the HTTP header
mentioned above. When POSTing, the authentication token can also be
set using the key token.
When using curl, both methods allows for the local filename to be -,
which makes curl slurp the data from stdin.
When downloading (HTTP GET) from Jabeh, the filename is returned in a
Content-Disposition header, and can be honoured using curl -J -O.
As an alternative to the HTTP Basic Auth, the token can also be passed
in a Authorization: Bearer header.
See ja for a slightly elaborate shell script.