mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Merged bakashrot-cert into bakashrot as bakashrot cert, Made the programs smaller, Added a -HybridCrt switch
- `bakashrot cert ca|issue|revoke|show` (same options) replaces bakashrot-cert: aws-lc, the C runtime and clap once, 2.53 MB instead of 2.85 + 1.73 MB on Windows; guides, docs, release.py, Docker updated - The tool built with its own profile, release-tools (panic = "abort", about 15% smaller); the DLL and the server keep unwind - clap without colours and suggestions (40 KB, 9 crates fewer) - SQLite without FTS3/FTS5, R-Tree, dbstat, STAT4, soundex(), extension loading and column metadata (LIBSQLITE3_FLAGS): the server 4.68 to 4.37 MB; a storage test checks they're out - build.ps1 / release.ps1 -HybridCrt (.cargo/hybrid-crt.toml): the UCRT from Windows, about 180 KB less per program, still nothing to install; static stays the default, README.txt says which - revamp.md: what was weighed and left (UPX, fully dynamic CRT, nightly options, OMIT_* flags), aws-lc kept over Graviola (490 KB bigger) and ring (no ML-KEM) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,3 +9,8 @@ rustflags = ["-C", "target-feature=+crt-static"]
|
|||||||
# 2026-11-14 (../revamp.md, "Randomness from the OS"; ../docs/certificates.md).
|
# 2026-11-14 (../revamp.md, "Randomness from the OS"; ../docs/certificates.md).
|
||||||
[env]
|
[env]
|
||||||
AWS_LC_SYS_NO_JITTER_ENTROPY = "1"
|
AWS_LC_SYS_NO_JITTER_ENTROPY = "1"
|
||||||
|
# SQLite (rusqlite's `bundled`) without what libsqlite3-sys turns on and
|
||||||
|
# nothing here uses: full-text search, R-Tree, dbstat, STAT4, soundex(),
|
||||||
|
# extension loading, column metadata. 310 KB less in the server (6.6%).
|
||||||
|
# Decided 2026-11-17 (../revamp.md, "One tool, smaller"; ../docs/storage.md).
|
||||||
|
LIBSQLITE3_FLAGS = "-USQLITE_ENABLE_FTS3 -USQLITE_ENABLE_FTS3_PARENTHESIS -USQLITE_ENABLE_FTS5 -USQLITE_ENABLE_RTREE -USQLITE_ENABLE_DBSTAT_VTAB -USQLITE_ENABLE_STAT4 -USQLITE_SOUNDEX -USQLITE_ENABLE_LOAD_EXTENSION -USQLITE_ENABLE_COLUMN_METADATA"
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# The hybrid C runtime on Windows (MSVC), instead of the static one: the
|
||||||
|
# UCRT from Windows (part of it since Windows 10, which Rust needs anyway),
|
||||||
|
# VCRuntime still static. About 180 KB less per program, still no Visual
|
||||||
|
# C++ redistributable; measured 2026-11-17. Not the default (../revamp.md,
|
||||||
|
# "Decided" 2): build.ps1 -HybridCrt, release.ps1 -HybridCrt, or
|
||||||
|
# `cargo build --config .cargo/hybrid-crt.toml`. Cargo adds these flags to
|
||||||
|
# config.toml's (+crt-static stays). Switching rebuilds everything.
|
||||||
|
[target.'cfg(all(windows, target_env = "msvc"))']
|
||||||
|
rustflags = ["-C", "link-arg=/NODEFAULTLIB:libucrt.lib", "-C", "link-arg=/DEFAULTLIB:ucrt.lib"]
|
||||||
Generated
-76
@@ -2,56 +2,12 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstream"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"anstyle-parse",
|
|
||||||
"anstyle-query",
|
|
||||||
"anstyle-wincon",
|
|
||||||
"colorchoice",
|
|
||||||
"is_terminal_polyfill",
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle"
|
name = "anstyle"
|
||||||
version = "1.0.14"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-parse"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
|
|
||||||
dependencies = [
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-query"
|
|
||||||
version = "1.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
|
||||||
dependencies = [
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-wincon"
|
|
||||||
version = "3.0.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"once_cell_polyfill",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asn1-rs"
|
name = "asn1-rs"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
@@ -304,10 +260,8 @@ version = "4.6.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
|
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"strsim",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -337,12 +291,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colorchoice"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "data-encoding"
|
name = "data-encoding"
|
||||||
version = "2.11.1"
|
version = "2.11.1"
|
||||||
@@ -526,12 +474,6 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "is_terminal_polyfill"
|
|
||||||
version = "1.70.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
@@ -674,12 +616,6 @@ version = "1.21.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell_polyfill"
|
|
||||||
version = "1.70.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pem"
|
name = "pem"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
@@ -973,12 +909,6 @@ dependencies = [
|
|||||||
"rsqlite-vfs",
|
"rsqlite-vfs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.6.1"
|
version = "2.6.1"
|
||||||
@@ -1265,12 +1195,6 @@ version = "0.9.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf8parse"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
|
|||||||
+10
-1
@@ -34,5 +34,14 @@ lto = true
|
|||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
strip = true
|
strip = true
|
||||||
# Kept on purpose: the C DLL catches panics at every export (catch_unwind),
|
# Kept on purpose: the C DLL catches panics at every export (catch_unwind),
|
||||||
# which "abort" would make impossible.
|
# which "abort" would make impossible, and the server loses only the
|
||||||
|
# connection that panicked (tokio catches it), not every one.
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
|
||||||
|
# The tool (bakashrot), released with this (build.ps1, release.py, the
|
||||||
|
# Dockerfile): a panic ends its command either way, and without unwinding
|
||||||
|
# it's about 15% smaller (measured 2026-11-17 on Windows: 2.53 MB, its
|
||||||
|
# certificates' commands in it). Its own folder, target/release-tools/.
|
||||||
|
[profile.release-tools]
|
||||||
|
inherits = "release"
|
||||||
|
panic = "abort"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ stored, a str that may or may not be JSON: parsing them is up to the app
|
|||||||
print(message.id, message.json())
|
print(message.id, message.json())
|
||||||
|
|
||||||
Who the client is comes from its certificate, issued by the CA the server
|
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
|
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
|
do. client.toml says where the server is and where the certificates are
|
||||||
(docs/client.md):
|
(docs/client.md):
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
# Builds everything (the server, the tools, the client library), release
|
# Builds everything (the server, the tool, the client library), release
|
||||||
# mode, into target\release\.
|
# mode, into target\release\: the tool with its own profile (release-tools,
|
||||||
# Usage: powershell -ExecutionPolicy Bypass -File build.ps1
|
# Cargo.toml) in target\release-tools\, then copied beside the others.
|
||||||
|
# -HybridCrt: the UCRT from Windows instead of linked in, about 180 KB less
|
||||||
|
# per program (.cargo/hybrid-crt.toml).
|
||||||
|
# Usage: powershell -ExecutionPolicy Bypass -File build.ps1 [-HybridCrt]
|
||||||
|
param([switch]$HybridCrt)
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
$crt = if ($HybridCrt) { @("--config", ".cargo/hybrid-crt.toml") } else { @() }
|
||||||
|
|
||||||
# rustup's folder isn't always on the PATH (it isn't in every shell here).
|
# rustup's folder isn't always on the PATH (it isn't in every shell here).
|
||||||
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
||||||
@@ -10,8 +15,12 @@ if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
|||||||
|
|
||||||
Push-Location $PSScriptRoot
|
Push-Location $PSScriptRoot
|
||||||
try {
|
try {
|
||||||
cargo build --workspace --release --locked
|
cargo build --workspace --exclude bakashrot-tools --release --locked @crt
|
||||||
if ($LASTEXITCODE -ne 0) { "FAILED: cargo build"; exit 1 }
|
if ($LASTEXITCODE -ne 0) { "FAILED: cargo build"; exit 1 }
|
||||||
|
cargo build -p bakashrot-tools --profile release-tools --locked @crt
|
||||||
|
if ($LASTEXITCODE -ne 0) { "FAILED: cargo build (the tool)"; exit 1 }
|
||||||
|
$tool = if ($IsLinux -or $IsMacOS) { "bakashrot" } else { "bakashrot.exe" }
|
||||||
|
Copy-Item (Join-Path "target\release-tools" $tool) "target\release" -Force
|
||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -8,13 +8,13 @@ From the repository's root, on Windows (`powershell -ExecutionPolicy Bypass -Fil
|
|||||||
|
|
||||||
| Script | What it does |
|
| Script | What it does |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `build.ps1` | Builds everything, release mode, into `target\release\` |
|
| `build.ps1` | Builds everything, release mode, into `target\release\` (the tool with the `release-tools` profile, copied there); `-HybridCrt` |
|
||||||
| `test.ps1` | What CI runs: formatting, clippy (warnings are errors), the tests, the docs |
|
| `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` |
|
| `release.ps1` | A release for this platform, smoke-tested (`release.py`, below); `-SkipTest`, `-HybridCrt` |
|
||||||
| `clean.ps1` | Deletes `target\` (builds and releases) |
|
| `clean.ps1` | Deletes `target\` (builds and releases) |
|
||||||
| `bench.ps1` | The benchmarks, release mode: pushes, replication, storage (`docs/server.md`, "Measured"); `-Only`, `-Sync full` or `normal` |
|
| `bench.ps1` | The benchmarks, release mode: pushes, replication, storage (`docs/server.md`, "Measured"); `-Only`, `-Sync full` or `normal` |
|
||||||
|
|
||||||
Elsewhere, the same with cargo: `cargo build --release`, `cargo test`, `python release.py`, `cargo clean`;
|
Elsewhere, the same with cargo: `cargo build --release` (and `-p bakashrot-tools --profile release-tools`), `cargo test`, `python release.py`, `cargo clean`;
|
||||||
the benchmarks are ignored tests (`cargo test --release -- --ignored`).
|
the benchmarks are ignored tests (`cargo test --release -- --ignored`).
|
||||||
Generated keys and certificates never go in git.
|
Generated keys and certificates never go in git.
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ Generated keys and certificates never go in git.
|
|||||||
A Cargo workspace:
|
A Cargo workspace:
|
||||||
|
|
||||||
```
|
```
|
||||||
Cargo.toml the workspace: shared lints, release profile
|
Cargo.toml the workspace: shared lints, the release profiles (release-tools: the tool's)
|
||||||
rust-toolchain.toml the pinned toolchain (1.100.0)
|
rust-toolchain.toml the pinned toolchain (1.100.0)
|
||||||
build.ps1, test.ps1, release.ps1, clean.ps1, bench.ps1
|
build.ps1, test.ps1, release.ps1, clean.ps1, bench.ps1
|
||||||
release.py a release for this platform: build, package, smoke test
|
release.py a release for this platform: build, package, smoke test
|
||||||
@@ -37,23 +37,24 @@ crates/
|
|||||||
bakashrot-server/ the server: TLS, identities, requests, the writer thread (and its program)
|
bakashrot-server/ the server: TLS, identities, requests, the writer thread (and its program)
|
||||||
bakashrot-client/ the client library, Rust API, blocking
|
bakashrot-client/ the client library, Rust API, blocking
|
||||||
bakashrot-capi/ the C DLL over bakashrot-client: the BakaShrot_* exports (bakashrot.dll)
|
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
|
bakashrot-tools/ the CLI tool: bakashrot (push, read, query, list; cert: the certificates)
|
||||||
bindings/
|
bindings/
|
||||||
c/ bakashrot.h, generated from bakashrot-capi
|
c/ bakashrot.h, generated from bakashrot-capi
|
||||||
purebasic/ the prototypes and error codes
|
purebasic/ the prototypes and error codes
|
||||||
python/ bakashrot.py over the DLL, check_bakashrot.py, make_wheel.py
|
python/ bakashrot.py over the DLL, check_bakashrot.py, make_wheel.py
|
||||||
.cargo/config.toml the C runtime linked statically on Windows
|
.cargo/config.toml the C runtime linked statically on Windows, SQLite's options
|
||||||
|
.cargo/hybrid-crt.toml -HybridCrt: the UCRT from Windows instead (about 180 KB less per program)
|
||||||
docker/ the server's image: Dockerfile, compose.yml, test.sh
|
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
|
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`.
|
on their own; `server` and `client` use them; the DLL and the tool only use `client`.
|
||||||
|
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
`python release.py` (or `release.ps1`) on Windows or Linux, x64 or ARM64, builds that platform's release into
|
`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`):
|
`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,
|
the server, `bakashrot` (the certificates too: `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,
|
`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`).
|
`docs/`, a `README.txt`, the licenses (`THIRD-PARTY.txt`: every crate built in, from `cargo metadata`).
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
[server]
|
[server]
|
||||||
listen = "0.0.0.0:7000" # required: address and port
|
listen = "0.0.0.0:7000" # required: address and port
|
||||||
|
|
||||||
# The certificates (bakashrot-cert), required. The node this server is,
|
# The certificates (bakashrot cert), required. The node this server is,
|
||||||
# for its peers, is its certificate's name.
|
# for its peers, is its certificate's name.
|
||||||
ca = "ca.crt"
|
ca = "ca.crt"
|
||||||
certificate = "server-1.crt"
|
certificate = "server-1.crt"
|
||||||
|
|||||||
@@ -687,6 +687,28 @@ fn queries() {
|
|||||||
json("SELECT count(*) FROM messages")["rows"],
|
json("SELECT count(*) FROM messages")["rows"],
|
||||||
serde_json::json!([["3"]])
|
serde_json::json!([["3"]])
|
||||||
);
|
);
|
||||||
|
// SQLite without what nothing here uses (LIBSQLITE3_FLAGS in
|
||||||
|
// .cargo/config.toml): not built in, nor loadable.
|
||||||
|
for option in [
|
||||||
|
"ENABLE_FTS3",
|
||||||
|
"ENABLE_FTS5",
|
||||||
|
"ENABLE_RTREE",
|
||||||
|
"ENABLE_DBSTAT_VTAB",
|
||||||
|
"ENABLE_STAT4",
|
||||||
|
"SOUNDEX",
|
||||||
|
"ENABLE_LOAD_EXTENSION",
|
||||||
|
"ENABLE_COLUMN_METADATA",
|
||||||
|
] {
|
||||||
|
assert_eq!(
|
||||||
|
json(&format!("SELECT sqlite_compileoption_used('{option}')"))["rows"],
|
||||||
|
serde_json::json!([["0"]]),
|
||||||
|
"{option}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert!(matches!(
|
||||||
|
runner.run("SELECT * FROM dbstat"),
|
||||||
|
Err(Error::Query(_))
|
||||||
|
));
|
||||||
// A failing row fails it all, with SQLite's message.
|
// A failing row fails it all, with SQLite's message.
|
||||||
match runner.run("SELECT message_data ->> '$.t' FROM messages") {
|
match runner.run("SELECT message_data ->> '$.t' FROM messages") {
|
||||||
Err(Error::Query(why)) => assert!(why.contains("malformed JSON"), "{why}"),
|
Err(Error::Query(why)) => assert!(why.contains("malformed JSON"), "{why}"),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bakashrot-tools"
|
name = "bakashrot-tools"
|
||||||
description = "BakaShrot's command-line tools: bakashrot pushes and reads messages, bakashrot-cert issues certificates and revokes them."
|
description = "BakaShrot's command-line tool: bakashrot pushes and reads messages, bakashrot cert issues certificates and revokes them."
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
rust-version.workspace = true
|
rust-version.workspace = true
|
||||||
@@ -9,17 +9,21 @@ authors.workspace = true
|
|||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
publish.workspace = true
|
publish.workspace = true
|
||||||
|
|
||||||
# No API to document, and its name is the DLL's library's (cargo doc would
|
# One program, the certificates' commands in it (`bakashrot cert`): aws-lc,
|
||||||
# collide).
|
# the C runtime and clap once, not in two programs. No API to document, and
|
||||||
|
# its name is the DLL's library's (cargo doc would collide). Released with
|
||||||
|
# the `release-tools` profile (../../Cargo.toml).
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "bakashrot"
|
name = "bakashrot"
|
||||||
|
path = "src/main.rs"
|
||||||
doc = false
|
doc = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bakashrot-client = { path = "../bakashrot-client" }
|
bakashrot-client = { path = "../bakashrot-client" }
|
||||||
bakashrot-pki = { path = "../bakashrot-pki" }
|
bakashrot-pki = { path = "../bakashrot-pki" }
|
||||||
bakashrot-proto = { path = "../bakashrot-proto" }
|
bakashrot-proto = { path = "../bakashrot-proto" }
|
||||||
clap = { version = "4", features = ["derive"] }
|
# Without colours and "did you mean" suggestions: 40 KB less.
|
||||||
|
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] }
|
||||||
serde = { version = "1.0.229", features = ["derive"] }
|
serde = { version = "1.0.229", features = ["derive"] }
|
||||||
serde_json = "1.0.154"
|
serde_json = "1.0.154"
|
||||||
time = "0.3.55"
|
time = "0.3.55"
|
||||||
|
|||||||
+8
-28
@@ -1,27 +1,16 @@
|
|||||||
//! `bakashrot-cert`: makes a CA, issues certificates, revokes them, shows
|
//! `bakashrot cert`: makes a CA, issues certificates, revokes them, shows
|
||||||
//! them. Every file is PEM; keys are written once, never over an existing
|
//! them, with no server. Every file is PEM; keys are written once, never
|
||||||
//! file. See `docs/certificates.md`.
|
//! over an existing file. See `docs/certificates.md`.
|
||||||
|
|
||||||
use bakashrot_pki::{CA_DAYS, CERTIFICATE_DAYS, Ca, Identity, Revocations, Usage, summarize};
|
use bakashrot_pki::{CA_DAYS, CERTIFICATE_DAYS, Ca, Identity, Revocations, Usage, summarize};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::Subcommand;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::ExitCode;
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
|
||||||
#[command(
|
|
||||||
name = "bakashrot-cert",
|
|
||||||
version,
|
|
||||||
about = "Issues and revokes BakaShrot's certificates"
|
|
||||||
)]
|
|
||||||
struct Cli {
|
|
||||||
#[command(subcommand)]
|
|
||||||
command: Command,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// `bakashrot cert`'s commands (its help is `Command::Cert`'s, in main.rs).
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Command {
|
pub enum Command {
|
||||||
/// Makes a new CA: ca.crt and ca.key in --out. Keep ca.key off the
|
/// Makes a new CA: ca.crt and ca.key in --out. Keep ca.key off the
|
||||||
/// servers: whoever has it can make any identity.
|
/// servers: whoever has it can make any identity.
|
||||||
Ca {
|
Ca {
|
||||||
@@ -85,17 +74,8 @@ enum Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
/// Runs one of `bakashrot cert`'s commands.
|
||||||
match run(Cli::parse().command) {
|
pub fn run(command: Command) -> Result<(), String> {
|
||||||
Ok(()) => ExitCode::SUCCESS,
|
|
||||||
Err(error) => {
|
|
||||||
eprintln!("bakashrot-cert: {error}");
|
|
||||||
ExitCode::FAILURE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(command: Command) -> Result<(), String> {
|
|
||||||
match command {
|
match command {
|
||||||
Command::Ca { name, days, out } => {
|
Command::Ca { name, days, out } => {
|
||||||
let ca = Ca::create(&name, days).map_err(|e| e.to_string())?;
|
let ca = Ca::create(&name, days).map_err(|e| e.to_string())?;
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
//! `bakashrot`: pushes messages, reads them and their attachments, runs
|
//! `bakashrot`: pushes messages, reads them and their attachments, runs
|
||||||
//! queries and lists names from the command line, connecting with a
|
//! queries and lists names from the command line, connecting with a
|
||||||
//! `client.toml`; see `docs/client.md`, "The tools".
|
//! `client.toml`; see `docs/client.md`, "The tool". `bakashrot cert`
|
||||||
|
//! issues the certificates (`cert.rs`, `docs/certificates.md`).
|
||||||
|
|
||||||
|
mod cert;
|
||||||
|
|
||||||
use bakashrot_client::{Client, Error, Settings};
|
use bakashrot_client::{Client, Error, Settings};
|
||||||
use bakashrot_proto::error::{code_name, is_refusal_code};
|
use bakashrot_proto::error::{code_name, is_refusal_code};
|
||||||
@@ -18,12 +21,12 @@ use std::time::Duration;
|
|||||||
#[command(
|
#[command(
|
||||||
name = "bakashrot",
|
name = "bakashrot",
|
||||||
version,
|
version,
|
||||||
about = "Pushes and reads BakaShrot's messages",
|
about = "Pushes and reads BakaShrot's messages, issues its certificates",
|
||||||
after_help = "Exits with 0 on success, 1 on a failure, 2 on bad arguments."
|
after_help = "Exits with 0 on success, 1 on a failure, 2 on bad arguments."
|
||||||
)]
|
)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// The client's settings: the server, the CA's certificate, this
|
/// The client's settings: the server, the CA's certificate, this
|
||||||
/// client's certificate and key, the CRL.
|
/// client's certificate and key, the CRL (cert doesn't use them).
|
||||||
#[arg(short, long, global = true, default_value = "client.toml")]
|
#[arg(short, long, global = true, default_value = "client.toml")]
|
||||||
config: PathBuf,
|
config: PathBuf,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -110,6 +113,12 @@ enum Command {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
json: bool,
|
json: bool,
|
||||||
},
|
},
|
||||||
|
/// Makes a CA, issues certificates, revokes them, shows them; no
|
||||||
|
/// server needed (run it where the CA's key is).
|
||||||
|
Cert {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: cert::Command,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where `messages` starts.
|
/// Where `messages` starts.
|
||||||
@@ -159,6 +168,7 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
fn run(config: &Path, command: Command) -> Result<(), String> {
|
fn run(config: &Path, command: Command) -> Result<(), String> {
|
||||||
match command {
|
match command {
|
||||||
|
Command::Cert { command } => cert::run(command)?,
|
||||||
Command::Push {
|
Command::Push {
|
||||||
topic,
|
topic,
|
||||||
message,
|
message,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//! `bakashrot-cert` end to end, in a folder of the build's.
|
//! `bakashrot cert` end to end, in a folder of the build's.
|
||||||
|
|
||||||
use bakashrot_pki::{Revocations, summarize};
|
use bakashrot_pki::{Revocations, summarize};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@@ -12,9 +12,11 @@ fn folder(name: &str) -> PathBuf {
|
|||||||
folder
|
folder
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the tool in `folder`: whether it succeeded, and what it printed.
|
/// Runs `bakashrot cert` in `folder`: whether it succeeded, and what it
|
||||||
|
/// printed.
|
||||||
fn cert(folder: &Path, args: &[&str]) -> (bool, String) {
|
fn cert(folder: &Path, args: &[&str]) -> (bool, String) {
|
||||||
let output = Command::new(env!("CARGO_BIN_EXE_bakashrot-cert"))
|
let output = Command::new(env!("CARGO_BIN_EXE_bakashrot"))
|
||||||
|
.arg("cert")
|
||||||
.args(args)
|
.args(args)
|
||||||
.current_dir(folder)
|
.current_dir(folder)
|
||||||
.output()
|
.output()
|
||||||
|
|||||||
+10
-7
@@ -1,5 +1,6 @@
|
|||||||
# The BakaShrot server's image: bakashrot-server, with the bakashrot and
|
# The BakaShrot server's image: bakashrot-server, with the bakashrot tool
|
||||||
# bakashrot-cert tools beside it. Built from the repository's root:
|
# beside it (bakashrot cert for the certificates). Built from the
|
||||||
|
# repository's root:
|
||||||
# docker build -f docker/Dockerfile -t bakashrot-server .
|
# docker build -f docker/Dockerfile -t bakashrot-server .
|
||||||
# CI builds it for amd64 and arm64 on a version tag, checks it
|
# 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
|
# (docker/test.sh) and pushes it to ghcr.io/aziascreations/bakashrot-server
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
# from outside the container
|
# from outside the container
|
||||||
# database = "/var/lib/bakashrot/bakashrot.sqlite"
|
# database = "/var/lib/bakashrot/bakashrot.sqlite"
|
||||||
# and the certificates relative to it (ca = "ca.crt", ...). The server runs
|
# 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
|
# 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
|
# keys readable by their owner only): chown 10001:10001 config/server-1.key
|
||||||
#
|
#
|
||||||
# docker run -d --name bakashrot -p 7000:7000 \
|
# docker run -d --name bakashrot -p 7000:7000 \
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
# ghcr.io/aziascreations/bakashrot-server
|
# ghcr.io/aziascreations/bakashrot-server
|
||||||
#
|
#
|
||||||
# Or docker/compose.yml. `docker stop` stops it cleanly (SIGTERM).
|
# Or docker/compose.yml. `docker stop` stops it cleanly (SIGTERM).
|
||||||
# The tools: docker run --rm <image> bakashrot-cert ... (or bakashrot ...).
|
# The tool: docker run --rm <image> bakashrot cert ... (or bakashrot push ...).
|
||||||
|
|
||||||
|
|
||||||
# --- Build ---------------------------------------------------------------------
|
# --- Build ---------------------------------------------------------------------
|
||||||
@@ -30,11 +31,13 @@ FROM rust:1-slim-trixie AS build
|
|||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
# Only what the programs are built from (Dockerfile.dockerignore).
|
# Only what the programs are built from (Dockerfile.dockerignore).
|
||||||
COPY . .
|
COPY . .
|
||||||
# The toolchain rust-toolchain.toml pins, then the release build.
|
# The toolchain rust-toolchain.toml pins, then the release build, the tool
|
||||||
|
# with its own profile (release-tools, Cargo.toml).
|
||||||
RUN rustup toolchain install \
|
RUN rustup toolchain install \
|
||||||
&& cargo build --release --locked -p bakashrot-server -p bakashrot-tools \
|
&& cargo build --release --locked -p bakashrot-server \
|
||||||
|
&& cargo build --profile release-tools --locked -p bakashrot-tools \
|
||||||
&& mkdir /out \
|
&& mkdir /out \
|
||||||
&& cp target/release/bakashrot-server target/release/bakashrot target/release/bakashrot-cert /out/
|
&& cp target/release/bakashrot-server target/release-tools/bakashrot /out/
|
||||||
|
|
||||||
|
|
||||||
# --- Runtime -------------------------------------------------------------------
|
# --- Runtime -------------------------------------------------------------------
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Smoke-tests a server image, as CI does before pushing it: certificates by
|
# Smoke-tests a server image, as CI does before pushing it: certificates by
|
||||||
# its bakashrot-cert, its server started with them, its bakashrot pushing
|
# its bakashrot cert, its server started with them, its bakashrot pushing
|
||||||
# and reading back over a Docker network, then `docker stop`, which must
|
# and reading back over a Docker network, then `docker stop`, which must
|
||||||
# end it cleanly (exit code 0, "stopped").
|
# end it cleanly (exit code 0, "stopped").
|
||||||
# Usage: docker/test.sh <image>
|
# Usage: docker/test.sh <image>
|
||||||
@@ -27,9 +27,9 @@ tool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
docker network create "$name" >/dev/null
|
docker network create "$name" >/dev/null
|
||||||
tool bakashrot-cert ca --name "Image test CA"
|
tool bakashrot cert ca --name "Image test CA"
|
||||||
tool bakashrot-cert issue --name server-1 --server
|
tool bakashrot cert issue --name server-1 --server
|
||||||
tool bakashrot-cert issue --name tester --role tester
|
tool bakashrot cert issue --name tester --role tester
|
||||||
cat >"$work/server.toml" <<EOF
|
cat >"$work/server.toml" <<EOF
|
||||||
[server]
|
[server]
|
||||||
listen = "0.0.0.0:7000"
|
listen = "0.0.0.0:7000"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Who connects to whom, and how it's checked. The code is
|
Who connects to whom, and how it's checked. The code is
|
||||||
`crates/bakashrot-pki` (the library) and `crates/bakashrot-tools`
|
`crates/bakashrot-pki` (the library) and `crates/bakashrot-tools`
|
||||||
(`bakashrot-cert`, the tool). Decided in `../revamp.md`, "Decided".
|
(`bakashrot cert`, the tool's commands). Decided in `../revamp.md`, "Decided".
|
||||||
|
|
||||||
## The idea
|
## The idea
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ connected, `peer_identity()` gives the other end's `Identity`.
|
|||||||
|
|
||||||
## Revocation
|
## Revocation
|
||||||
|
|
||||||
- `bakashrot-cert revoke` writes `ca.crl`, signed by the CA, with every
|
- `bakashrot cert revoke` writes `ca.crl`, signed by the CA, with every
|
||||||
certificate revoked before (written aside, then moved in place).
|
certificate revoked before (written aside, then moved in place).
|
||||||
- A server reads it into `Revocations`, which its TLS setup shares
|
- A server reads it into `Revocations`, which its TLS setup shares
|
||||||
(`SharedRevocations`): replacing what's inside takes effect for the next
|
(`SharedRevocations`): replacing what's inside takes effect for the next
|
||||||
@@ -95,11 +95,11 @@ connected, `peer_identity()` gives the other end's `Identity`.
|
|||||||
## The tool
|
## The tool
|
||||||
|
|
||||||
```
|
```
|
||||||
bakashrot-cert ca --name "Home CA" ca.crt, ca.key
|
bakashrot cert ca --name "Home CA" ca.crt, ca.key
|
||||||
bakashrot-cert issue --name kitchen --role sensor kitchen.crt, kitchen.key
|
bakashrot cert issue --name kitchen --role sensor kitchen.crt, kitchen.key
|
||||||
bakashrot-cert issue --name server-1 --role peer --server
|
bakashrot cert issue --name server-1 --role peer --server
|
||||||
bakashrot-cert revoke kitchen.crt ca.crl
|
bakashrot cert revoke kitchen.crt ca.crl
|
||||||
bakashrot-cert show kitchen.crt
|
bakashrot cert show kitchen.crt
|
||||||
```
|
```
|
||||||
|
|
||||||
`--ca` (the folder of `ca.crt` / `ca.key`, `.` by default), `--out` (where
|
`--ca` (the folder of `ca.crt` / `ca.key`, `.` by default), `--out` (where
|
||||||
|
|||||||
+10
-9
@@ -9,7 +9,7 @@ What apps connect with, in layers:
|
|||||||
| C header | `bindings/c/bakashrot.h` | generated from the DLL (cbindgen) |
|
| C header | `bindings/c/bakashrot.h` | generated from the DLL (cbindgen) |
|
||||||
| PureBasic | `bindings/purebasic/` | the prototypes and the error codes |
|
| PureBasic | `bindings/purebasic/` | the prototypes and the error codes |
|
||||||
| Python | `bindings/python/bakashrot.py` | `Client` over the DLL (ctypes), standard library only |
|
| 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` |
|
| The tool | `crates/bakashrot-tools`: `bakashrot` | the command line, over `bakashrot-client`; `bakashrot cert`, the certificates |
|
||||||
|
|
||||||
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`.
|
wire: `protocol.md`; the server's side: `server.md`.
|
||||||
@@ -20,14 +20,14 @@ names, queries.
|
|||||||
## Who connects: certificates
|
## Who connects: certificates
|
||||||
|
|
||||||
A client is its certificate, issued by the CA the servers trust
|
A client is its certificate, issued by the CA the servers trust
|
||||||
(`certificates.md`, `bakashrot-cert issue`): its name is its node, its
|
(`certificates.md`, `bakashrot cert issue`): its name is its node, its
|
||||||
roles say what it may do on each server (`config.md`). It needs the CA's
|
roles say what it may do on each server (`config.md`). It needs the CA's
|
||||||
certificate (to check the server's), its own certificate and key, and the
|
certificate (to check the server's), its own certificate and key, and the
|
||||||
CA's CRL if there is one (servers it revokes are refused).
|
CA's CRL if there is one (servers it revokes are refused).
|
||||||
|
|
||||||
### `client.toml`
|
### `client.toml`
|
||||||
|
|
||||||
What Python's `Client.from_file()` and the tools read. Paths are relative
|
What Python's `Client.from_file()` and the tool read. Paths are relative
|
||||||
to the file's folder.
|
to the file's folder.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
@@ -108,13 +108,14 @@ getters. Run directly, it's an example: `ClientExample <DllPath> <CaFile>
|
|||||||
with an attachment, reading both back (run by hand against a server;
|
with an attachment, reading both back (run by hand against a server;
|
||||||
not in CI, which has no PureBasic).
|
not in CI, which has no PureBasic).
|
||||||
|
|
||||||
## The tools
|
## The tool
|
||||||
|
|
||||||
`bakashrot`, one program to push, read, query and list (`bakashrot-cert`,
|
`bakashrot`, one program to push, read, query and list, and to make the
|
||||||
for the CA, is apart: `certificates.md`). Each command connects with
|
certificates (`bakashrot cert`, no server needed: `certificates.md`).
|
||||||
`-c <file>` (`client.toml` by default), does one thing and exits: 0, 1 on a
|
Each other command connects with `-c <file>` (`client.toml` by default),
|
||||||
failure (why on stderr: `Refused by the server (NotAllowed): ...`,
|
does one thing and exits: 0, 1 on a failure (why on stderr: `Refused by
|
||||||
`Failed to connect to ...`), 2 on bad arguments. `--help` on each.
|
the server (NotAllowed): ...`, `Failed to connect to ...`), 2 on bad
|
||||||
|
arguments. `--help` on each.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
bakashrot push logs '{"t":21}' Pushed as message #42
|
bakashrot push logs '{"t":21}' Pushed as message #42
|
||||||
|
|||||||
+8
-8
@@ -10,7 +10,7 @@ example configs.
|
|||||||
|
|
||||||
| Machine | What runs there | Files it gets |
|
| Machine | What runs there | Files it gets |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| admin (any) | `bakashrot-cert` | `ca.key` stays here, never copied |
|
| admin (any) | `bakashrot cert` | `ca.key` stays here, never copied |
|
||||||
| server-1 | `bakashrot-server` | `ca.crt`, `server-1.crt`, `server-1.key`, `server.toml` |
|
| server-1 | `bakashrot-server` | `ca.crt`, `server-1.crt`, `server-1.key`, `server.toml` |
|
||||||
| server-2 | `bakashrot-server` | `ca.crt`, `server-2.crt`, `server-2.key`, `server.toml` |
|
| server-2 | `bakashrot-server` | `ca.crt`, `server-2.crt`, `server-2.key`, `server.toml` |
|
||||||
| kitchen | `bakashrot` (pushes to server-1) | `ca.crt`, `kitchen.crt`, `kitchen.key`, `client.toml` |
|
| kitchen | `bakashrot` (pushes to server-1) | `ca.crt`, `kitchen.crt`, `kitchen.key`, `client.toml` |
|
||||||
@@ -23,12 +23,12 @@ their hostnames or IPs. The clients can be on the servers' machines.
|
|||||||
## 1. The certificates (admin)
|
## 1. The certificates (admin)
|
||||||
|
|
||||||
```
|
```
|
||||||
bakashrot-cert ca --name "Lab CA"
|
bakashrot cert ca --name "Lab CA"
|
||||||
bakashrot-cert issue --name server-1 --role peer --server
|
bakashrot cert issue --name server-1 --role peer --server
|
||||||
bakashrot-cert issue --name server-2 --role peer --server
|
bakashrot cert issue --name server-2 --role peer --server
|
||||||
bakashrot-cert issue --name kitchen --role sensor
|
bakashrot cert issue --name kitchen --role sensor
|
||||||
bakashrot-cert issue --name dashboard --role dashboard
|
bakashrot cert issue --name dashboard --role dashboard
|
||||||
bakashrot-cert issue --name lab-py --role sensor --role dashboard
|
bakashrot cert issue --name lab-py --role sensor --role dashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
A certificate is its name (the node) and its roles; the servers' configs
|
A certificate is its name (the node) and its roles; the servers' configs
|
||||||
@@ -154,7 +154,7 @@ Failed to connect to server-1.lab:7000 (NotAllowed): none of visitor's roles (gu
|
|||||||
takes them; it logs once that server-2 refused), start server-2: within
|
takes them; it logs once that server-2 refused), start server-2: within
|
||||||
about 10 s every one is on dashboard, in order.
|
about 10 s every one is on dashboard, in order.
|
||||||
|
|
||||||
**Revoking.** On admin, `bakashrot-cert revoke dashboard.crt` writes
|
**Revoking.** On admin, `bakashrot cert revoke dashboard.crt` writes
|
||||||
`ca.crl`; copy it next to each server's `server.toml` (the `crl` above).
|
`ca.crl`; copy it next to each server's `server.toml` (the `crl` above).
|
||||||
Within 5 s they reload it (`INFO ca.crl: reloaded, 1 revoked`), and the
|
Within 5 s they reload it (`INFO ca.crl: reloaded, 1 revoked`), and the
|
||||||
certificate is refused, at its next connection or request:
|
certificate is refused, at its next connection or request:
|
||||||
|
|||||||
+6
-4
@@ -50,12 +50,13 @@ Restart=on-failure
|
|||||||
|
|
||||||
`docker/Dockerfile` (its comments have the details), the image
|
`docker/Dockerfile` (its comments have the details), the image
|
||||||
`ghcr.io/aziascreations/bakashrot-server` (amd64 and arm64, pushed by CI
|
`ghcr.io/aziascreations/bakashrot-server` (amd64 and arm64, pushed by CI
|
||||||
on a version tag): the server, with `bakashrot` and `bakashrot-cert`
|
on a version tag): the server, with the `bakashrot` tool beside it
|
||||||
beside it, on `debian:trixie-slim`, as uid 10001.
|
(`bakashrot cert` for the certificates), on `debian:trixie-slim`, as
|
||||||
|
uid 10001.
|
||||||
|
|
||||||
- **The config** in `/etc/bakashrot`, read-only: `server.toml`, the
|
- **The config** in `/etc/bakashrot`, read-only: `server.toml`, the
|
||||||
certificates, the server's key (readable by uid 10001: `chown 10001`
|
certificates, the server's key (readable by uid 10001: `chown 10001`
|
||||||
it, `bakashrot-cert` writes keys for their owner only). `listen =
|
it, `bakashrot cert` writes keys for their owner only). `listen =
|
||||||
"0.0.0.0:7000"`: 127.0.0.1 isn't reachable from outside.
|
"0.0.0.0:7000"`: 127.0.0.1 isn't reachable from outside.
|
||||||
- **The database** in `/var/lib/bakashrot`, a volume: `database =
|
- **The database** in `/var/lib/bakashrot`, a volume: `database =
|
||||||
"/var/lib/bakashrot/bakashrot.sqlite"`.
|
"/var/lib/bakashrot/bakashrot.sqlite"`.
|
||||||
@@ -64,7 +65,8 @@ beside it, on `debian:trixie-slim`, as uid 10001.
|
|||||||
7000:7000 -v ./config:/etc/bakashrot:ro -v
|
7000:7000 -v ./config:/etc/bakashrot:ro -v
|
||||||
bakashrot-data:/var/lib/bakashrot <image>`. `docker stop` is SIGTERM:
|
bakashrot-data:/var/lib/bakashrot <image>`. `docker stop` is SIGTERM:
|
||||||
a clean stop. The logs: `docker logs`.
|
a clean stop. The logs: `docker logs`.
|
||||||
- **The tools:** `docker run --rm <image> bakashrot-cert ...`.
|
- **The tool:** `docker run --rm <image> bakashrot cert ...` (or
|
||||||
|
`bakashrot push ...`).
|
||||||
- **Checked** by `docker/test.sh <image>` (CI runs it on both before
|
- **Checked** by `docker/test.sh <image>` (CI runs it on both before
|
||||||
pushing): certificates by the image's tool, its server, a push read
|
pushing): certificates by the image's tool, its server, a push read
|
||||||
back over a Docker network, `docker stop` ending it cleanly.
|
back over a Docker network, `docker stop` ending it cleanly.
|
||||||
|
|||||||
+8
-1
@@ -159,6 +159,9 @@ SELECT * FROM messages WHERE topic = 'logs' AND node = 'kitchen'
|
|||||||
SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_json = 1
|
SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_json = 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
SQLite's functions are there, JSON's included; not `soundex()` nor the
|
||||||
|
`dbstat` table (left out of the build, "The file").
|
||||||
|
|
||||||
- **By topic, or topic and node:** ranges of the table, read in order (a
|
- **By topic, or topic and node:** ranges of the table, read in order (a
|
||||||
test checks the plans).
|
test checks the plans).
|
||||||
- **Filters on `pushed_at` or `message_id`** read the streams they're in,
|
- **Filters on `pushed_at` or `message_id`** read the streams they're in,
|
||||||
@@ -182,7 +185,11 @@ SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_js
|
|||||||
foreign keys: one writer keeps the tables consistent, `CHECK`s keep the
|
foreign keys: one writer keeps the tables consistent, `CHECK`s keep the
|
||||||
values valid.
|
values valid.
|
||||||
- SQLite is compiled in (`rusqlite`'s `bundled`): the same version
|
- SQLite is compiled in (`rusqlite`'s `bundled`): the same version
|
||||||
everywhere, no system library.
|
everywhere, no system library. Without full-text search (FTS3, FTS5),
|
||||||
|
R-Tree, `dbstat`, STAT4, `soundex()`, extension loading and column
|
||||||
|
metadata, which libsqlite3-sys turns on and nothing here uses: 310 KB
|
||||||
|
less in the server (`LIBSQLITE3_FLAGS` in `../.cargo/config.toml`; a
|
||||||
|
test checks they're out). JSON is SQLite's own, always there.
|
||||||
|
|
||||||
## Measured
|
## Measured
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
[Index](readme.md) · Next: [Server](2-server.md)
|
[Index](readme.md) · Next: [Server](2-server.md)
|
||||||
|
|
||||||
More options: `bakashrot-cert.exe <command> --help`.
|
Made by `bakashrot.exe`'s `cert` commands, with no server needed.
|
||||||
|
More options: `bakashrot.exe cert <command> --help`.
|
||||||
|
|
||||||
|
|
||||||
## The root certificate
|
## The root certificate
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bakashrot-cert.exe ca --name bakashrot-test
|
bakashrot.exe cert ca --name bakashrot-test
|
||||||
```
|
```
|
||||||
|
|
||||||
Resulting files:
|
Resulting files:
|
||||||
@@ -19,7 +20,7 @@ Resulting files:
|
|||||||
## A server certificate
|
## A server certificate
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bakashrot-cert.exe issue --server --name server-lan1
|
bakashrot.exe cert issue --server --name server-lan1
|
||||||
Wrote .\server-lan1.crt
|
Wrote .\server-lan1.crt
|
||||||
Wrote .\server-lan1.key
|
Wrote .\server-lan1.key
|
||||||
```
|
```
|
||||||
@@ -31,11 +32,11 @@ See [???]().
|
|||||||
## Node certificates
|
## Node certificates
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bakashrot-cert.exe issue --name node-sensor --role sensor
|
bakashrot.exe cert issue --name node-sensor --role sensor
|
||||||
Wrote .\node-sensor.crt
|
Wrote .\node-sensor.crt
|
||||||
Wrote .\node-sensor.key
|
Wrote .\node-sensor.key
|
||||||
|
|
||||||
bakashrot-cert.exe issue --name node-viewer --role viewer
|
bakashrot.exe cert issue --name node-viewer --role viewer
|
||||||
Wrote .\node-viewer.crt
|
Wrote .\node-viewer.crt
|
||||||
Wrote .\node-viewer.key
|
Wrote .\node-viewer.key
|
||||||
```
|
```
|
||||||
@@ -48,7 +49,7 @@ Wrote .\node-viewer.key
|
|||||||
## Checking one
|
## Checking one
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bakashrot-cert.exe show node-sensor.crt
|
bakashrot.exe cert show node-sensor.crt
|
||||||
node-sensor.crt
|
node-sensor.crt
|
||||||
name: node-sensor
|
name: node-sensor
|
||||||
roles: sensor
|
roles: sensor
|
||||||
@@ -62,7 +63,7 @@ node-sensor.crt
|
|||||||
## Revoking one
|
## Revoking one
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bakashrot-cert.exe revoke node-sensor.crt
|
bakashrot.exe cert revoke node-sensor.crt
|
||||||
```
|
```
|
||||||
|
|
||||||
* Writes `ca.crl` (every certificate revoked so far).
|
* Writes `ca.crl` (every certificate revoked so far).
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ accept_nodes = ["*"] # Accepts every foreign node's messages (Default)
|
|||||||
> list_topics = true
|
> list_topics = true
|
||||||
> list_nodes = true
|
> list_nodes = true
|
||||||
> ```
|
> ```
|
||||||
> Its certificate: `bakashrot-cert.exe issue --name node-admin --role admin`
|
> Its certificate: `bakashrot.exe cert issue --name node-admin --role admin`
|
||||||
|
|
||||||
|
|
||||||
### Retention
|
### Retention
|
||||||
|
|||||||
+2
-2
@@ -15,12 +15,12 @@ Who gets which files:
|
|||||||
|
|
||||||
| Machine | Files |
|
| Machine | Files |
|
||||||
|---------|---------------------------------------------------------------------------------------|
|
|---------|---------------------------------------------------------------------------------------|
|
||||||
| admin | `bakashrot-cert.exe`, `ca.crt`, `ca.key` (never copied) |
|
| admin | `bakashrot.exe` (its `cert` commands), `ca.crt`, `ca.key` (never copied) |
|
||||||
| server | `bakashrot-server.exe`, `ca.crt`, `server-lan1.crt`, `server-lan1.key`, `server.toml` |
|
| server | `bakashrot-server.exe`, `ca.crt`, `server-lan1.crt`, `server-lan1.key`, `server.toml` |
|
||||||
| sensor | `bakashrot.exe`, `ca.crt`, `node-sensor.crt`, `node-sensor.key`, `client.toml` |
|
| sensor | `bakashrot.exe`, `ca.crt`, `node-sensor.crt`, `node-sensor.key`, `client.toml` |
|
||||||
| viewer | `bakashrot.exe`, `ca.crt`, `node-viewer.crt`, `node-viewer.key`, `viewer.toml` |
|
| viewer | `bakashrot.exe`, `ca.crt`, `node-viewer.crt`, `node-viewer.key`, `viewer.toml` |
|
||||||
|
|
||||||
More:
|
More:
|
||||||
* `bakashrot <command> --help`, `bakashrot-cert <command> --help`.
|
* `bakashrot <command> --help`, `bakashrot cert <command> --help`.
|
||||||
* Two replicating servers, Python, Docker: `docs/lab.md`.
|
* Two replicating servers, Python, Docker: `docs/lab.md`.
|
||||||
* Every setting: `docs/config.md`.
|
* Every setting: `docs/config.md`.
|
||||||
|
|||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
# A release for this platform, built, packaged and smoke-tested, into
|
# A release for this platform, built, packaged and smoke-tested, into
|
||||||
# target\dist\ (release.py, Python 3.11+, does it all).
|
# target\dist\ (release.py, Python 3.11+, does it all).
|
||||||
# Usage: powershell -ExecutionPolicy Bypass -File release.ps1 [-SkipTest]
|
# Usage: powershell -ExecutionPolicy Bypass -File release.ps1 [-SkipTest] [-HybridCrt]
|
||||||
param([switch]$SkipTest)
|
# (-HybridCrt: the UCRT from Windows, see release.py's --hybrid-crt)
|
||||||
|
param([switch]$SkipTest, [switch]$HybridCrt)
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
# The py launcher if it's there, python otherwise.
|
# The py launcher if it's there, python otherwise.
|
||||||
$python = if (Get-Command py -ErrorAction SilentlyContinue) { @("py", "-3") } else { @("python") }
|
$python = if (Get-Command py -ErrorAction SilentlyContinue) { @("py", "-3") } else { @("python") }
|
||||||
$arguments = @(Join-Path $PSScriptRoot "release.py")
|
$arguments = @(Join-Path $PSScriptRoot "release.py")
|
||||||
if ($SkipTest) { $arguments += "--skip-test" }
|
if ($SkipTest) { $arguments += "--skip-test" }
|
||||||
|
if ($HybridCrt) { $arguments += "--hybrid-crt" }
|
||||||
& $python[0] @($python | Select-Object -Skip 1) @arguments
|
& $python[0] @($python | Select-Object -Skip 1) @arguments
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
|
|||||||
+48
-33
@@ -1,11 +1,11 @@
|
|||||||
"""Builds a BakaShrot release for this machine's platform (Windows or
|
"""Builds a BakaShrot release for this machine's platform (Windows or
|
||||||
Linux, x64 or ARM64), checks it works, and archives it:
|
Linux, x64 or ARM64), checks it works, and archives it:
|
||||||
|
|
||||||
python release.py [--skip-test]
|
python release.py [--skip-test] [--hybrid-crt]
|
||||||
|
|
||||||
Into target/dist/:
|
Into target/dist/:
|
||||||
bakashrot-<version>-<platform>/ the release:
|
bakashrot-<version>-<platform>/ the release:
|
||||||
bakashrot-server, bakashrot, bakashrot-cert the programs
|
bakashrot-server, bakashrot the programs
|
||||||
bakashrot.dll / libbakashrot.so the client library (C)
|
bakashrot.dll / libbakashrot.so the client library (C)
|
||||||
include/bakashrot.h its C header
|
include/bakashrot.h its C header
|
||||||
purebasic/*.pbi its PureBasic prototypes
|
purebasic/*.pbi its PureBasic prototypes
|
||||||
@@ -17,17 +17,21 @@ Into target/dist/:
|
|||||||
LICENSE.txt, THIRD-PARTY.txt BakaShrot's (CC0), its dependencies'
|
LICENSE.txt, THIRD-PARTY.txt BakaShrot's (CC0), its dependencies'
|
||||||
bakashrot-<version>-<platform>.zip (Windows) or .tar.gz (Linux)
|
bakashrot-<version>-<platform>.zip (Windows) or .tar.gz (Linux)
|
||||||
|
|
||||||
No keys or certificates in it: bakashrot-cert makes them.
|
No keys or certificates in it: bakashrot cert makes them.
|
||||||
|
|
||||||
The check (unless --skip-test), in the release folder's _test/ (exes run
|
The check (unless --skip-test), in the release folder's _test/ (exes run
|
||||||
from temp folders get blocked by antivirus here), deleted after unless
|
from temp folders get blocked by antivirus here), deleted after unless
|
||||||
it failed: a CA and certificates by bakashrot-cert, the
|
it failed: a CA and certificates by bakashrot cert, the
|
||||||
server started on a free port with a throwaway database, then the tool
|
server started on a free port with a throwaway database, then the tool
|
||||||
pushing (and an attachment of 3 MB), reading back, listing, querying;
|
pushing (and an attachment of 3 MB), reading back, listing, querying;
|
||||||
Python through the library, then the wheel installed by pip and used with
|
Python through the library, then the wheel installed by pip and used with
|
||||||
no path given; then the server stopped as a service manager would
|
no path given; then the server stopped as a service manager would
|
||||||
(SIGTERM, or Ctrl+Break on Windows), which must end cleanly.
|
(SIGTERM, or Ctrl+Break on Windows), which must end cleanly.
|
||||||
|
|
||||||
|
--hybrid-crt, on Windows: the C runtime's UCRT from Windows (10 and up)
|
||||||
|
instead of linked in, about 180 KB less per program, still no Visual C++
|
||||||
|
redistributable (.cargo/hybrid-crt.toml); README.txt says which.
|
||||||
|
|
||||||
The version is the workspace's (Cargo.toml), which bakashrot.py's
|
The version is the workspace's (Cargo.toml), which bakashrot.py's
|
||||||
__version__ must match. Needs Python 3.11+ (tomllib) and cargo (rustup).
|
__version__ must match. Needs Python 3.11+ (tomllib) and cargo (rustup).
|
||||||
"""
|
"""
|
||||||
@@ -49,16 +53,17 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
|||||||
WINDOWS = sys.platform == "win32"
|
WINDOWS = sys.platform == "win32"
|
||||||
EXE = ".exe" if WINDOWS else ""
|
EXE = ".exe" if WINDOWS else ""
|
||||||
LIBRARY = "bakashrot.dll" if WINDOWS else "libbakashrot.so"
|
LIBRARY = "bakashrot.dll" if WINDOWS else "libbakashrot.so"
|
||||||
PROGRAMS = ["bakashrot-server", "bakashrot", "bakashrot-cert"]
|
# Each built with its profile (Cargo.toml), into target/<profile>/.
|
||||||
CRATES = ["bakashrot-server", "bakashrot-tools", "bakashrot-capi"]
|
PROGRAMS = {"bakashrot-server": "release", "bakashrot": "release-tools"}
|
||||||
|
CRATES = {"bakashrot-server": "release", "bakashrot-capi": "release", "bakashrot-tools": "release-tools"}
|
||||||
|
|
||||||
CLIENT_EXAMPLE = """\
|
CLIENT_EXAMPLE = """\
|
||||||
# What the bakashrot tool and Python's Client.from_file() read, to connect
|
# What the bakashrot tool and Python's Client.from_file() read, to connect
|
||||||
# to a server. Paths are relative to this file's folder. See
|
# to a server. Paths are relative to this file's folder. See
|
||||||
# docs/client.md.
|
# docs/client.md.
|
||||||
server = "10.0.0.2:7000" # host:port, [an IPv6 address]:port
|
server = "10.0.0.2:7000" # host:port, [an IPv6 address]:port
|
||||||
ca = "ca.crt" # the CA's certificate (bakashrot-cert ca)
|
ca = "ca.crt" # the CA's certificate (bakashrot cert ca)
|
||||||
certificate = "kitchen.crt" # this node's (bakashrot-cert issue --name kitchen ...)
|
certificate = "kitchen.crt" # this node's (bakashrot cert issue --name kitchen ...)
|
||||||
key = "kitchen.key"
|
key = "kitchen.key"
|
||||||
# crl = "ca.crl" # optional: certificates the CA revoked
|
# crl = "ca.crl" # optional: certificates the CA revoked
|
||||||
"""
|
"""
|
||||||
@@ -162,13 +167,17 @@ def third_party():
|
|||||||
return "\n".join(lines) + "\n"
|
return "\n".join(lines) + "\n"
|
||||||
|
|
||||||
|
|
||||||
def readme(version, name):
|
def readme(version, name, hybrid):
|
||||||
built = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
built = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
||||||
rustc = run(["rustc", "--version"]).strip()
|
rustc = run(["rustc", "--version"]).strip()
|
||||||
|
crt = ""
|
||||||
|
if WINDOWS:
|
||||||
|
crt = ("\nThe C runtime: Windows' UCRT (Windows 10 and up), VCRuntime linked in."
|
||||||
|
if hybrid else "\nThe C runtime: linked in, nothing to install.")
|
||||||
return f"""\
|
return f"""\
|
||||||
BakaShrot {version} ({name})
|
BakaShrot {version} ({name})
|
||||||
|
|
||||||
Built {built}, commit {commit()}, {rustc}.
|
Built {built}, commit {commit()}, {rustc}.{crt}
|
||||||
Licenses: BakaShrot is CC0 (LICENSE.txt); the crates built into it are
|
Licenses: BakaShrot is CC0 (LICENSE.txt); the crates built into it are
|
||||||
listed in THIRD-PARTY.txt with their licenses.
|
listed in THIRD-PARTY.txt with their licenses.
|
||||||
|
|
||||||
@@ -177,11 +186,11 @@ from clients with certificates of your own CA, store them in SQLite, and
|
|||||||
replicate them between servers. docs/ has the details (config.md,
|
replicate them between servers. docs/ has the details (config.md,
|
||||||
certificates.md, server.md, client.md, protocol.md).
|
certificates.md, server.md, client.md, protocol.md).
|
||||||
|
|
||||||
Certificates (bakashrot-cert{EXE}; docs/certificates.md):
|
Certificates (bakashrot{EXE} cert, no server needed; docs/certificates.md):
|
||||||
bakashrot-cert ca --name "Home CA" ca.crt, ca.key (keep ca.key safe)
|
bakashrot cert ca --name "Home CA" ca.crt, ca.key (keep ca.key safe)
|
||||||
bakashrot-cert issue --name server-1 --server a server's
|
bakashrot cert issue --name server-1 --server a server's
|
||||||
bakashrot-cert issue --name kitchen --role sensor a client's: its node, its roles
|
bakashrot cert issue --name kitchen --role sensor a client's: its node, its roles
|
||||||
bakashrot-cert revoke kitchen.crt ca.crl
|
bakashrot cert revoke kitchen.crt ca.crl
|
||||||
|
|
||||||
The server (bakashrot-server{EXE} server.toml; docs/config.md, server.md):
|
The server (bakashrot-server{EXE} server.toml; docs/config.md, server.md):
|
||||||
server.example.toml has every setting. It logs to the console
|
server.example.toml has every setting. It logs to the console
|
||||||
@@ -208,20 +217,25 @@ release: another version's connection is refused. Nothing from the old
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build(hybrid):
|
||||||
print("Building")
|
"""Each profile's crates at once; the folder of a profile's output."""
|
||||||
command = ["cargo", "build", "--release", "--locked"]
|
print("Building" + (" (the hybrid C runtime)" if hybrid else ""))
|
||||||
for crate in CRATES:
|
for profile in sorted(set(CRATES.values())):
|
||||||
command += ["-p", crate]
|
command = ["cargo", "build", "--profile", profile, "--locked"]
|
||||||
run(command)
|
if hybrid:
|
||||||
return os.path.join(HERE, "target", "release")
|
command += ["--config", os.path.join(".cargo", "hybrid-crt.toml")]
|
||||||
|
for crate, its in CRATES.items():
|
||||||
|
if its == profile:
|
||||||
|
command += ["-p", crate]
|
||||||
|
run(command)
|
||||||
|
return lambda profile: os.path.join(HERE, "target", profile)
|
||||||
|
|
||||||
|
|
||||||
def package(built, version, name, out):
|
def package(built, version, name, out, hybrid):
|
||||||
print(f"Packaging {out}")
|
print(f"Packaging {out}")
|
||||||
for program in PROGRAMS:
|
for program, profile in PROGRAMS.items():
|
||||||
shutil.copy2(os.path.join(built, program + EXE), out)
|
shutil.copy2(os.path.join(built(profile), program + EXE), out)
|
||||||
shutil.copy2(os.path.join(built, LIBRARY), out)
|
shutil.copy2(os.path.join(built(CRATES["bakashrot-capi"]), LIBRARY), out)
|
||||||
bindings = os.path.join(HERE, "bindings")
|
bindings = os.path.join(HERE, "bindings")
|
||||||
os.makedirs(os.path.join(out, "include"))
|
os.makedirs(os.path.join(out, "include"))
|
||||||
shutil.copy2(os.path.join(bindings, "c", "bakashrot.h"), os.path.join(out, "include"))
|
shutil.copy2(os.path.join(bindings, "c", "bakashrot.h"), os.path.join(out, "include"))
|
||||||
@@ -234,7 +248,7 @@ def package(built, version, name, out):
|
|||||||
write(os.path.join(out, "client.example.toml"), CLIENT_EXAMPLE)
|
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, "THIRD-PARTY.txt"), third_party())
|
||||||
write(os.path.join(out, "README.txt"), readme(version, name))
|
write(os.path.join(out, "README.txt"), readme(version, name, hybrid))
|
||||||
wheel = run([sys.executable, "-B", os.path.join(bindings, "python", "make_wheel.py"),
|
wheel = run([sys.executable, "-B", os.path.join(bindings, "python", "make_wheel.py"),
|
||||||
os.path.join(out, LIBRARY), os.path.join(out, "python"),
|
os.path.join(out, LIBRARY), os.path.join(out, "python"),
|
||||||
os.path.join(out, "LICENSE.txt"), os.path.join(out, "THIRD-PARTY.txt")]).strip()
|
os.path.join(out, "LICENSE.txt"), os.path.join(out, "THIRD-PARTY.txt")]).strip()
|
||||||
@@ -264,9 +278,9 @@ def smoke_test(out, wheel):
|
|||||||
if not re.search(pattern, got, re.MULTILINE):
|
if not re.search(pattern, got, re.MULTILINE):
|
||||||
fail(f"{what}: unexpected output:\n{got}")
|
fail(f"{what}: unexpected output:\n{got}")
|
||||||
|
|
||||||
tool("bakashrot-cert", "ca", "--name", "Release test CA")
|
tool("bakashrot", "cert", "ca", "--name", "Release test CA")
|
||||||
tool("bakashrot-cert", "issue", "--name", "server-1", "--server")
|
tool("bakashrot", "cert", "issue", "--name", "server-1", "--server")
|
||||||
tool("bakashrot-cert", "issue", "--name", "tester", "--role", "tester")
|
tool("bakashrot", "cert", "issue", "--name", "tester", "--role", "tester")
|
||||||
port = free_port()
|
port = free_port()
|
||||||
write(os.path.join(test, "server.toml"), f"""\
|
write(os.path.join(test, "server.toml"), f"""\
|
||||||
[server]
|
[server]
|
||||||
@@ -328,7 +342,7 @@ key = "tester.key"
|
|||||||
expect("query", tool("bakashrot", "query",
|
expect("query", tool("bakashrot", "query",
|
||||||
"SELECT message_data ->> '$.value' AS v FROM messages WHERE topic = 'releasetest' AND message_id = 1"),
|
"SELECT message_data ->> '$.value' AS v FROM messages WHERE topic = 'releasetest' AND message_id = 1"),
|
||||||
r'"rows":\[\["42"\]\]')
|
r'"rows":\[\["42"\]\]')
|
||||||
print(" The tools: pushed, an attachment too, read back, listed, queried: OK")
|
print(" The tool: certificates made, pushed, an attachment too, read back, listed, queried: OK")
|
||||||
|
|
||||||
script = ("import sys; sys.path.insert(0, sys.argv[1]); import bakashrot\n"
|
script = ("import sys; sys.path.insert(0, sys.argv[1]); import bakashrot\n"
|
||||||
"with bakashrot.Client.from_file('client.toml', sys.argv[2]) as c:\n"
|
"with bakashrot.Client.from_file('client.toml', sys.argv[2]) as c:\n"
|
||||||
@@ -382,7 +396,7 @@ def archive(out):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = set(sys.argv[1:])
|
args = set(sys.argv[1:])
|
||||||
if args - {"--skip-test"}:
|
if args - {"--skip-test", "--hybrid-crt"}:
|
||||||
sys.exit(__doc__)
|
sys.exit(__doc__)
|
||||||
# rustup's folder isn't on every shell's PATH.
|
# rustup's folder isn't on every shell's PATH.
|
||||||
os.environ["PATH"] = os.path.join(os.path.expanduser("~"), ".cargo", "bin") + os.pathsep + os.environ["PATH"]
|
os.environ["PATH"] = os.path.join(os.path.expanduser("~"), ".cargo", "bin") + os.pathsep + os.environ["PATH"]
|
||||||
@@ -398,7 +412,8 @@ def main():
|
|||||||
os.remove(old)
|
os.remove(old)
|
||||||
os.makedirs(out)
|
os.makedirs(out)
|
||||||
print(f"BakaShrot {release} for {name}, into {out}")
|
print(f"BakaShrot {release} for {name}, into {out}")
|
||||||
wheel = package(build(), release, name, out)
|
hybrid = "--hybrid-crt" in args
|
||||||
|
wheel = package(build(hybrid), release, name, out, hybrid)
|
||||||
if "--skip-test" not in args:
|
if "--skip-test" not in args:
|
||||||
shutil.rmtree(smoke_test(out, wheel))
|
shutil.rmtree(smoke_test(out, wheel))
|
||||||
print(f"Archive: {archive(out)}")
|
print(f"Archive: {archive(out)}")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Started 2026-11-13: what it should change, what's decided, what's still
|
Started 2026-11-13: what it should change, what's decided, what's still
|
||||||
open, and the plan. Every step of the plan is done (the workspace,
|
open, and the plan. Every step of the plan is done (the workspace,
|
||||||
`bakashrot-proto`, `bakashrot-pki` and `bakashrot-cert`,
|
`bakashrot-proto`, `bakashrot-pki` and the certificate tool,
|
||||||
`bakashrot-config`, `bakashrot-storage`, `bakashrot-server` and
|
`bakashrot-config`, `bakashrot-storage`, `bakashrot-server` and
|
||||||
`bakashrot-client` answering every request, attachments included, the C
|
`bakashrot-client` answering every request, attachments included, the C
|
||||||
DLL with its C, PureBasic and Python bindings, the `bakashrot` tool,
|
DLL with its C, PureBasic and Python bindings, the `bakashrot` tool,
|
||||||
@@ -30,7 +30,12 @@ test runner, CI, Docker, `bench.ps1`), see "Plan".
|
|||||||
unloaded (`BakaShrot_UnloadClient()`) and Windows' loader lock is
|
unloaded (`BakaShrot_UnloadClient()`) and Windows' loader lock is
|
||||||
never in the way;
|
never in the way;
|
||||||
- the C runtime linked statically on Windows (`+crt-static`), built
|
- the C runtime linked statically on Windows (`+crt-static`), built
|
||||||
against an old glibc on Linux (manylinux);
|
against an old glibc on Linux (manylinux); a switch for the hybrid
|
||||||
|
one, not the default (2026-11-17): `build.ps1` / `release.ps1
|
||||||
|
-HybridCrt`, `.cargo/hybrid-crt.toml`, the UCRT from Windows (10
|
||||||
|
and up), VCRuntime still linked in, about 180 KB less per program,
|
||||||
|
still nothing to install (fully dynamic: 21 KB less again, but
|
||||||
|
`vcruntime140.dll`, the redistributable's);
|
||||||
- `W` exports take UTF-16 everywhere (PureBasic's strings; `wchar_t` is
|
- `W` exports take UTF-16 everywhere (PureBasic's strings; `wchar_t` is
|
||||||
32 bits on Linux);
|
32 bits on Linux);
|
||||||
- the toolchain pinned (`rust-toolchain.toml`), a C header generated
|
- the toolchain pinned (`rust-toolchain.toml`), a C header generated
|
||||||
@@ -112,7 +117,7 @@ Also decided (2026-11-13):
|
|||||||
config (warned in its log: a CRL deleted by mistake) and
|
config (warned in its log: a CRL deleted by mistake) and
|
||||||
`client.toml` (the tool, Python's `from_file()`). A path given
|
`client.toml` (the tool, Python's `from_file()`). A path given
|
||||||
to the DLL's `SetCrl` or Python's `Client(crl=...)` is asked for
|
to the DLL's `SetCrl` or Python's `Client(crl=...)` is asked for
|
||||||
explicitly: missing, it's a `FileError`. `bakashrot-cert revoke`
|
explicitly: missing, it's a `FileError`. `bakashrot cert revoke`
|
||||||
needs no file to start from (it writes the first one). A file
|
needs no file to start from (it writes the first one). A file
|
||||||
that's there but can't be read or isn't the CA's is refused;
|
that's there but can't be read or isn't the CA's is refused;
|
||||||
- clients check it too when given one (`client_config()` takes the
|
- clients check it too when given one (`client_config()` takes the
|
||||||
@@ -120,7 +125,7 @@ Also decided (2026-11-13):
|
|||||||
block each other whichever end dials;
|
block each other whichever end dials;
|
||||||
- revoked by certificate, not by name: each certificate has its own key
|
- revoked by certificate, not by name: each certificate has its own key
|
||||||
and serial number, so two servers of the same name each have theirs,
|
and serial number, so two servers of the same name each have theirs,
|
||||||
revoked one at a time (`bakashrot-cert issue --file`).
|
revoked one at a time (`bakashrot cert issue --file`).
|
||||||
- **The server's config is TOML** (2026-11-13), `docs/config.md`:
|
- **The server's config is TOML** (2026-11-13), `docs/config.md`:
|
||||||
- `[server]`, `[retention]`, `[replication]`, `[roles.<name>]`; unknown
|
- `[server]`, `[retention]`, `[replication]`, `[roles.<name>]`; unknown
|
||||||
keys refused; names only (no ids, pins or ranges);
|
keys refused; names only (no ids, pins or ranges);
|
||||||
@@ -190,7 +195,7 @@ Also decided (2026-11-13):
|
|||||||
- **The tools** (2026-11-14), `docs/client.md`, "The tools": one
|
- **The tools** (2026-11-14), `docs/client.md`, "The tools": one
|
||||||
`bakashrot` program with subcommands (`push`, `latest`, `messages`,
|
`bakashrot` program with subcommands (`push`, `latest`, `messages`,
|
||||||
`query`, `list`) over `bakashrot-client`, `bakashrot-cert` kept apart
|
`query`, `list`) over `bakashrot-client`, `bakashrot-cert` kept apart
|
||||||
(the CA's key); `-c/--config`, `client.toml` by default; the old tools'
|
(the CA's key; folded in as `bakashrot cert` on 2026-11-17, below); `-c/--config`, `client.toml` by default; the old tools'
|
||||||
output; messages and SQL inline, `@file` or `-` (standard input); exit
|
output; messages and SQL inline, `@file` or `-` (standard input); exit
|
||||||
codes 0, 1, and 2 for bad arguments.
|
codes 0, 1, and 2 for bad arguments.
|
||||||
- **Attachments** (2026-11-14), `docs/server.md` and `client.md`:
|
- **Attachments** (2026-11-14), `docs/server.md` and `client.md`:
|
||||||
@@ -270,6 +275,29 @@ Also decided (2026-11-13):
|
|||||||
manual runs only, a read-only token but where images are pushed (after
|
manual runs only, a read-only token but where images are pushed (after
|
||||||
they're built and checked), no token left on disk by checkout, actions
|
they're built and checked), no token left on disk by checkout, actions
|
||||||
pinned to commits, `--locked` builds.
|
pinned to commits, `--locked` builds.
|
||||||
|
- **One tool, smaller** (2026-11-17), `docs/certificates.md`, "The
|
||||||
|
tool", and `docs/storage.md`, "The file": `bakashrot-cert` folded
|
||||||
|
into `bakashrot` as `bakashrot cert` (`ca`, `issue`, `revoke`, `show`,
|
||||||
|
the same options): aws-lc, the C runtime and clap once, 2.53 MB
|
||||||
|
instead of 2.85 + 1.73 MB on Windows.
|
||||||
|
The tool is built with its own profile, `release-tools` (`panic =
|
||||||
|
"abort"`, about 15% smaller); the DLL keeps `unwind` (it catches
|
||||||
|
panics), the server too (a panic loses one connection, not all).
|
||||||
|
clap without colours and "did you mean" suggestions (40 KB). SQLite
|
||||||
|
without what libsqlite3-sys turns on and nothing uses (FTS3, FTS5,
|
||||||
|
R-Tree, `dbstat`, STAT4, `soundex()`, extension loading, column
|
||||||
|
metadata; `LIBSQLITE3_FLAGS` in `.cargo/config.toml`): the server 4.68
|
||||||
|
to 4.37 MB. Weighed and left: UPX (antivirus), the C runtime as a DLL
|
||||||
|
(Decided 2), a nightly `build-std` or `trim-paths`, `opt-level = "z"`
|
||||||
|
(5% for slower code), SQLite's `OMIT_*` options (7 KB), a TLS setup
|
||||||
|
naming P-384 only (25 KB: aws-lc links its other algorithms anyway).
|
||||||
|
**aws-lc kept** (the owner, 2026-11-17), the others measured with the
|
||||||
|
same TLS setup: Graviola (rustls-graviola 0.4.0, X25519MLKEM768 too)
|
||||||
|
490 KB bigger, its P-256 and P-384 tables in it, and very new; ring
|
||||||
|
410 KB smaller per program but without ML-KEM, which protects what's
|
||||||
|
recorded today from a quantum computer later; RustCrypto's provider
|
||||||
|
not for production. Worth another look if rustls-graviola lets a
|
||||||
|
provider name its algorithms one by one, or ring gets ML-KEM.
|
||||||
|
|
||||||
## Proposed, to confirm
|
## Proposed, to confirm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user