mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
5b41a06d0c
- `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>
154 lines
4.2 KiB
Markdown
154 lines
4.2 KiB
Markdown
# 2. Server
|
|
|
|
[Index](readme.md) · Previous: [Certificates](1-certificates.md) · Next: [Client](3-client.md)
|
|
|
|
## Pre-requisites
|
|
* The certificate authority's `.crt` file.
|
|
* The server's `.crt` file.
|
|
|
|
|
|
---
|
|
|
|
## Configuring it
|
|
The server's config is typically kept in `server.toml`, next the `.crt` files. \
|
|
Create a blank one and all the following sections.
|
|
|
|
### Server's base config
|
|
```toml
|
|
# All paths are relative to this file's folder unless they're absolute.
|
|
[server]
|
|
listen = "0.0.0.0:7000" # Used when binding.
|
|
|
|
ca = "ca.crt"
|
|
certificate = "server-1.crt"
|
|
key = "server-1.key"
|
|
|
|
# The watched CA's CRL.
|
|
# Not given: no CRL checks. Given but not there yet: nothing revoked (a warning is logged),
|
|
# and it's picked up once it appears.
|
|
#crl = "ca.crl"
|
|
|
|
database = "bakashrot.sqlite"
|
|
|
|
# "full": every push flushed to disk before it's answered, it survives a
|
|
# power loss. "normal": about twice the pushes, a power loss loses the last
|
|
# second or so. ("off" isn't allowed.)
|
|
synchronous = "full"
|
|
|
|
# Replication cut partway through an attachment resumes once the peer has
|
|
# read back and hashed what it already has, in 30 s at most: up to about
|
|
# 4 GB received on a hard disk, 15 GB on a SATA SSD, 30-60 GB on NVMe
|
|
# (estimates). Past that, resuming fails at every retry: keep attachments
|
|
# well under it (more than a few GB is a lot for this anyway).
|
|
max_attachment_size = "1G" # bytes, or K M G T (1024-based); 0: none
|
|
retention_interval = "1m" # how often old messages are deleted
|
|
```
|
|
|
|
|
|
### Replication
|
|
```toml
|
|
# Who this server replicates with, by address.
|
|
# A link carries messages one way: the server that dials sends, the one dialed takes them.
|
|
[replication]
|
|
push_to = [] # Servers we'll actively connect to.
|
|
# Example: ["10.0.0.2:7000", "server-2.lan:7000"]
|
|
|
|
accept_from = [] # Connecting servers must have these origins, otherwise we abort.
|
|
# Example: ["10.0.0.2", "server-2.lan"], or ["*"]
|
|
|
|
retry_delay = "10s"
|
|
sync_interval = "5s" # keep it under 5 min: a link idle that long is closed
|
|
batch_size = 1000 # messages per packet, 1-10000
|
|
```
|
|
|
|
|
|
### Roles section
|
|
```toml
|
|
# A database holds 1,048,575 topic and node pairs at most, all topics together,
|
|
# never freed: patterns like "*" in push_topics let clients make as many as they like.
|
|
[roles.sensor]
|
|
push_topics = ["sensors.*"] # always as its own node (its name)
|
|
read_topics = ["*"]
|
|
query = true # read-only SQL, reads every topic
|
|
|
|
# Listing: by default, only the topics it may push to or read,
|
|
# and only the nodes of the topics it may read.
|
|
list_topics = false # true: lists every topic (query does too)
|
|
list_nodes = false # true: lists every node (query does too)
|
|
|
|
# Only relevant when replicating.
|
|
send_nodes = ["*"] # Replicates every node's messages (Default)
|
|
accept_nodes = ["*"] # Accepts every foreign node's messages (Default)
|
|
```
|
|
|
|
#### Remarks:
|
|
* Any node/certificate without any known role is refused.
|
|
|
|
#### Examples:
|
|
> **Sensor:**
|
|
> ```toml
|
|
> [roles.sensor]
|
|
> push_topics = ["sensors.*"]
|
|
> read_topics = []
|
|
> ```
|
|
|
|
> **Log Processor:**
|
|
> ```toml
|
|
> [roles.log-processor]
|
|
> push_topics = ["alerts.sensors.*"]
|
|
> read_topics = ["sensors.*"]
|
|
> ```
|
|
|
|
> **Explorer:** (sees every name, reads nothing)
|
|
> ```toml
|
|
> [roles.explorer]
|
|
> list_topics = true
|
|
> list_nodes = true
|
|
> ```
|
|
|
|
> **Admin:** (everything a client can do, on every topic)
|
|
> ```toml
|
|
> [roles.admin]
|
|
> push_topics = ["*"]
|
|
> read_topics = ["*"]
|
|
> query = true
|
|
> list_topics = true
|
|
> list_nodes = true
|
|
> ```
|
|
> Its certificate: `bakashrot.exe cert issue --name node-admin --role admin`
|
|
|
|
|
|
### Retention
|
|
```toml
|
|
# How long each topic's messages are kept, from when they were first pushed.
|
|
# Any topic not present here will be kept forever.
|
|
[retention]
|
|
logs = "30d"
|
|
"sensors.*" = "12h"
|
|
"*" = "forever" # Implied
|
|
```
|
|
|
|
|
|
---
|
|
|
|
## Opening the port
|
|
|
|
Admin PowerShell:
|
|
```powershell
|
|
New-NetFirewallRule -DisplayName BakaShrot -Direction Inbound -Protocol TCP -LocalPort 7000 -Action Allow
|
|
```
|
|
|
|
|
|
---
|
|
|
|
## Starting it
|
|
|
|
```shell
|
|
bakashrot-server.exe server.toml
|
|
2026-11-15T11:35:51.404202Z INFO server-lan1 listening on 0.0.0.0:7000
|
|
```
|
|
|
|
* Creates `bakashrot.sqlite` on first start.
|
|
* Stop with Ctrl+C: what was accepted is saved.
|
|
* More logs: `set BAKASHROT_LOG=debug` before starting it.
|