mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Moved the workspace to the root, Added the build scripts, ARM64 releases and the Docker image
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>
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
# On a version tag, or run by hand: the same checks as test.ps1 (Windows
|
||||
# and Linux), then a release for each platform (release.py), its archive
|
||||
# kept as the run's artifact, and the server's Docker image for amd64 and
|
||||
# arm64, checked (docker/test.sh), pushed to ghcr.io on a tag only. Gitea
|
||||
# Actions runs this file too.
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
IMAGE: ghcr.io/aziascreations/bakashrot-server
|
||||
|
||||
jobs:
|
||||
check:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Installs the toolchain rust-toolchain.toml pins.
|
||||
- run: rustup toolchain install
|
||||
- run: cargo fmt --all -- --check
|
||||
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
||||
- run: cargo test --workspace --all-features
|
||||
- run: cargo doc --workspace --no-deps --all-features
|
||||
env:
|
||||
RUSTDOCFLAGS: -D warnings
|
||||
|
||||
release:
|
||||
# Build, package, smoke test, each on its own kind of machine: no
|
||||
# cross-compiling, and the smoke test runs where the release will.
|
||||
# Linux builds in manylinux 2.28 (glibc 2.28): the programs, the .so
|
||||
# and the wheel run on systems that old.
|
||||
needs: check
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: windows-x64
|
||||
os: windows-latest
|
||||
arch: x64
|
||||
- platform: windows-arm64
|
||||
# aws-lc needs clang-cl there: Visual Studio's, on this image.
|
||||
os: windows-11-arm
|
||||
arch: arm64
|
||||
- platform: linux-x64
|
||||
os: ubuntu-latest
|
||||
container: quay.io/pypa/manylinux_2_28_x86_64
|
||||
- platform: linux-arm64
|
||||
os: ubuntu-24.04-arm
|
||||
container: quay.io/pypa/manylinux_2_28_aarch64
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ${{ matrix.container }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Windows: a Python of the machine's architecture (the smoke test
|
||||
# loads the DLL into it). Linux: the container's.
|
||||
- if: ${{ !matrix.container }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
architecture: ${{ matrix.arch }}
|
||||
- if: ${{ matrix.container }}
|
||||
run: echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH"
|
||||
# rustup, where the image has none.
|
||||
- run: |
|
||||
if ! command -v rustup; then
|
||||
if [ "$RUNNER_OS" = Windows ]; then
|
||||
curl --proto '=https' -sSfo rustup-init.exe https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe
|
||||
./rustup-init.exe -y --default-toolchain none
|
||||
rm rustup-init.exe
|
||||
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
|
||||
else
|
||||
curl --proto '=https' -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
fi
|
||||
- run: rustup toolchain install
|
||||
- run: python release.py
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bakashrot-${{ matrix.platform }}
|
||||
path: |
|
||||
target/dist/*.zip
|
||||
target/dist/*.tar.gz
|
||||
if-no-files-found: error
|
||||
|
||||
docker:
|
||||
# The server's image, each architecture built on its own kind of
|
||||
# machine (no emulation), checked, then pushed as <version>-<arch> on a
|
||||
# tag. Run by hand, it's built and checked only.
|
||||
needs: check
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
os: ubuntu-latest
|
||||
- arch: arm64
|
||||
os: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
if [ "$GITHUB_REF_TYPE" = tag ]; then version=${GITHUB_REF_NAME#v}; else version=manual; fi
|
||||
echo "TAG=$IMAGE:$version-${{ matrix.arch }}" >> "$GITHUB_ENV"
|
||||
- run: docker build -f docker/Dockerfile -t "$TAG" .
|
||||
- run: sh docker/test.sh "$TAG"
|
||||
- if: github.ref_type == 'tag'
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
||||
docker push "$TAG"
|
||||
|
||||
docker-index:
|
||||
# One image for both architectures, <version> and latest: an index of
|
||||
# the two, once the releases passed too. GitHub reads the source label
|
||||
# on an index from its annotations.
|
||||
if: github.ref_type == 'tag'
|
||||
needs: [docker, release]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
steps:
|
||||
- run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
||||
version=${GITHUB_REF_NAME#v}
|
||||
docker buildx imagetools create -t "$IMAGE:$version" -t "$IMAGE:latest" \
|
||||
--annotation "index:org.opencontainers.image.source=https://github.com/aziascreations/BakaShrot" \
|
||||
--annotation "index:org.opencontainers.image.description=BakaShrot server" \
|
||||
--annotation "index:org.opencontainers.image.licenses=CC0-1.0" \
|
||||
"$IMAGE:$version-amd64" "$IMAGE:$version-arm64"
|
||||
@@ -1,71 +0,0 @@
|
||||
# The new sources (Source/): the same checks as Source/check.ps1, on Windows
|
||||
# and Linux; a release of each (Source/release.py) on a version tag or when
|
||||
# run by hand. Gitea Actions runs this file too.
|
||||
name: Source
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
# Tags aren't filtered by paths.
|
||||
tags: ["v*"]
|
||||
paths: ["Source/**", ".github/workflows/source.yml"]
|
||||
pull_request:
|
||||
paths: ["Source/**", ".github/workflows/source.yml"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: Source
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Installs the toolchain Source/rust-toolchain.toml pins.
|
||||
- run: rustup toolchain install
|
||||
- run: cargo fmt --all -- --check
|
||||
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
||||
- run: cargo test --workspace --all-features
|
||||
- run: cargo doc --workspace --no-deps --all-features
|
||||
env:
|
||||
RUSTDOCFLAGS: -D warnings
|
||||
|
||||
release:
|
||||
# Build, package, smoke test: target/dist/'s archive, kept as an
|
||||
# artifact. Linux builds in manylinux 2.28 (glibc 2.28): the programs,
|
||||
# the .so and the wheel run on systems that old.
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
||||
needs: check
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
python: python
|
||||
- os: ubuntu-latest
|
||||
container: quay.io/pypa/manylinux_2_28_x86_64
|
||||
python: /opt/python/cp312-cp312/bin/python
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ${{ matrix.container }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: Source
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- if: matrix.container
|
||||
run: |
|
||||
curl --proto '=https' -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
- run: rustup toolchain install
|
||||
- run: ${{ matrix.python }} release.py
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bakashrot-${{ matrix.os }}
|
||||
path: |
|
||||
Source/target/dist/*.zip
|
||||
Source/target/dist/*.tar.gz
|
||||
+4
-1
@@ -14,5 +14,8 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
|
||||
# Rust (Source/)
|
||||
# Rust
|
||||
target/
|
||||
|
||||
# The compose example's config (keys)
|
||||
docker/config/
|
||||
|
||||
@@ -9,8 +9,8 @@ between peers by name. Clients: a C DLL, CLI tools, a Python module. An
|
||||
|
||||
- `revamp.md`: why, what's decided, what's proposed and open, the plan and
|
||||
its status. Read it first.
|
||||
- `Source/`: the implementation (`Source/README.md`: layout, commands,
|
||||
conventions; `Source/docs/`: designs, `protocol.md` first,
|
||||
- The implementation is the Cargo workspace at the root (`readme.md`:
|
||||
layout, scripts, conventions; `docs/`: designs, `protocol.md` first,
|
||||
`known-issues.md` for what's left).
|
||||
- The old PureBasic implementation was removed on 2026-11-15: it's in git
|
||||
history, `OldSource/` up to commit `68966a8`. Paths starting with
|
||||
@@ -20,10 +20,13 @@ between peers by name. Clients: a C DLL, CLI tools, a Python module. An
|
||||
|
||||
- Rust via rustup, in `%USERPROFILE%\.cargo\bin`, which **isn't on every
|
||||
shell's PATH**: prepend it (`export PATH="$HOME/.cargo/bin:$PATH"` in
|
||||
bash; `check.ps1` does it itself). The toolchain is pinned
|
||||
(`Source/rust-toolchain.toml`, 1.100.0, MSVC; Visual Studio 18 has the
|
||||
bash; the `.ps1` scripts and `release.py` do it themselves). The toolchain is pinned
|
||||
(`rust-toolchain.toml`, 1.100.0, MSVC; Visual Studio 18 has the
|
||||
linker).
|
||||
- `Source\check.ps1` runs what CI runs; it must pass before a step is done.
|
||||
- `test.ps1` runs what CI runs; it must pass before a step is done
|
||||
(`build.ps1`, `release.ps1`, `clean.ps1` beside it, see `readme.md`).
|
||||
Run them by absolute path (`-File <repo>\test.ps1`): a relative one
|
||||
fails when the shell's folder differs.
|
||||
|
||||
## Working rules
|
||||
|
||||
@@ -33,10 +36,10 @@ between peers by name. Clients: a C DLL, CLI tools, a Python module. An
|
||||
- **Decisions go in `revamp.md`**: moved to "Decided" only when the owner
|
||||
decides, with the date.
|
||||
- **Use existing crates** rather than reimplementing (MessagePack is `rmp-serde`).
|
||||
- **Files mix CRLF and LF:** edits must keep each file's line endings
|
||||
(`Source/` is LF, the docs at the root mostly CRLF).
|
||||
- **Line endings:** LF everywhere, `.ps1` CRLF (`.gitattributes`); edits
|
||||
must keep them.
|
||||
- **Bash tool heredocs collapse `\\`:** write edit scripts to files, or use
|
||||
the Edit tool.
|
||||
- **Run exes from a build folder** (`Source\target\`):
|
||||
- **Run exes from a build folder** (`target\`):
|
||||
the antivirus blocks them in temp folders.
|
||||
- **Generated keys and certificates never go in git** (`target/`).
|
||||
|
||||
Generated
@@ -1,5 +1,5 @@
|
||||
# The BakaShrot workspace: every crate is in crates/, see README.md for the
|
||||
# layout and ../revamp.md for the plan.
|
||||
# The BakaShrot workspace: every crate is in crates/, see readme.md for the
|
||||
# layout and revamp.md for the plan.
|
||||
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
@@ -1,89 +0,0 @@
|
||||
# BakaShrot - new sources (Rust)
|
||||
|
||||
The new implementation, see `../revamp.md` (why, decisions, the plan and
|
||||
where it stands).
|
||||
|
||||
## Layout
|
||||
|
||||
A Cargo workspace. What's marked with a step number is planned, added by
|
||||
that step of the plan; the rest exists:
|
||||
|
||||
```
|
||||
Source/
|
||||
Cargo.toml the workspace: shared lints, release profile
|
||||
rust-toolchain.toml the pinned toolchain (1.100.0)
|
||||
check.ps1 what CI runs: fmt, clippy, tests, docs
|
||||
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
|
||||
tests/ (13) end-to-end suites across processes
|
||||
```
|
||||
|
||||
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`.
|
||||
|
||||
## Building and checking
|
||||
|
||||
- `cargo build`, `cargo test` from `Source/` (rustup picks the pinned
|
||||
toolchain).
|
||||
- `powershell -ExecutionPolicy Bypass -File Source\check.ps1`: everything
|
||||
CI checks (`../.github/workflows/source.yml`), warnings are errors.
|
||||
- Output in `target/` (git-ignored). Generated keys and certificates never
|
||||
go in git.
|
||||
|
||||
## Releases
|
||||
|
||||
`python release.py` (Python 3.11+) on Windows x64 or Linux x86-64 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`.
|
||||
|
||||
CI runs it on a version tag (`v*`) or by hand, keeping the archives: the
|
||||
Linux one in a manylinux 2.28 container, so it runs 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.
|
||||
|
||||
Publishing, as the old version did:
|
||||
|
||||
- **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`), 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, removed
|
||||
2026-11-15, in git history up to commit `68966a8`.
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BakaShrot's client DLL: bakashrot.dll (Windows), libbakashrot.so (Linux).
|
||||
* Generated by cbindgen from Source/crates/bakashrot-capi: don't edit.
|
||||
* Source/docs/client.md has the conventions and the whole API.
|
||||
* Generated by cbindgen from crates/bakashrot-capi: don't edit.
|
||||
* docs/client.md has the conventions and the whole API.
|
||||
*/
|
||||
|
||||
#ifndef BAKASHROT_H
|
||||
+2
-2
@@ -28,8 +28,8 @@
|
||||
; BakaShrot_UnloadClient()
|
||||
; EndIf
|
||||
;
|
||||
; Source/docs/client.md has what each function does (and
|
||||
; Source/bindings/c/bakashrot.h, generated from the DLL). The string
|
||||
; docs/client.md has what each function does (and
|
||||
; bindings/c/bakashrot.h, generated from the DLL). The string
|
||||
; functions are mapped to the DLL's W (UTF-16) variants. After a failed
|
||||
; call, BakaShrot_GetLastError() tells why: the codes and what to do about
|
||||
; each are in BakaShrot_ErrorCodes.pbi, next to this file (included below),
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
;
|
||||
; What BakaShrot_GetLastError() returns after a failed call of the client DLL
|
||||
; (bakashrot.dll), and the code a server sends with each refusal (protocol 7,
|
||||
; Source/crates/bakashrot-proto/src/error.rs, the same numbers as protocol 6).
|
||||
; crates/bakashrot-proto/src/error.rs, the same numbers as protocol 6).
|
||||
; The Python client has them in bakashrot.ErrorCode. Shipped next to
|
||||
; BakaShrot_Client_Prototypes.pbi, which includes it.
|
||||
;
|
||||
@@ -18,7 +18,7 @@ stored, a str that may or may not be JSON: parsing them is up to the app
|
||||
Who the client is comes from its certificate, issued by the CA the server
|
||||
trusts (bakashrot-cert): its name is its node, its roles say what it may
|
||||
do. client.toml says where the server is and where the certificates are
|
||||
(Source/docs/client.md):
|
||||
(docs/client.md):
|
||||
|
||||
server = "10.0.0.2:7000"
|
||||
ca = "ca.crt"
|
||||
@@ -66,7 +66,7 @@ __all__ = [
|
||||
"MAX_GET_MESSAGES", "MAX_MESSAGE_SIZE",
|
||||
]
|
||||
|
||||
# The protocol's: Source/crates/bakashrot-proto/src/limits.rs.
|
||||
# The protocol's: crates/bakashrot-proto/src/limits.rs.
|
||||
MAX_GET_MESSAGES = 10000
|
||||
MAX_MESSAGE_SIZE = 16 * 1024 * 1024 - 4096
|
||||
|
||||
@@ -74,7 +74,7 @@ DLL_NAME = "bakashrot.dll" if sys.platform == "win32" else "libbakashrot.so"
|
||||
|
||||
|
||||
class ErrorCode(enum.IntEnum):
|
||||
"""What failed: the protocol's codes (Source/crates/bakashrot-proto/src/error.rs).
|
||||
"""What failed: the protocol's codes (crates/bakashrot-proto/src/error.rs).
|
||||
1-99: refused by the server, 100+: the client's own."""
|
||||
NONE = 0
|
||||
# Refused by the server, the connection still open.
|
||||
@@ -3,14 +3,14 @@ so `pip install` is all a Python app needs, nothing to compile.
|
||||
|
||||
python make_wheel.py <library> <out_dir> [license files...]
|
||||
|
||||
<library> is bakashrot.dll (Windows x64) or libbakashrot.so (Linux x86-64),
|
||||
<library> is bakashrot.dll (Windows) or libbakashrot.so (Linux), x64 or ARM64,
|
||||
from `cargo build --release`; the license files go in the wheel's
|
||||
dist-info/licenses/ (release.py gives LICENSE and THIRD-PARTY.txt). Prints
|
||||
the wheel's path.
|
||||
|
||||
The wheel is bakashrot-<version>-py3-none-<platform>.whl, the version
|
||||
being bakashrot.py's __version__ (release.py checks it's the workspace's):
|
||||
win_amd64, or manylinux_<glibc>_x86_64 with the glibc it was built
|
||||
win_amd64 or win_arm64, or manylinux_<glibc>_<x86_64|aarch64> with the glibc it was built
|
||||
against (a Rust library only needs libc, libm and libgcc_s, which
|
||||
manylinux allows). Inside, bakashrot.py is bakashrot/__init__.py with the
|
||||
library next to it, where it looks first. Only the standard library, and
|
||||
@@ -62,17 +62,27 @@ def version():
|
||||
|
||||
|
||||
def platform_tag(library):
|
||||
"""The wheel's platform, from the library's kind."""
|
||||
"""The wheel's platform, from the library's kind and machine (its
|
||||
header's)."""
|
||||
with open(library, "rb") as file:
|
||||
magic = file.read(4)
|
||||
if magic[:2] == b"MZ":
|
||||
return "win_amd64", "Operating System :: Microsoft :: Windows"
|
||||
if magic == b"\x7fELF":
|
||||
header = file.read(4096)
|
||||
if header[:2] == b"MZ":
|
||||
# The PE header's offset at 0x3C, its machine after "PE\0\0".
|
||||
pe = int.from_bytes(header[0x3C:0x40], "little")
|
||||
machine = {0x8664: "amd64", 0xAA64: "arm64"}.get(int.from_bytes(header[pe + 4:pe + 6], "little"))
|
||||
if machine is None or header[pe:pe + 4] != b"PE\0\0":
|
||||
sys.exit(f"{library}: neither an x64 nor an ARM64 DLL")
|
||||
return f"win_{machine}", "Operating System :: Microsoft :: Windows"
|
||||
if header[:4] == b"\x7fELF":
|
||||
# e_machine, little-endian on both.
|
||||
machine = {62: "x86_64", 183: "aarch64"}.get(int.from_bytes(header[18:20], "little"))
|
||||
if machine is None:
|
||||
sys.exit(f"{library}: neither an x86-64 nor an ARM64 shared object")
|
||||
libc, glibc = platform.libc_ver()
|
||||
if libc != "glibc":
|
||||
sys.exit("Built against another libc than glibc: no manylinux tag")
|
||||
major, minor = glibc.split(".")[:2]
|
||||
return f"manylinux_{major}_{minor}_x86_64", "Operating System :: POSIX :: Linux"
|
||||
return f"manylinux_{major}_{minor}_{machine}", "Operating System :: POSIX :: Linux"
|
||||
sys.exit(f"{library}: neither a Windows DLL nor a Linux shared object")
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Builds everything (the server, the tools, the client library), release
|
||||
# mode, into target\release\.
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File build.ps1
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# rustup's folder isn't always on the PATH (it isn't in every shell here).
|
||||
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
||||
$env:PATH = (Join-Path $env:USERPROFILE ".cargo\bin") + [IO.Path]::PathSeparator + $env:PATH
|
||||
}
|
||||
|
||||
Push-Location $PSScriptRoot
|
||||
try {
|
||||
cargo build --workspace --release --locked
|
||||
if ($LASTEXITCODE -ne 0) { "FAILED: cargo build"; exit 1 }
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
"Built into $(Join-Path $PSScriptRoot "target\release")"
|
||||
exit 0
|
||||
@@ -0,0 +1,20 @@
|
||||
# Deletes what the builds and releases made: target\ (cargo's output and
|
||||
# target\dist\), and Python's __pycache__ folders.
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File clean.ps1
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# rustup's folder isn't always on the PATH (it isn't in every shell here).
|
||||
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
||||
$env:PATH = (Join-Path $env:USERPROFILE ".cargo\bin") + [IO.Path]::PathSeparator + $env:PATH
|
||||
}
|
||||
|
||||
Push-Location $PSScriptRoot
|
||||
try {
|
||||
cargo clean
|
||||
if ($LASTEXITCODE -ne 0) { "FAILED: cargo clean"; exit 1 }
|
||||
Get-ChildItem -Path bindings -Directory -Recurse -Filter __pycache__ | Remove-Item -Recurse -Force
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
"Cleaned"
|
||||
exit 0
|
||||
@@ -3,8 +3,8 @@
|
||||
language = "C"
|
||||
header = """/*
|
||||
* BakaShrot's client DLL: bakashrot.dll (Windows), libbakashrot.so (Linux).
|
||||
* Generated by cbindgen from Source/crates/bakashrot-capi: don't edit.
|
||||
* Source/docs/client.md has the conventions and the whole API.
|
||||
* Generated by cbindgen from crates/bakashrot-capi: don't edit.
|
||||
* docs/client.md has the conventions and the whole API.
|
||||
*/"""
|
||||
include_guard = "BAKASHROT_H"
|
||||
cpp_compat = true
|
||||
@@ -1,6 +1,6 @@
|
||||
//! BakaShrot's C DLL (`bakashrot.dll`, `libbakashrot.so`): the old
|
||||
//! `BakaShrot_*` exports over [`bakashrot_client`], for C, PureBasic,
|
||||
//! Python (ctypes) and anything that loads a DLL. `Source/docs/client.md`
|
||||
//! Python (ctypes) and anything that loads a DLL. `docs/client.md`
|
||||
//! has the whole API; `bindings/c/bakashrot.h` is generated from this file.
|
||||
//!
|
||||
//! The conventions, the old DLL's:
|
||||
@@ -15,7 +15,7 @@
|
||||
//!
|
||||
//! The connection: TLS 1.3 with the CA's certificates (`bakashrot-pki`),
|
||||
//! ALPN `bakashrot`, both ends' protocol versions, then the server's
|
||||
//! `Welcome` (`Source/docs/protocol.md`). Errors carry the protocol's codes
|
||||
//! `Welcome` (`docs/protocol.md`). Errors carry the protocol's codes
|
||||
//! (`bakashrot_proto::ErrorCode`): a server's refusal keeps its own.
|
||||
|
||||
use aws_lc_rs::digest;
|
||||
@@ -423,7 +423,7 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Runs read-only SQL: `{"columns":[...],"rows":[[...],...]}`, every
|
||||
/// value a string or null (`Source/docs/storage.md`, "The query surface").
|
||||
/// value a string or null (`docs/storage.md`, "The query surface").
|
||||
pub fn query(&mut self, sql: &str) -> Result<String> {
|
||||
check_size(sql, "a query")?;
|
||||
let query = Query {
|
||||
@@ -1,5 +1,5 @@
|
||||
# A BakaShrot server's config, every key with its default where it has
|
||||
# one. Read by bakashrot-config, explained in Source/docs/config.md.
|
||||
# one. Read by bakashrot-config, explained in docs/config.md.
|
||||
#
|
||||
# Names (topics, nodes, roles): 1-64 of A-Z a-z 0-9 _ . -, not only digits,
|
||||
# case doesn't matter. Lists of topics or nodes also take patterns: * any
|
||||
@@ -10,7 +10,7 @@
|
||||
//! Who connects is the certificate's (`bakashrot-pki`): its name is its
|
||||
//! node, its roles are looked up here. Peers too: what's replicated with a
|
||||
//! peer is its roles'. The file, every key and its default:
|
||||
//! `Source/docs/config.md`.
|
||||
//! `docs/config.md`.
|
||||
//!
|
||||
//! Every value is checked as serde reads it, so a wrong one is refused with
|
||||
//! its line.
|
||||
@@ -9,7 +9,7 @@
|
||||
//! strongest settings rustls has.
|
||||
//!
|
||||
//! Everything is PEM text in and out, as files hold it. The profile and the
|
||||
//! reasons behind it: `Source/docs/certificates.md`.
|
||||
//! reasons behind it: `docs/certificates.md`.
|
||||
|
||||
mod ca;
|
||||
mod identity;
|
||||
@@ -27,7 +27,7 @@ use x509_parser::certificate::X509Certificate;
|
||||
///
|
||||
/// **A placeholder** ([`IDENTITY_OID_IS_PLACEHOLDER`]): under PEN 32473,
|
||||
/// which RFC 5612 reserves for documentation. Replace it with one under
|
||||
/// NibblePoker's own PEN once IANA gave it (`Source/docs/oid.md`), before
|
||||
/// NibblePoker's own PEN once IANA gave it (`docs/oid.md`), before
|
||||
/// issuing certificates for real: certificates made with this one stop
|
||||
/// being read once it changes.
|
||||
pub const IDENTITY_OID: &[u64] = &[1, 3, 6, 1, 4, 1, 32473, 1, 1];
|
||||
@@ -11,7 +11,7 @@
|
||||
//! - [`frame`]: frames, a 4-byte size then a packet.
|
||||
//! - [`packets`]: every packet, and [`Packet`] to encode and decode them.
|
||||
//!
|
||||
//! The wire format is described in `Source/docs/protocol.md`.
|
||||
//! The wire format is described in `docs/protocol.md`.
|
||||
|
||||
pub mod error;
|
||||
pub mod frame;
|
||||
@@ -28,7 +28,7 @@ pub const MAX_TIMESTAMP: u64 = 253_402_300_799_999;
|
||||
|
||||
/// The biggest message id: 2^43 - 1, about 8.8 trillion per topic and
|
||||
/// node. Servers store it in 43 bits of a packed key
|
||||
/// (`Source/docs/storage.md`, "Keys").
|
||||
/// (`docs/storage.md`, "Keys").
|
||||
pub const MAX_MESSAGE_ID: u64 = (1 << 43) - 1;
|
||||
|
||||
/// The longest topic or node name, in characters (ASCII only).
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
//! array, `[type, [field, field, ...]]`. Structs inside are arrays of their
|
||||
//! fields too, `Option`s nil or their value, bytes binaries. All of it is
|
||||
//! derived with `serde` (`rmp-serde`'s compact form): the structs below
|
||||
//! are the format, `Source/docs/protocol.md` lists them.
|
||||
//! are the format, `docs/protocol.md` lists them.
|
||||
//!
|
||||
//! [`Packet::decode`] checks everything: the types and the number of
|
||||
//! fields (`serde`), then each packet's rules ([`Check`]: ranges, names,
|
||||
@@ -20,7 +20,7 @@
|
||||
//! Adding a packet: a struct deriving `Serialize` and `Deserialize`, with
|
||||
//! its [`Check`], in the file of its family; a line in the `packets!` table
|
||||
//! below with the next id (never reuse one); a sample in `tests/packets.rs`;
|
||||
//! its row in `Source/docs/protocol.md`.
|
||||
//! its row in `docs/protocol.md`.
|
||||
|
||||
mod attachments;
|
||||
mod messages;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//! One connection: TLS, the versions, who it is, then its requests, one at
|
||||
//! a time (`Source/docs/protocol.md`).
|
||||
//! a time (`docs/protocol.md`).
|
||||
|
||||
use crate::writer::Write;
|
||||
use crate::{Shared, accept_from, now};
|
||||
@@ -252,7 +252,7 @@ impl Shared {
|
||||
|
||||
/// Checkpoints the WAL every second, on a thread and a connection of its
|
||||
/// own, so the writer doesn't do it in the middle of a commit (2.5 times
|
||||
/// the pushes: `Source/docs/storage.md`, "Against the old storage").
|
||||
/// the pushes: `docs/storage.md`, "Against the old storage").
|
||||
fn start_checkpoints(database: &Database) -> Result<(), String> {
|
||||
let checkpointer = database.checkpointer().map_err(|error| error.to_string())?;
|
||||
std::thread::Builder::new()
|
||||
@@ -11,7 +11,7 @@
|
||||
//!
|
||||
//! **Everything is by name:** topics, nodes, message ids, times, as on the
|
||||
//! wire. Streams (one node's messages in one topic) and the packed keys
|
||||
//! that store them stay inside this crate: `Source/docs/storage.md`.
|
||||
//! that store them stay inside this crate: `docs/storage.md`.
|
||||
//!
|
||||
//! **Blocking:** SQLite is. The server runs these on threads of their own
|
||||
//! (the writer on one, readers on a pool), not on its async tasks.
|
||||
@@ -90,7 +90,7 @@ impl From<rusqlite::Error> for Error {
|
||||
/// A result of this crate.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Where an attachment is at (`Source/docs/storage.md`, "Attachments").
|
||||
/// Where an attachment is at (`docs/storage.md`, "Attachments").
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AttachmentState {
|
||||
/// Pushed, its parts coming, no message yet.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- BakaShrot's database, schema v9. Read Source/docs/storage.md first: the
|
||||
-- BakaShrot's database, schema v9. Read docs/storage.md first: the
|
||||
-- keys below are packed integers, on purpose, and only bakashrot-storage
|
||||
-- packs and unpacks them.
|
||||
--
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
//! `bakashrot-cert`: makes a CA, issues certificates, revokes them, shows
|
||||
//! them. Every file is PEM; keys are written once, never over an existing
|
||||
//! file. See `Source/docs/certificates.md`.
|
||||
//! file. See `docs/certificates.md`.
|
||||
|
||||
use bakashrot_pki::{
|
||||
CA_DAYS, CERTIFICATE_DAYS, Ca, IDENTITY_OID_IS_PLACEHOLDER, Identity, Revocations, Usage,
|
||||
@@ -100,7 +100,7 @@ fn main() -> ExitCode {
|
||||
|
||||
/// Said whenever a certificate is made while the OID is the placeholder.
|
||||
const PLACEHOLDER_WARNING: &str = "warning: the identity extension's OID is still a placeholder \
|
||||
(Source/docs/oid.md): fine for tests, not for certificates in use";
|
||||
(docs/oid.md): fine for tests, not for certificates in use";
|
||||
|
||||
fn run(command: Command) -> Result<(), String> {
|
||||
if IDENTITY_OID_IS_PLACEHOLDER && matches!(command, Command::Ca { .. } | Command::Issue { .. })
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
//! `bakashrot`: pushes messages, reads them and their attachments, runs
|
||||
//! queries and lists names from the command line, connecting with a
|
||||
//! `client.toml`. The old `BakaShrot*` tools in one program; see
|
||||
//! `Source/docs/client.md`, "The tools".
|
||||
//! `docs/client.md`, "The tools".
|
||||
|
||||
use bakashrot_client::{Client, Error, Settings};
|
||||
use bakashrot_proto::error::{code_name, is_refusal_code};
|
||||
@@ -0,0 +1,64 @@
|
||||
# The BakaShrot server's image: bakashrot-server, with the bakashrot and
|
||||
# bakashrot-cert tools beside it. Built from the repository's root:
|
||||
# docker build -f docker/Dockerfile -t bakashrot-server .
|
||||
# CI builds it for amd64 and arm64 on a version tag, checks it
|
||||
# (docker/test.sh) and pushes it to ghcr.io/aziascreations/bakashrot-server
|
||||
# (.github/workflows/ci.yml).
|
||||
#
|
||||
# The config goes in /etc/bakashrot (read-only: server.toml, the CA's
|
||||
# certificate, the server's certificate and key, the CRL if any), the
|
||||
# database in /var/lib/bakashrot (a volume). In server.toml:
|
||||
# listen = "0.0.0.0:7000" every interface: 127.0.0.1 isn't reachable
|
||||
# from outside the container
|
||||
# database = "/var/lib/bakashrot/bakashrot.sqlite"
|
||||
# and the certificates relative to it (ca = "ca.crt", ...). The server runs
|
||||
# as uid 10001, which must be able to read its key (bakashrot-cert writes
|
||||
# keys readable by their owner only): chown 10001:10001 config/server-1.key
|
||||
#
|
||||
# docker run -d --name bakashrot -p 7000:7000 \
|
||||
# -v ./config:/etc/bakashrot:ro -v bakashrot-data:/var/lib/bakashrot \
|
||||
# ghcr.io/aziascreations/bakashrot-server
|
||||
#
|
||||
# Or docker/compose.yml. `docker stop` stops it cleanly (SIGTERM).
|
||||
# The tools: docker run --rm <image> bakashrot-cert ... (or bakashrot ...).
|
||||
|
||||
|
||||
# --- Build ---------------------------------------------------------------------
|
||||
|
||||
FROM rust:1-slim-trixie AS build
|
||||
|
||||
WORKDIR /src
|
||||
# Only what the programs are built from (Dockerfile.dockerignore).
|
||||
COPY . .
|
||||
# The toolchain rust-toolchain.toml pins, then the release build.
|
||||
RUN rustup toolchain install \
|
||||
&& cargo build --release --locked -p bakashrot-server -p bakashrot-tools \
|
||||
&& mkdir /out \
|
||||
&& cp target/release/bakashrot-server target/release/bakashrot target/release/bakashrot-cert /out/
|
||||
|
||||
|
||||
# --- Runtime -------------------------------------------------------------------
|
||||
|
||||
# The same Debian as the build: the programs only need its glibc.
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# The source label links the package to the repository on ghcr.io. CI
|
||||
# pushes each architecture's image as is, then an index of both with the
|
||||
# same as annotations: GitHub reads those on an index.
|
||||
LABEL org.opencontainers.image.source="https://github.com/aziascreations/BakaShrot" \
|
||||
org.opencontainers.image.description="BakaShrot server" \
|
||||
org.opencontainers.image.licenses="CC0-1.0"
|
||||
|
||||
RUN groupadd --system --gid 10001 bakashrot \
|
||||
&& useradd --system --uid 10001 --gid 10001 --home-dir /var/lib/bakashrot --shell /usr/sbin/nologin bakashrot \
|
||||
&& mkdir -p /etc/bakashrot /var/lib/bakashrot \
|
||||
&& chown bakashrot:bakashrot /var/lib/bakashrot
|
||||
|
||||
COPY --from=build /out/ /usr/local/bin/
|
||||
|
||||
USER bakashrot
|
||||
WORKDIR /var/lib/bakashrot
|
||||
VOLUME /var/lib/bakashrot
|
||||
EXPOSE 7000
|
||||
|
||||
CMD ["bakashrot-server", "/etc/bakashrot/server.toml"]
|
||||
@@ -0,0 +1,8 @@
|
||||
# Only what the programs are built from: target/ alone can hold gigabytes
|
||||
# of builds and test databases, and keys.
|
||||
*
|
||||
!Cargo.toml
|
||||
!Cargo.lock
|
||||
!rust-toolchain.toml
|
||||
!.cargo
|
||||
!crates
|
||||
@@ -0,0 +1,27 @@
|
||||
# BakaShrot's server with docker compose, from this folder:
|
||||
# docker compose up -d pulls the image (--build: builds it here)
|
||||
# docker compose logs -f
|
||||
# docker compose down stops it cleanly (SIGTERM)
|
||||
#
|
||||
# config/, next to this file: server.toml, ca.crt, the server's certificate
|
||||
# and key, the CRL if any (the Dockerfile says what server.toml needs; its
|
||||
# key readable by uid 10001). The database lives in the bakashrot-data
|
||||
# volume, kept by `down` (`down -v` deletes it).
|
||||
|
||||
services:
|
||||
bakashrot:
|
||||
image: ghcr.io/aziascreations/bakashrot-server:latest
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
container_name: bakashrot
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
# server.toml's listen port.
|
||||
- "7000:7000"
|
||||
volumes:
|
||||
- ./config:/etc/bakashrot:ro
|
||||
- bakashrot-data:/var/lib/bakashrot
|
||||
|
||||
volumes:
|
||||
bakashrot-data:
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
# Smoke-tests a server image, as CI does before pushing it: certificates by
|
||||
# its bakashrot-cert, its server started with them, its bakashrot pushing
|
||||
# and reading back over a Docker network, then `docker stop`, which must
|
||||
# end it cleanly (exit code 0, "stopped").
|
||||
# Usage: docker/test.sh <image>
|
||||
set -eu
|
||||
image=$1
|
||||
name=bakashrot-test-$$
|
||||
work=$(mktemp -d)
|
||||
# The image's user (10001) writes the certificates there.
|
||||
chmod 777 "$work"
|
||||
|
||||
cleanup() {
|
||||
docker rm -f -v "$name" >/dev/null 2>&1 || true
|
||||
docker network rm "$name" >/dev/null 2>&1 || true
|
||||
rm -rf "$work"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
fail() {
|
||||
echo "FAILED: $1"
|
||||
docker logs "$name" 2>&1 || true
|
||||
exit 1
|
||||
}
|
||||
tool() {
|
||||
docker run --rm -v "$work:/w" -w /w --network "$name" "$image" "$@"
|
||||
}
|
||||
|
||||
docker network create "$name" >/dev/null
|
||||
tool bakashrot-cert ca --name "Image test CA"
|
||||
tool bakashrot-cert issue --name server-1 --server
|
||||
tool bakashrot-cert issue --name tester --role tester
|
||||
cat >"$work/server.toml" <<EOF
|
||||
[server]
|
||||
listen = "0.0.0.0:7000"
|
||||
ca = "ca.crt"
|
||||
certificate = "server-1.crt"
|
||||
key = "server-1.key"
|
||||
database = "/var/lib/bakashrot/test.sqlite"
|
||||
topics = ["imagetest"]
|
||||
|
||||
[roles.tester]
|
||||
push_topics = ["imagetest"]
|
||||
read_topics = ["*"]
|
||||
EOF
|
||||
cat >"$work/client.toml" <<EOF
|
||||
server = "$name:7000"
|
||||
ca = "ca.crt"
|
||||
certificate = "tester.crt"
|
||||
key = "tester.key"
|
||||
EOF
|
||||
|
||||
docker run -d --name "$name" --network "$name" -v "$work:/etc/bakashrot:ro" "$image" >/dev/null
|
||||
tries=0
|
||||
until docker logs "$name" 2>&1 | grep -q "listening on"; do
|
||||
tries=$((tries + 1))
|
||||
[ "$tries" -lt 100 ] || fail "the server isn't listening"
|
||||
[ "$(docker inspect -f '{{.State.Running}}' "$name")" = true ] || fail "the server exited"
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
tool bakashrot push imagetest '{"image":"test"}' | grep -q "message #1" || fail "push"
|
||||
tool bakashrot messages imagetest tester | grep -q '"image":"test"' || fail "messages"
|
||||
|
||||
docker stop "$name" >/dev/null
|
||||
[ "$(docker inspect -f '{{.State.ExitCode}}' "$name")" = 0 ] || fail "the server's exit code"
|
||||
docker logs "$name" 2>&1 | grep -q "stopped" || fail "no clean stop"
|
||||
echo "The image: certificates, the server, a push read back, a clean stop: OK"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Who connects to whom, and how it's checked. The code is
|
||||
`crates/bakashrot-pki` (the library) and `crates/bakashrot-tools`
|
||||
(`bakashrot-cert`, the tool). Decided in `../../revamp.md`, "Decided".
|
||||
(`bakashrot-cert`, the tool). Decided in `../revamp.md`, "Decided".
|
||||
|
||||
## The idea
|
||||
|
||||
@@ -11,7 +11,7 @@ What apps connect with, in layers:
|
||||
| Python | `bindings/python/bakashrot.py` | `Client` over the DLL (ctypes), standard library only |
|
||||
| The tools | `crates/bakashrot-tools`: `bakashrot` | the command line, over `bakashrot-client` |
|
||||
|
||||
Decided in `../../revamp.md`, "Decided" (2026-11-13). What goes over the
|
||||
Decided in `../revamp.md`, "Decided" (2026-11-13). What goes over the
|
||||
wire: `protocol.md`; the server's side: `server.md`.
|
||||
|
||||
**Status:** steps 7 to 9: connecting, pushes, messages, attachments,
|
||||
@@ -4,7 +4,7 @@ One TOML file, read and checked at once by `crates/bakashrot-config`: a
|
||||
config that's wrong is refused whole, saying where (the line, shown) and
|
||||
why. Every value is checked as it's read (serde), so every refusal has its
|
||||
line. Every key, with its default: `crates/bakashrot-config/example.toml`.
|
||||
Decided in `../../revamp.md`, "Decided".
|
||||
Decided in `../revamp.md`, "Decided".
|
||||
|
||||
## What's in it
|
||||
|
||||
@@ -72,6 +72,6 @@ With `<PEN>` the number IANA gave:
|
||||
`[1, 3, 6, 1, 4, 1, <PEN>, 1, 1]`, `IDENTITY_OID_IS_PLACEHOLDER` to
|
||||
`false`.
|
||||
3. **Update** this file (the table, "Now"), `certificates.md` and the open
|
||||
point in `../../revamp.md`.
|
||||
point in `../revamp.md`.
|
||||
4. **Issue again** any certificate made with the placeholder, and run
|
||||
`check.ps1` (the tests issue their own, nothing to change there).
|
||||
`test.ps1` (the tests issue their own, nothing to change there).
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`crates/bakashrot-server` (a library and the `bakashrot-server` program)
|
||||
and `crates/bakashrot-client` (the blocking client library the C DLL will
|
||||
wrap). Decided in `../../revamp.md`, "Decided" (2026-11-13). What goes over
|
||||
wrap). Decided in `../revamp.md`, "Decided" (2026-11-13). What goes over
|
||||
the wire: `protocol.md`.
|
||||
|
||||
**Status:** steps 5, 6, 9, 10, 11 and 12: connecting, pushes and their
|
||||
@@ -17,7 +17,7 @@ bakashrot-server server.toml
|
||||
|
||||
The config (`config.md`) gives where to listen, the certificates, the CRL,
|
||||
the database, the topics and the roles. Decided 2026-11-14
|
||||
(`../../revamp.md`, "Operations"):
|
||||
(`../revamp.md`, "Operations"):
|
||||
|
||||
- **Stopping:** SIGTERM or SIGINT on Linux; Ctrl+C, Ctrl+Break or its
|
||||
console closed on Windows. It stops taking connections and writes
|
||||
@@ -46,6 +46,29 @@ Restart=on-failure
|
||||
# SIGTERM, then 90 s at most: far more than a stop takes.
|
||||
```
|
||||
|
||||
### In Docker
|
||||
|
||||
`docker/Dockerfile` (its comments have the details), the image
|
||||
`ghcr.io/aziascreations/bakashrot-server` (amd64 and arm64, pushed by CI
|
||||
on a version tag): the server, with `bakashrot` and `bakashrot-cert`
|
||||
beside it, on `debian:trixie-slim`, as uid 10001.
|
||||
|
||||
- **The config** in `/etc/bakashrot`, read-only: `server.toml`, the
|
||||
certificates, the server's key (readable by uid 10001: `chown 10001`
|
||||
it, `bakashrot-cert` writes keys for their owner only). `listen =
|
||||
"0.0.0.0:7000"`: 127.0.0.1 isn't reachable from outside.
|
||||
- **The database** in `/var/lib/bakashrot`, a volume: `database =
|
||||
"/var/lib/bakashrot/bakashrot.sqlite"`.
|
||||
- **Running it:** `docker/compose.yml` (`docker compose up -d` from
|
||||
`docker/`, the config in `docker/config/`), or `docker run -d -p
|
||||
7000:7000 -v ./config:/etc/bakashrot:ro -v
|
||||
bakashrot-data:/var/lib/bakashrot <image>`. `docker stop` is SIGTERM:
|
||||
a clean stop. The logs: `docker logs`.
|
||||
- **The tools:** `docker run --rm <image> bakashrot-cert ...`.
|
||||
- **Checked** by `docker/test.sh <image>` (CI runs it on both before
|
||||
pushing): certificates by the image's tool, its server, a push read
|
||||
back over a Docker network, `docker stop` ending it cleanly.
|
||||
|
||||
## Inside the server
|
||||
|
||||
| What | Where | How |
|
||||
@@ -77,7 +100,7 @@ Each topic's count is logged ("deleted 3 messages of topic 'logs'").
|
||||
|
||||
## Replication
|
||||
|
||||
Decided in `../../revamp.md` ("Replication by address", 2026-11-14).
|
||||
Decided in `../revamp.md` ("Replication by address", 2026-11-14).
|
||||
Each server's config says who it replicates with, by address
|
||||
(`config.md`, "Peers"): `push_to`, the servers it dials and sends to;
|
||||
`accept_from`, the servers whose messages it takes (`"*"` for all). A link
|
||||
@@ -3,7 +3,7 @@
|
||||
The server's database: one SQLite file. The code is
|
||||
`crates/bakashrot-storage`; the schema is
|
||||
`crates/bakashrot-storage/src/schema_v9.sql`, made in one go. Decided in
|
||||
`../../revamp.md`, "Decided" (2026-11-13).
|
||||
`../revamp.md`, "Decided" (2026-11-13).
|
||||
|
||||
**Not compatible with v8:** a database of the old server isn't opened
|
||||
(refused at start, saying so); its data isn't carried over.
|
||||
@@ -19,13 +19,95 @@ store them in SQLite, and replicate them to other servers by topic and node name
|
||||
* 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
|
||||
Written in Rust, see [Source/README.md](Source/README.md): `cargo build --release` from `Source/`,
|
||||
`python release.py` for a release (Windows x64, Linux x86-64) with its smoke test.
|
||||
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.
|
||||
|
||||
See [revamp.md](revamp.md) for why it was rewritten, what was decided, and the plan.
|
||||
The PureBasic version it replaced (protocol 6) is in the git history: `OldSource/`, up to commit `68966a8`.
|
||||
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
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
# A release for this platform, built, packaged and smoke-tested, into
|
||||
# target\dist\ (release.py, Python 3.11+, does it all).
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File release.ps1 [-SkipTest]
|
||||
param([switch]$SkipTest)
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# The py launcher if it's there, python otherwise.
|
||||
$python = if (Get-Command py -ErrorAction SilentlyContinue) { @("py", "-3") } else { @("python") }
|
||||
$arguments = @(Join-Path $PSScriptRoot "release.py")
|
||||
if ($SkipTest) { $arguments += "--skip-test" }
|
||||
& $python[0] @($python | Select-Object -Skip 1) @arguments
|
||||
exit $LASTEXITCODE
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Builds a BakaShrot release for this machine's platform (Windows x64 or
|
||||
Linux x86-64), checks it works, and archives it:
|
||||
"""Builds a BakaShrot release for this machine's platform (Windows or
|
||||
Linux, x64 or ARM64), checks it works, and archives it:
|
||||
|
||||
python release.py [--skip-test]
|
||||
|
||||
@@ -12,7 +12,7 @@ Into target/dist/:
|
||||
python/bakashrot.py the Python client, over it
|
||||
python/bakashrot-<version>-*.whl the same with the library in it
|
||||
server.example.toml, client.example.toml the configs, documented
|
||||
docs/ Source/docs/
|
||||
docs/ docs/
|
||||
README.txt what's where, how to start
|
||||
LICENSE.txt, THIRD-PARTY.txt BakaShrot's (CC0), its dependencies'
|
||||
bakashrot-<version>-<platform>.zip (Windows) or .tar.gz (Linux)
|
||||
@@ -86,13 +86,27 @@ def version():
|
||||
return version
|
||||
|
||||
|
||||
# The release's name for each Rust host it's built on.
|
||||
PLATFORMS = {
|
||||
"x86_64-pc-windows-msvc": "windows-x64",
|
||||
"aarch64-pc-windows-msvc": "windows-arm64",
|
||||
"x86_64-unknown-linux-gnu": "linux-x64",
|
||||
"aarch64-unknown-linux-gnu": "linux-arm64",
|
||||
}
|
||||
|
||||
|
||||
def platform_name():
|
||||
machine = platform.machine().lower()
|
||||
if WINDOWS and machine in ("amd64", "x86_64"):
|
||||
return "windows-x64"
|
||||
if sys.platform.startswith("linux") and machine == "x86_64":
|
||||
return "linux-x64"
|
||||
fail(f"no release for {sys.platform} {machine}")
|
||||
"""The release's platform: the Rust toolchain's host, which Python must
|
||||
match (the smoke test loads the library into it)."""
|
||||
host = next(line.split()[1] for line in run(["rustc", "-vV"]).splitlines()
|
||||
if line.startswith("host:"))
|
||||
if host not in PLATFORMS:
|
||||
fail(f"no release for {host}")
|
||||
machine = {"amd64": "x86_64", "arm64": "aarch64"}.get(platform.machine().lower(),
|
||||
platform.machine().lower())
|
||||
if not host.startswith(machine + "-"):
|
||||
fail(f"Python is {platform.machine()}, Rust builds for {host}: use a Python of the same")
|
||||
return PLATFORMS[host]
|
||||
|
||||
|
||||
def commit():
|
||||
@@ -218,7 +232,7 @@ def package(built, version, name, out):
|
||||
shutil.copy2(os.path.join(HERE, "crates", "bakashrot-config", "example.toml"),
|
||||
os.path.join(out, "server.example.toml"))
|
||||
write(os.path.join(out, "client.example.toml"), CLIENT_EXAMPLE)
|
||||
shutil.copy2(os.path.join(HERE, "..", "LICENSE"), os.path.join(out, "LICENSE.txt"))
|
||||
shutil.copy2(os.path.join(HERE, "LICENSE"), os.path.join(out, "LICENSE.txt"))
|
||||
write(os.path.join(out, "THIRD-PARTY.txt"), third_party())
|
||||
write(os.path.join(out, "README.txt"), readme(version, name))
|
||||
wheel = run([sys.executable, "-B", os.path.join(bindings, "python", "make_wheel.py"),
|
||||
@@ -11,9 +11,11 @@ retention, replication, operations and releases), see "Plan".
|
||||
- **Old implementation:** PureBasic, protocol 6, schema v8. Removed on
|
||||
2026-11-15 ("The PureBasic version removed"): it's in git history,
|
||||
`OldSource/` up to commit `68966a8`, which the `OldSource/` paths here
|
||||
and in `Source/` point to. What of its notes still holds:
|
||||
`Source/docs/known-issues.md`.
|
||||
- **New implementation:** `Source/`, see `Source/README.md`.
|
||||
and in the code point to. What of its notes still holds:
|
||||
`docs/known-issues.md`.
|
||||
- **New implementation:** the Cargo workspace at the root (in `Source/`
|
||||
until 2026-11-15, so the paths below are relative to the root now),
|
||||
see `readme.md`.
|
||||
|
||||
## Why
|
||||
|
||||
@@ -34,7 +36,8 @@ PureBasic, which has no libraries for it:
|
||||
## Decided
|
||||
|
||||
1. **Rust**, for the server, the client library and DLL, and the tools: one
|
||||
Cargo workspace in `Source/`. Built in the order of "Plan" below.
|
||||
Cargo workspace (in `Source/`, at the root since 2026-11-15). Built in
|
||||
the order of "Plan" below.
|
||||
2. **A C-compatible client DLL**, usable from any language as today: the
|
||||
same kind of exports (`BakaShrot_*A/W`, cdecl), the same conventions
|
||||
(strings copied into the caller's buffers, the size needed returned,
|
||||
@@ -65,7 +68,7 @@ Also decided (2026-11-13):
|
||||
|
||||
- the build order ("Plan"); the protocol crate is `bakashrot-proto`;
|
||||
existing crates rather than our own (MessagePack: `rmp-serde`);
|
||||
- the protocol simplified (`Source/docs/protocol.md`, "What changed"):
|
||||
- the protocol simplified (`docs/protocol.md`, "What changed"):
|
||||
- **names only on the wire**: topics and nodes by name everywhere, each
|
||||
server's ids stay in its database (no refs, no `ResolveName`, no ids
|
||||
in answers or in the sync state);
|
||||
@@ -76,7 +79,7 @@ Also decided (2026-11-13):
|
||||
in the `SyncState`, no echoes in answers;
|
||||
- **attachments streamed inside their request**: no upload ids or
|
||||
expiry, no request or answer per part.
|
||||
- **protocol 7's start** (`Source/docs/protocol.md`): ALPN `bakashrot`, not
|
||||
- **protocol 7's start** (`docs/protocol.md`): ALPN `bakashrot`, not
|
||||
versioned; right after TLS each end sends its version (4 bytes) and
|
||||
checks the other's, abandoning the connection if they differ (the
|
||||
client's error: `VersionMismatch`, 111); then the server's `Welcome`.
|
||||
@@ -138,7 +141,7 @@ Also decided (2026-11-13):
|
||||
revoked one at a time (`bakashrot-cert issue --file`);
|
||||
- optionally, a node blocked by name in the config, whatever certificate
|
||||
it has (emergencies, a node taken down).
|
||||
- **The server's config is TOML** (2026-11-13), `Source/docs/config.md`:
|
||||
- **The server's config is TOML** (2026-11-13), `docs/config.md`:
|
||||
- `[server]`, `[retention]`, `[replication]`, `[roles.<name>]`; unknown
|
||||
keys refused; names only (no ids, pins or ranges);
|
||||
- **roles in the certificate, permissions in the config**: a certificate
|
||||
@@ -159,7 +162,7 @@ Also decided (2026-11-13):
|
||||
replicated at all, whatever the roles say, to filter on edge nodes.
|
||||
- **Schema v9, not compatible with v8** (2026-11-13): old databases aren't
|
||||
opened, their data isn't carried over (the real-life tests start empty).
|
||||
`Source/docs/storage.md`:
|
||||
`docs/storage.md`:
|
||||
- **streams** (a topic and node pair: its id, names, last id) instead of
|
||||
`topics`, `nodes` and `node_heads`;
|
||||
- **packed keys**: a message's key is `stream_id << 43 | message_id`, one
|
||||
@@ -171,7 +174,7 @@ Also decided (2026-11-13):
|
||||
queries read their streams, an index is a migration away if needed;
|
||||
- `attachments` (five states) and `attachment_parts`, uploads inside
|
||||
their push; a `metadata` table with `schema_version` for migrations.
|
||||
- **The server and the client** (2026-11-13), `Source/docs/server.md`:
|
||||
- **The server and the client** (2026-11-13), `docs/server.md`:
|
||||
- **crates:** `tokio` and `tokio-rustls` on the server, `tracing` for
|
||||
its logs; the client blocking (std and `rustls`, no runtime). Named
|
||||
`bakashrot-server` (also the program: `bakashrot-server
|
||||
@@ -183,7 +186,7 @@ Also decided (2026-11-13):
|
||||
silence before the server closes, 30 s for an answer (the client);
|
||||
- **the writer:** one thread, a queue, group commits; WAL checkpoints on
|
||||
a thread of their own.
|
||||
- **The DLL** (2026-11-13), `Source/docs/client.md`:
|
||||
- **The DLL** (2026-11-13), `docs/client.md`:
|
||||
- **connecting:** `BakaShrot_SetCaCertificate()`, `_SetCertificate()`,
|
||||
`_SetPrivateKey()`, `_SetCrl()`, each taking PEM text or a file's path;
|
||||
- **the old exports that don't fit any more are dropped**, not kept
|
||||
@@ -192,13 +195,13 @@ Also decided (2026-11-13):
|
||||
- **one connection per process**, as before (handles maybe later);
|
||||
- **`client.toml`** (server, ca, certificate, key, crl) replaces
|
||||
`client.ini`: Python's `Client.from_file()`, the tools at step 8.
|
||||
- **The tools** (2026-11-14), `Source/docs/client.md`, "The tools": one
|
||||
- **The tools** (2026-11-14), `docs/client.md`, "The tools": one
|
||||
`bakashrot` program with subcommands (`push`, `latest`, `messages`,
|
||||
`query`, `list`) over `bakashrot-client`, `bakashrot-cert` kept apart
|
||||
(the CA's key); `-c/--config`, `client.toml` by default; the old tools'
|
||||
output; messages and SQL inline, `@file` or `-` (standard input); exit
|
||||
codes 0, 1, and 2 for bad arguments.
|
||||
- **Attachments** (2026-11-14), `Source/docs/server.md` and `client.md`:
|
||||
- **Attachments** (2026-11-14), `docs/server.md` and `client.md`:
|
||||
- **the DLL keeps the old six exports**, by names: `PushMessageWithFile`,
|
||||
`PushMessageWithData`, `SaveAttachment`, `LoadAttachment` then
|
||||
`GetAttachmentData` and `FreeAttachmentData`;
|
||||
@@ -210,14 +213,14 @@ Also decided (2026-11-13):
|
||||
`get_attachment()`, `save_attachment()`;
|
||||
- **the SHA-256 through `aws-lc-rs`**, already built for TLS, instead of
|
||||
the `sha2` proposed: no other crate, and faster.
|
||||
- **Randomness from the OS** (2026-11-14), `Source/docs/certificates.md`,
|
||||
- **Randomness from the OS** (2026-11-14), `docs/certificates.md`,
|
||||
"TLS": aws-lc built without CPU Jitter Entropy
|
||||
(`AWS_LC_SYS_NO_JITTER_ENTROPY`, `Source/.cargo/config.toml`), its random
|
||||
(`AWS_LC_SYS_NO_JITTER_ENTROPY`, `.cargo/config.toml`), its random
|
||||
generator seeded from the OS's (Windows' `ProcessPrng`, Linux's
|
||||
`getrandom`) and RDRAND, as BoringSSL and `ring` do. The jitter seeding
|
||||
took 25 ms in every process at its first connection: a tool command went
|
||||
from 36 ms to 11 ms (the old tools: 8).
|
||||
- **Replication by address** (2026-11-14), `Source/docs/config.md`:
|
||||
- **Replication by address** (2026-11-14), `docs/config.md`:
|
||||
- **each server's config says who it replicates with**, by IP or
|
||||
hostname: `[replication] push_to`, the servers it dials and sends to
|
||||
(`host:port`, was `peers`), and `accept_from`, the servers whose
|
||||
@@ -230,9 +233,9 @@ Also decided (2026-11-13):
|
||||
- **`accept_from` is for servers only:** clients push wherever their
|
||||
roles allow, as now. A node pushing to one server only stays the
|
||||
config's rule, not checked, as in the old version
|
||||
(`Source/docs/known-issues.md`).
|
||||
- **Operations** (2026-11-14), `Source/docs/server.md`, "Running";
|
||||
`Source/README.md`, "Releases":
|
||||
(`docs/known-issues.md`).
|
||||
- **Operations** (2026-11-14), `docs/server.md`, "Running";
|
||||
`readme.md`, "Releases":
|
||||
- **signals only:** SIGTERM and SIGINT on Linux; Ctrl+C, Ctrl+Break or
|
||||
the console closed on Windows; each stops it cleanly. No Windows
|
||||
service mode (a tool like NSSM if needed); more only if needed later;
|
||||
@@ -247,11 +250,28 @@ Also decided (2026-11-13):
|
||||
- **version 0.2.0.**
|
||||
- **The PureBasic version removed** (2026-11-15): `OldSource/` deleted,
|
||||
kept in git history (up to `68966a8`). What of its notes and designs
|
||||
still holds went to `Source/docs/known-issues.md`; the rest was already
|
||||
in `Source/docs/` or only about PureBasic. Its PowerShell suites go
|
||||
with it: the Rust tests (`cargo test`, `check.ps1`, CI) are the one
|
||||
still holds went to `docs/known-issues.md`; the rest was already
|
||||
in `docs/` or only about PureBasic. Its PowerShell suites go
|
||||
with it: the Rust tests (`cargo test`, `test.ps1`, CI) are the one
|
||||
runner, with `release.py`'s smoke test across processes (old open item
|
||||
7).
|
||||
- **The workspace at the root** (2026-11-15): `Source/`'s content moved
|
||||
up, `Source/README.md` merged into `readme.md`; scripts at the root:
|
||||
`build.ps1`, `test.ps1` (was `check.ps1`), `release.ps1` (over
|
||||
`release.py`, which CI's Linux job runs as is), `clean.ps1`. CI is
|
||||
`.github/workflows/ci.yml`.
|
||||
- **CI on tags only** (2026-11-15): a `v*` tag (or a run by hand) runs
|
||||
the checks, then a release for Windows x64 and ARM64, Linux x64 and
|
||||
ARM64, each on its own kind of runner (the smoke test runs there), the
|
||||
archives kept as the run's artifacts. Nothing runs on pushes:
|
||||
`test.ps1` is run here before.
|
||||
- **Docker** (2026-11-15): `docker/` (Dockerfile, compose.yml, test.sh):
|
||||
the server and the tools, built from source, on `debian:trixie-slim`,
|
||||
as uid 10001. CI builds amd64 and arm64 natively, checks each with
|
||||
`docker/test.sh`, and on a tag pushes them to
|
||||
`ghcr.io/aziascreations/bakashrot-server` with the workflow's token,
|
||||
then an index of both as `<version>` and `latest` (once the releases
|
||||
passed). The Gitea registry stays a push by hand.
|
||||
|
||||
## Proposed, to confirm
|
||||
|
||||
@@ -273,7 +293,7 @@ come back as text either way; only what SQL computes would gain
|
||||
`IDENTITY_OID_IS_PLACEHOLDER` is `true` and `bakashrot-cert` warns when
|
||||
it makes a certificate. Certificates issued with it stop being read once
|
||||
it changes: get the number before any is in use. How to request it and
|
||||
what to change then: `Source/docs/oid.md`.
|
||||
what to change then: `docs/oid.md`.
|
||||
|
||||
## Kept: the behaviour to carry over
|
||||
|
||||
@@ -346,7 +366,7 @@ hand in each).
|
||||
|
||||
| # | Step | What | Done when | Decide first | Status |
|
||||
|---|---|---|---|---|---|
|
||||
| 0 | Workspace | Cargo workspace, pinned toolchain, `check.ps1`, CI (fmt, clippy, test, doc) | The crates build, the checks pass | Crate names | Done 2026-11-13 |
|
||||
| 0 | Workspace | Cargo workspace, pinned toolchain, `test.ps1`, CI (fmt, clippy, test, doc) | The crates build, the checks pass | Crate names | Done 2026-11-13 |
|
||||
| 1 | `bakashrot-proto` | Names, error codes, limits, every packet, frames | Round trips, refusals, random input never panics | The packet format | Done 2026-11-13, simplified the same day |
|
||||
| 2 | `bakashrot-pki` + certificate tool | CA, server, client, peer certificates (P-384, the identity extension); name and roles read; the TLS setup (AES-256-GCM, X25519MLKEM768, the fixed server name); CRLs and their reload | `openssl verify` takes the tool's certificates; a TLS test accepts and refuses the right ones, a revoked one dropped | Decided 2026-11-13 | Done 2026-11-13 |
|
||||
| 3 | `bakashrot-config` | Server config: topics, roles to permissions, peers, retention, clear errors | `schema.ini`'s cases, the configs `Names-Test` refuses | TOML, roles (decided 2026-11-13) | Done 2026-11-13 |
|
||||
@@ -359,10 +379,10 @@ hand in each).
|
||||
| 10 | Retention | Background deletion, `node_heads` kept, attachments cleaned up | `Retention-Test`'s local checks | | Done 2026-11-14 |
|
||||
| 11 | Replication | Peer links, sync state, batches by name, wildcards, attachments, skipping on arrival | `Names-Test` (replication), `Restart-Test`; the corrupted-attachment fix | Decided 2026-11-14 | Done 2026-11-14 |
|
||||
| 12 | Operations | Signals and a clean stop, logs, release, wheel | Runs unattended, stops cleanly, the release's smoke test | Decided 2026-11-14 | Done 2026-11-14 |
|
||||
| 13 | Finish | One test runner (the Rust tests, decided 2026-11-15), end-to-end tests in CI, the bench, Docker | Push speed against the old ~17,000 msg/s (4 servers, measured 2026-11-14: `Source/docs/server.md`) | | |
|
||||
| 13 | Finish | One test runner (the Rust tests, decided 2026-11-15), end-to-end tests in CI, the bench, Docker | Push speed against the old ~17,000 msg/s (4 servers, measured 2026-11-14: `docs/server.md`) | | |
|
||||
|
||||
Each step ends with its tests passing and its docs updated (the crate's
|
||||
docs, `Source/docs/`, this file's status), then a commit when the owner
|
||||
docs, `docs/`, this file's status), then a commit when the owner
|
||||
asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: steps 0 and 1 (2026-11-13)
|
||||
@@ -371,8 +391,8 @@ asks. Open questions get settled at the step that needs them.
|
||||
`unsafe_code` denied, docs required, clippy's defaults; release profile
|
||||
with LTO, `panic = "unwind"` for the DLL's `catch_unwind`),
|
||||
`rust-toolchain.toml` (1.100.0, rustfmt, clippy), `.gitattributes` (LF),
|
||||
`check.ps1` (fmt, clippy with warnings as errors, tests, docs),
|
||||
`../.github/workflows/source.yml` (the same on Windows and Linux, Gitea
|
||||
`test.ps1` (fmt, clippy with warnings as errors, tests, docs),
|
||||
`../.github/workflows/ci.yml` (the same on Windows and Linux, Gitea
|
||||
Actions reads it too; not run yet, nothing pushed).
|
||||
- **`bakashrot-proto`**, on `serde`, `rmp-serde` and `serde_bytes`
|
||||
(first written over `rmp` with hand-written packets, then simplified the
|
||||
@@ -398,7 +418,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
ALPN tied to the version by a test; the batch sizes (~1 MiB per
|
||||
`Messages`, ~64 KiB per `ReplicateMessages`) left the protocol crate,
|
||||
they're the server's to set (steps 6 and 11).
|
||||
- **`Source/docs/protocol.md`**: protocol 7, every packet, the flows, what
|
||||
- **`docs/protocol.md`**: protocol 7, every packet, the flows, what
|
||||
changed from 6.
|
||||
- **Left for later steps:** the TLS side of the protocol (ALPN, `Welcome`
|
||||
sent first: steps 2 and 5); generating the C, PureBasic and Python
|
||||
@@ -407,7 +427,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 2 (2026-11-13)
|
||||
|
||||
`Source/docs/certificates.md` has all of it.
|
||||
`docs/certificates.md` has all of it.
|
||||
|
||||
- **`bakashrot-pki`**, on `rcgen`, `rustls` (aws-lc), `x509-parser`
|
||||
(`verify-aws`, the same aws-lc) and `yasna`:
|
||||
@@ -450,8 +470,8 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 3 (2026-11-13)
|
||||
|
||||
`Source/docs/config.md` has all of it; every key with its default:
|
||||
`Source/crates/bakashrot-config/example.toml`.
|
||||
`docs/config.md` has all of it; every key with its default:
|
||||
`crates/bakashrot-config/example.toml`.
|
||||
|
||||
- **`bakashrot-config`**, on `toml` and `serde` (`indexmap` for the
|
||||
file's order): `Config::load()` (paths from the config's folder) and
|
||||
@@ -479,7 +499,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 4 (2026-11-13)
|
||||
|
||||
`Source/docs/storage.md` has all of it (the layout, why, the numbers).
|
||||
`docs/storage.md` has all of it (the layout, why, the numbers).
|
||||
|
||||
- **`bakashrot-storage`**, on `rusqlite` (SQLite bundled):
|
||||
- `Database::open`: makes a v9 database, opens one, refuses the old
|
||||
@@ -516,7 +536,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 5 (2026-11-13)
|
||||
|
||||
`Source/docs/server.md` has all of it.
|
||||
`docs/server.md` has all of it.
|
||||
|
||||
- **`bakashrot-server`**: TLS with `bakashrot-pki`'s settings, the versions,
|
||||
the identity and its roles (refused with `NotAllowed` when none is
|
||||
@@ -541,7 +561,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 6 (2026-11-13)
|
||||
|
||||
`Source/docs/server.md`, "Requests so far".
|
||||
`docs/server.md`, "Requests so far".
|
||||
|
||||
- **`GetMessages`** refuses an unknown topic (not the config's) or node
|
||||
(no messages in any topic) with `UnknownName`, as the old server did; a
|
||||
@@ -558,7 +578,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 7 (2026-11-13)
|
||||
|
||||
`Source/docs/client.md` has all of it.
|
||||
`docs/client.md` has all of it.
|
||||
|
||||
- **`bakashrot-capi`** builds `bakashrot.dll` / `libbakashrot.so`: the old
|
||||
exports over `bakashrot-client` (A and W, buffers, `GetLastError`, the
|
||||
@@ -579,7 +599,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 8 (2026-11-14)
|
||||
|
||||
`Source/docs/client.md`, "The tools".
|
||||
`docs/client.md`, "The tools".
|
||||
|
||||
- **`bakashrot`** (`bakashrot-tools`): `push <topic> <message>`, `latest
|
||||
<topic> <node>`, `messages <topic> <node>` (`--after <id|latest>`,
|
||||
@@ -598,7 +618,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 9 (2026-11-14)
|
||||
|
||||
`Source/docs/server.md` ("Requests"), `client.md`.
|
||||
`docs/server.md` ("Requests"), `client.md`.
|
||||
|
||||
- **The server:** a push with an attachment is checked (topic, roles,
|
||||
sizes, the server's `max_attachment_size`), answered `Continue`, then
|
||||
@@ -632,7 +652,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 10 (2026-11-14)
|
||||
|
||||
`Source/docs/server.md` ("Retention").
|
||||
`docs/server.md` ("Retention").
|
||||
|
||||
- **The server:** a task (`retention.rs`, `Server::apply_retention()`):
|
||||
at start, then every `retention_interval`, every topic in the database
|
||||
@@ -650,7 +670,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 11 (2026-11-14)
|
||||
|
||||
`Source/docs/server.md` ("Replication"), `config.md` ("Peers").
|
||||
`docs/server.md` ("Replication"), `config.md` ("Peers").
|
||||
|
||||
- **The config:** `[replication] push_to` (was `peers`) and
|
||||
`accept_from` (IPs or hostnames, `"*"`), as decided.
|
||||
@@ -678,7 +698,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
storage's `replication` (skipped on arrival, `to_replicate`,
|
||||
`damaged`); the config's (`push_to`, `accept_from`, `peers` refused,
|
||||
`accepted()`).
|
||||
- **Measured** (`Source/docs/server.md`, "Replication, against the old
|
||||
- **Measured** (`docs/server.md`, "Replication, against the old
|
||||
server"): 4 servers in a Y, 10 nodes each flat out: 16,000-16,300
|
||||
pushes/s with `full` (old: 16,638), 35,300-37,500 with `normal` (old:
|
||||
33,895), and the servers keeping up while pushing (under 1 s behind,
|
||||
@@ -691,7 +711,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### Done: step 12 (2026-11-14)
|
||||
|
||||
`Source/docs/server.md` ("Running"), `Source/README.md` ("Releases").
|
||||
`docs/server.md` ("Running"), `readme.md` ("Releases").
|
||||
|
||||
- **Stopping:** `bakashrot-server` waits for SIGTERM or SIGINT (Linux),
|
||||
Ctrl+C, Ctrl+Break or its console closed (Windows), stops taking
|
||||
@@ -701,7 +721,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
with 0.
|
||||
- **Logs:** the console, no colour codes when redirected,
|
||||
`BAKASHROT_LOG` for the level. No console commands.
|
||||
- **The release:** `Source/release.py`, for the platform it runs on:
|
||||
- **The release:** `release.py`, for the platform it runs on:
|
||||
builds, packages into `target/dist/bakashrot-0.2.0-<platform>/` (the
|
||||
three programs, the library, `bakashrot.h`, the PureBasic files,
|
||||
`bakashrot.py` and its wheel, the example configs, the docs, a
|
||||
@@ -716,7 +736,7 @@ asks. Open questions get settled at the step that needs them.
|
||||
the standard library, the same inputs giving the same wheel):
|
||||
`win_amd64`, or `manylinux_<glibc>_x86_64` from the glibc it's built
|
||||
against; the licenses in it.
|
||||
- **CI** (`.github/workflows/source.yml`): a `release` job on a `v*` tag
|
||||
- **CI** (`.github/workflows/ci.yml`): a `release` job on a `v*` tag
|
||||
or by hand, Windows and Linux (in `manylinux_2_28`), keeping the
|
||||
archives.
|
||||
- **The version:** 0.2.0, the workspace's; `release.py` checks
|
||||
@@ -737,7 +757,9 @@ asks. Open questions get settled at the step that needs them.
|
||||
|
||||
### For step 13: what the old Docker image did
|
||||
|
||||
From `OldSource/Docker/` (git history), to keep in the new one:
|
||||
From `OldSource/Docker/` (git history), kept in `docker/` (the config
|
||||
in `/etc/bakashrot`, the database in a volume, the source label, a user
|
||||
of its own; the image is an index now, its annotations hold the label):
|
||||
|
||||
- A multi-stage build, the final image only the server and what it
|
||||
needs; `docker compose up -d --build` with the config in a mounted
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Runs what CI runs (../.github/workflows/source.yml), in this order:
|
||||
# Runs what CI runs (.github/workflows/ci.yml), in this order:
|
||||
# formatting, clippy (warnings are errors), the tests, the docs.
|
||||
# Exit code 0 when everything passed.
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File Source\check.ps1
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File test.ps1
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# rustup's folder isn't always on the PATH (it isn't in every shell here).
|
||||
Reference in New Issue
Block a user