- C 96.4%
- Shell 2.1%
- Makefile 0.7%
- HTML 0.6%
- Dockerfile 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| assets | ||
| src | ||
| .gitignore | ||
| bin2h.sh | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
CBin - Pastebin server (C) that's a mildly responsible memory dumpster
CBin is a Unix/Linux only, in-memory pastebin server written in C. It exposes a small REST-ish API and delegates the entire "pretty web experience" to a separate frontend codebase (HTML, TypeScript, CSS), which is maintained by my friend Jan Palma.
It uses FIFO (First in first out) eviction, so older data gets sacrificed to evil demons when the server hits its configured memory limit (default is 1MB * 1000 pastes).
Features
-
Written in C (because fuck memory safety)
-
Uses stb_ds for dynamic data structures (mainly hashmaps)
-
In-memory storage only
-
FIFO eviction policy
-
Unix/Linux only (because I'm using raw sockets and GCC features that aren't standard)
-
Minimal REST-like API (not "REST compliant", just REST-flavored)
-
Designed for a separate frontend
Architecture Overview
This is not a "framework". It's a server that stores text, sometimes throws it out into the abyss.
Core idea:
-
Client submits paste -> server stores it in memory
-
Server assigns an ID
-
Client receives paste via ID
-
When memory limit is reached -> oldest entry is GONE (slow algorithm but idc)
Build
Requirements
-
Linux or some other Unix-like OS
-
GCC or Clang
Compile
make
Run
./build/cbin
usage: ./build/cbin [bind_port] [options]
positional:
bind_port Port to bind (default: 8820)
options:
--bind-port=PORT Port to bind
--n-pastes=N Max number of pastes (default: 1000)
--max-paste-size=BYTES Max paste size (default: 1048576)
--log-level=LEVEL Log level (default: INFO)
Frontend
Completely separate repository here
This backend:
-
Does not render HTML.
-
Does not care about your CSS.
-
Does send data to the client.
-
Does have a favicon and the compiled frontend
Design Philosophy
- As long as it works
Contributing
- Keep it simple
License
MIT License