mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
9caf816dca
- Every message is stamped with the time its push arrived (UTC ms since 1970, the server's clock), carried as is by replication. Exposed in LatestMessage and Messages, BakaShrot_GetMessagePushedAt() in the DLL, Message.pushed_at / .pushed in Python, GetMessages --time, GetLatestMessage, and the messages view (pushed_at, pushed_utc). - [BakaShrot.Retention] in each server's config: a max age per topic, by name, id, pattern or *, ages like 30d or 1d12h. A background pass (Server/Storage/Retention.pbi, every RetentionInterval seconds) deletes what's older, in batches through the writer. node_heads is left as is, so ids never go back and peers don't resend what was deleted. - Replicated messages already past the receiver's max age are skipped on arrival, their head still raised so they aren't sent again. - Schema v6: data.pushed_at (older databases stamped at upgrade time), a (topic_id, pushed_at) index, the unused archives table dropped. The writer takes the next id from node_heads. - Folded into protocol 3, not released yet. - Tests/Retention-Test.ps1 (52 checks), Python checks for pushed_at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVPXGLs3KK1MAQn3ouP
171 lines
6.5 KiB
INI
171 lines
6.5 KiB
INI
; BakaShrot server config file.
|
|
; Section names are literal strings as far as PureBasic's Preferences
|
|
; library is concerned — the dots below are just part of the name.
|
|
;
|
|
; Topics and nodes: each has an id (0-65535) on this server, and can have a
|
|
; name, in [BakaShrot.Topics] and [BakaShrot.Nodes]. Names are what's shared
|
|
; between servers: replication sends them, and each server stores the
|
|
; messages under its own ids for them ("logs" can be 1 here and 200 on a
|
|
; peer).
|
|
; ONLY WHAT'S NAMED ON BOTH SERVERS REPLICATES: a topic or node without a
|
|
; name, or whose name the other server doesn't have, is dropped. Unnamed
|
|
; ones still work locally, by id.
|
|
; Names: 1-64 of A-Z a-z 0-9 _ . -, not only digits, case doesn't matter.
|
|
; The server's "names" command and the ListNames tool list them all.
|
|
;
|
|
; Topic, Node and ReplicatingTopics were TopicId, NodeId and
|
|
; ReplicatingTopicIds before: the old names are still read.
|
|
;
|
|
; Everywhere below, a topic or node can be written as a name or an id.
|
|
; Topic lists (and a peer's node lists): names and ids separated by ";",
|
|
; ranges of ids (100-150), wildcards like file names (sensors.*, kitchen-??:
|
|
; * any characters, ? one, they only match names), or * for every one.
|
|
; In a peer's AcceptTopics / AcceptNodes, * and wildcards also take names
|
|
; this server doesn't have: they get an id here by themselves, the highest
|
|
; free one counting down from 65535 (see them with the "names" command).
|
|
|
|
[BakaShrot]
|
|
; Config shared by every type of config.
|
|
|
|
; This node's Ed25519 private key (Base64), from KeyGen.exe. It proves who
|
|
; this server is: clients seal their Hello for its public key and check
|
|
; that it signed the handshake, so they need that public key (client.ini's
|
|
; ServerPublicKey, peers' PublicKey below in THEIR own config). The server
|
|
; logs it when it starts. See Commons/Networking/Connections.pbi.
|
|
PrivateKey =
|
|
|
|
; The topic and node this server authenticates as when it links to its
|
|
; peers, a name or an id. Its peers must register it under the same names.
|
|
Topic =
|
|
Node =
|
|
|
|
|
|
[BakaShrot.Topics]
|
|
; One line per named topic: name = this server's id for it.
|
|
; logs = 1
|
|
; sensors = 2
|
|
|
|
|
|
[BakaShrot.Nodes]
|
|
; One line per named node (a client's or a server's), same as topics. Every
|
|
; server that should get a node's messages must name it too.
|
|
; Once a name has messages, keep its id: the server refuses to start if the
|
|
; config moves it to another one, and says which id to use.
|
|
; kitchen = 2
|
|
|
|
|
|
[BakaShrot.Retention]
|
|
; How long this server keeps each topic's messages, counted from when they
|
|
; were pushed (to whichever server they were first pushed to). Past that,
|
|
; they may be deleted: checked every RetentionInterval seconds. Each server
|
|
; has its own: a peer keeps its copies as long as its own config says.
|
|
; One line per topic: name or id = age, a pattern (sensors.*), or * for
|
|
; every topic not listed. A topic takes its id's line, else its name's,
|
|
; else the first pattern matching it, else *'s.
|
|
; Ages: numbers with a unit, s m h d w, added up (1d12h), or forever.
|
|
; Without any line, everything is kept forever.
|
|
; Deleting doesn't shrink the file, SQLite reuses the space for new
|
|
; messages; the "vacuum" console command gives it back to the disk.
|
|
; logs = 30d
|
|
; sensors.* = 12h
|
|
; * = 365d
|
|
|
|
|
|
[BakaShrot.Server]
|
|
; IPV4 that the server will be bound to.
|
|
Host =
|
|
|
|
; Used port.
|
|
Port =
|
|
|
|
; The topics replicated with every peer that doesn't say otherwise
|
|
; (SendTopics, AcceptTopics below).
|
|
; Format: logs;0;100-150;... or * for every topic.
|
|
ReplicatingTopics =
|
|
|
|
; Amount of threads used for networking-related tasks.
|
|
NetThreadPoolSize = 4
|
|
|
|
; SQLite database file holding the messages.
|
|
DatabasePath = ./test.sqlite
|
|
|
|
; Seconds to wait before connecting to a peer again, after failing to
|
|
; connect or losing the connection.
|
|
PeerRetryDelay = 10
|
|
|
|
; Seconds between two check-ins with a linked peer, where it's sent the
|
|
; messages it's missing.
|
|
PeerSyncInterval = 5
|
|
|
|
; Most messages sent to a peer per packet when it's missing some, 1-10000.
|
|
; A batch is also cut short at about 64 KB, a bigger message goes alone.
|
|
PeerBatchSize = 100
|
|
|
|
; Seconds between two passes deleting the messages past their topic's age
|
|
; ([BakaShrot.Retention] above). Only runs if a topic has one.
|
|
RetentionInterval = 60
|
|
|
|
|
|
; One [BakaShrot.Peer.<name>] section per peer this node talks to.
|
|
; <name> is only a key for this file; it is never sent on the wire.
|
|
[BakaShrot.Peer.example]
|
|
; Remote address of the peer. Can be a domain name, IPV4 or IPV6.
|
|
Host =
|
|
|
|
; Remote port of the peer (0-65535).
|
|
Port =
|
|
|
|
; The server links to every peer on start, and retries every PeerRetryDelay.
|
|
; The peer must register this server in one of its [BakaShrot.Client.<name>].
|
|
; The link only goes through if the peer proves it holds the private key
|
|
; of PublicKey below, and it's encrypted.
|
|
|
|
; Remote node's topic and node, names or ids. The peer authenticates with
|
|
; them when it links to here.
|
|
Topic =
|
|
Node =
|
|
|
|
; The topics sent to this peer (if it takes them), and the topics taken
|
|
; from it. Both default to ReplicatingTopics.
|
|
; SendTopics = logs;sensors.*
|
|
; AcceptTopics = logs;sensors.*
|
|
|
|
; The nodes whose messages are sent to this peer (default: every one), and
|
|
; the nodes whose messages are taken from it (default: the ones named in
|
|
; [BakaShrot.Nodes], no other). AcceptNodes = kitchen-* takes every
|
|
; kitchen-something the peer sends, named here or not.
|
|
; SendNodes = *
|
|
; AcceptNodes = kitchen-*;garage
|
|
|
|
; This peer's Ed25519 public key (Base64), required: the link's Hello is
|
|
; sealed for it, and the peer must sign the handshake with its private key.
|
|
; It's also the key the peer authenticates with when it links to here.
|
|
PublicKey =
|
|
|
|
|
|
; One [BakaShrot.Client.<name>] section per client allowed to connect.
|
|
; <name> is only a key for this file; it is never sent on the wire.
|
|
[BakaShrot.Client.example]
|
|
; Ed25519 public keys (Base64) this client is allowed to authenticate with.
|
|
; Format: Key;Key;...
|
|
PublicKeys =
|
|
|
|
; Topic and node pairs this client is allowed to authenticate as, names or ids.
|
|
; Format: Topic:Node;Topic:Node;...
|
|
Identities =
|
|
|
|
; The topics it may push to (always under its own node), and the topics it
|
|
; may read the latest messages of. Both default to the topics of its
|
|
; Identities, empty allows none.
|
|
; PushTopics = logs;sensors
|
|
; ReadTopics = *
|
|
|
|
; What this client may do once authenticated, 1 to allow, 0 to deny.
|
|
; Read: GetLatestMessage. Write: PushMessage.
|
|
; Query: raw read-only SQL, which can read every topic's data, whatever
|
|
; ReadTopics says. The "messages" view has the names:
|
|
; SELECT * FROM messages WHERE topic = 'logs' AND node = 'kitchen'
|
|
AllowRead = 1
|
|
AllowWrite = 1
|
|
AllowQuery = 0
|