mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
5045019df4
Source/'s content is at the root now, Source/README.md merged into readme.md. Scripts at the root: build.ps1, test.ps1 (was check.ps1), release.ps1 (over release.py) and clean.ps1. Everything is LF except the .ps1 files. CI (.github/workflows/ci.yml) runs on a v* tag or by hand: the checks, then a release for Windows x64 and ARM64 and Linux x64 and ARM64, each on its own kind of runner, the archives kept as artifacts. release.py names the platform from the Rust host, make_wheel.py tags the wheel from the library's header. docker/: the server's image (built from source, the tools beside it, uid 10001), compose.yml and test.sh. CI builds amd64 and arm64 natively, checks them, and on a tag pushes them to ghcr.io with an index for <version> and latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
6.5 KiB
Markdown
124 lines
6.5 KiB
Markdown
# BakaShrot
|
|
A message store with replication.
|
|
|
|
Servers take messages (usually JSON) per topic and node from authenticated clients,
|
|
store them in SQLite, and replicate them to other servers by topic and node name.
|
|
|
|
> [!NOTE]
|
|
> Meant as an internal tool on trusted machines and networks.
|
|
|
|
|
|
## Features
|
|
* TLS 1.3 connections, both ends proving who they are with certificates from your own CA (`bakashrot-cert`)
|
|
* Replication between servers, by topic and node names
|
|
* Attachments, one per message, 1 GB by default
|
|
* Per-topic retention
|
|
* Read-only SQL queries on the stored messages
|
|
* Clients:
|
|
* A C library (`bakashrot.dll`, `libbakashrot.so`), with a C header and PureBasic prototypes
|
|
* A CLI tool to push, read, query and list
|
|
* A Python module over the library, without dependencies, as a wheel with the library in it
|
|
|
|
See [revamp.md](revamp.md) for why it was rewritten in Rust, what was decided, and the plan.
|
|
The PureBasic version it replaced (protocol 6) is in the git history: `OldSource/`, up to commit `68966a8`.
|
|
|
|
|
|
## Building
|
|
Requires [rustup](https://rustup.rs) (it installs the pinned toolchain, [rust-toolchain.toml](rust-toolchain.toml),
|
|
by itself; on Windows, Visual Studio's C++ tools for the linker) and Python 3.11+ for releases.
|
|
|
|
From the repository's root, on Windows (`powershell -ExecutionPolicy Bypass -File <script>`):
|
|
|
|
| Script | What it does |
|
|
|---|---|
|
|
| `build.ps1` | Builds everything, release mode, into `target\release\` |
|
|
| `test.ps1` | What CI runs: formatting, clippy (warnings are errors), the tests, the docs |
|
|
| `release.ps1` | A release for this platform, smoke-tested (`release.py`, below); `-SkipTest` |
|
|
| `clean.ps1` | Deletes `target\` (builds and releases) |
|
|
|
|
Elsewhere, the same with cargo: `cargo build --release`, `cargo test`, `python release.py`, `cargo clean`.
|
|
Generated keys and certificates never go in git.
|
|
|
|
|
|
## Layout
|
|
A Cargo workspace:
|
|
|
|
```
|
|
Cargo.toml the workspace: shared lints, release profile
|
|
rust-toolchain.toml the pinned toolchain (1.100.0)
|
|
build.ps1, test.ps1, release.ps1, clean.ps1
|
|
release.py a release for this platform: build, package, smoke test
|
|
docs/ designs across crates: protocol.md, certificates.md, oid.md, config.md,
|
|
storage.md, server.md, client.md, known-issues.md
|
|
crates/
|
|
bakashrot-proto/ packets, frames, names, limits, error codes, shared by everything
|
|
bakashrot-pki/ certificates: issuing, identities, CRLs, the TLS setup
|
|
bakashrot-config/ the server's config (TOML): topics, retention, replication, roles
|
|
bakashrot-storage/ SQLite, schema v9: the writer, reads, attachments, queries
|
|
bakashrot-server/ the server: TLS, identities, requests, the writer thread (and its program)
|
|
bakashrot-client/ the client library, Rust API, blocking
|
|
bakashrot-capi/ the C DLL over bakashrot-client: the BakaShrot_* exports (bakashrot.dll)
|
|
bakashrot-tools/ the CLI tools: bakashrot (push, read, query, list), bakashrot-cert
|
|
bindings/
|
|
c/ bakashrot.h, generated from bakashrot-capi
|
|
purebasic/ the prototypes and error codes, as the PureBasic version's
|
|
python/ bakashrot.py over the DLL, check_bakashrot.py, make_wheel.py
|
|
.cargo/config.toml the C runtime linked statically on Windows
|
|
docker/ the server's image: Dockerfile, compose.yml, test.sh
|
|
```
|
|
|
|
Dependencies only point downward: `proto`, `pki`, `config` and `storage` don't open sockets and are tested
|
|
on their own; `server` and `client` use them; the DLL and the tools only use `client`.
|
|
|
|
|
|
## Releases
|
|
`python release.py` (or `release.ps1`) on Windows or Linux, x64 or ARM64, builds that platform's release into
|
|
`target/dist/bakashrot-<version>-<platform>/` and its archive (`.zip`, `.tar.gz`):
|
|
the server, `bakashrot`, `bakashrot-cert`, the client library with its C header and PureBasic prototypes,
|
|
`bakashrot.py` and a wheel with the library in it (`bindings/python/make_wheel.py`), the example configs,
|
|
`docs/`, a `README.txt`, the licenses (`THIRD-PARTY.txt`: every crate built in, from `cargo metadata`).
|
|
|
|
Then it checks it, in the folder's `_test/`: a CA and certificates, the server on a free port,
|
|
the tool pushing (an attachment too), reading back, listing and querying, Python through the library
|
|
and the wheel installed by pip, the server stopped by SIGTERM (Ctrl+Break on Windows),
|
|
which must end cleanly (`_test/` kept if not). `--skip-test` skips it.
|
|
|
|
CI ([.github/workflows/ci.yml](.github/workflows/ci.yml)) runs on a version tag (`v*`) or by hand: `test.ps1`'s checks
|
|
on Windows and Linux, then a release on each of Windows x64 and ARM64, Linux x64 and ARM64, each on its own
|
|
kind of machine (so its smoke test runs there), its archive kept as the run's artifact. The Linux ones build
|
|
in a manylinux 2.28 container, so they run with glibc 2.28 and later.
|
|
The version is the workspace's (`Cargo.toml`), and `bindings/python/bakashrot.py`'s `__version__` must be the same.
|
|
|
|
The server's Docker image: `docker build -f docker/Dockerfile -t bakashrot-server .`, or CI's for amd64
|
|
and arm64, checked by `docker/test.sh`, then pushed to `ghcr.io/aziascreations/bakashrot-server` (`<version>` and
|
|
`latest`) on a tag. Running it: `docs/server.md`, "In Docker".
|
|
|
|
Publishing:
|
|
* **The wheel** to Gitea's registry, with twine 6.1+ (for the license metadata) and a token with `write:package`:
|
|
`twine upload --repository-url https://git.nibblepoker.lu/api/packages/aziascreations/pypi -u aziascreations <wheel>`
|
|
* **On GitHub** (no Python registry), the archives and the wheels on a release:
|
|
`gh release create v<version> --repo aziascreations/BakaShrot --title <version> <files>`
|
|
(`gh release upload` for one that exists).
|
|
|
|
|
|
## Conventions
|
|
* LF line endings (`.gitattributes`; `.ps1` CRLF), rustfmt's defaults.
|
|
* Every public item documented (`missing_docs`), no `unsafe` outside the C API crate.
|
|
* A crate's root docs say what it does; designs that span crates go in `docs/`, updated with the code.
|
|
* Use existing crates rather than reimplementing (MessagePack is `rmp-serde`).
|
|
* Protocol changes update `docs/protocol.md`; error codes are never renumbered, packet ids never reused.
|
|
* `OldSource/` paths in comments and docs: the PureBasic version, in git history up to commit `68966a8`.
|
|
|
|
|
|
## Cloning
|
|
```
|
|
git clone https://github.com/aziascreations/BakaShrot.git
|
|
git clone https://git.nibblepoker.lu/aziascreations/BakaShrot.git
|
|
```
|
|
|
|
|
|
## License
|
|
All the code in this repo is released in the [Public Domain](LICENSE).
|
|
|
|
The releases include third-party crates under their own licenses, listed with their texts in `THIRD-PARTY.txt`.
|