1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Protocol 6: node identities, error codes, Synchronous, schema v8, examples

- Protocol 5: a client authenticates as a node (Node), its pushes go to the
  section's DefaultTopic unless they name one; old Identities refused at
  start with what to write instead.
- Topics listed by name, ids picked and kept by the server; nodes come from
  client sections, [BakaShrot.Nodes] optional, AcceptNodes = * by default.
- Protocol 6: every refusal carries a code, every client failure too
  (BakaShrot_ErrorCodes.pbi, BakaShrot_GetLastError(), ErrorCode in Python);
  nothing reconnects by itself, delivery is at least once.
- [BakaShrot.Server] Synchronous = FULL (default) or NORMAL, benchmarked.
- Schema v8: browse table and browse_messages view for database tools.
- Tools renamed BakaShrot<Name>, wait for Enter when started from Explorer.
- Examples/SingleServer: a server and a client with scripts (example keys,
  public on purpose).
- Restart-Test.ps1: servers killed mid-traffic and mid-catch-up.
- Docs: one server per node rule, DatabaseError() checked per thread,
  release notes' Compatibility section, Notes "Right now".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwFeVQrLqMQPw9AZnsHqQH
This commit is contained in:
2026-11-09 23:57:55 +01:00
parent df61ef9719
commit 488ffe4bc8
67 changed files with 3163 additions and 1029 deletions
+67 -28
View File
@@ -3,15 +3,17 @@
; 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).
; name. Topics are named in [BakaShrot.Topics]; nodes by the sections that
; define them ([BakaShrot] Node, a peer's, a client's), [BakaShrot.Nodes]
; only names the others. The server gives every name its id, and keeps it.
; 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.
; The server's "names" command and the BakaShrotList tool list them all.
;
; Topic, Node and ReplicatingTopics were TopicId, NodeId and
; ReplicatingTopicIds before: the old names are still read.
@@ -27,31 +29,37 @@
[BakaShrot]
; Config shared by every type of config.
; This node's Ed25519 private key (Base64), from KeyGen.exe. It proves who
; This node's Ed25519 private key (Base64), from BakaShrotGenerateKeyPairs.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 =
; The node this server authenticates as when it links to its peers, a name
; or an id. Its peers must register it under the same name: a client
; section with this Node and this server's public key. (A Topic left here
; from before protocol 5 is ignored.)
Node =
[BakaShrot.Topics]
; One line per named topic: name = this server's id for it.
; logs = 1
; sensors = 2
; One topic name per line. This server gives each its id: the one its
; database already has for it, or the lowest free one for a new one, so the
; order doesn't matter and they keep their ids.
; "name = id" pins one instead (configs from before work as they are). Once
; a name has messages, its id can't change: the server refuses to start if
; a pin moves it, and says which id to use.
; logs
; sensors
[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
; Optional. The nodes [BakaShrot] Node, the peers' and the clients' Node
; define are named already. List the others this server should know by name
; up front, like topics; peers add the ones they send as they come
; (AcceptNodes, below).
; kitchen
[BakaShrot.Retention]
@@ -114,6 +122,21 @@ MaxAttachmentSize = 1G
; after which the upload is deleted.
UploadTimeout = 3600
; How hard the database makes sure a push is on disk before answering it.
; FULL (default) every commit is flushed to disk: a message the server
; acknowledged survives a power loss or an OS crash.
; NORMAL flushed about once a second only (at the checkpoints): faster
; (twice the pushes under full load, measured), but a power loss
; or an OS crash loses the last second or so of acknowledged
; messages, and their ids are handed out again, which peers that
; already got them can't tell (Design/ReplicationIssues.md #1).
; A crash of the server alone loses nothing either way.
; The cost of FULL is the disk's flush time, once per group of pushes: well
; under a millisecond on a server SSD, ~10 ms on a hard disk, which then
; caps one client pushing one message at a time to ~100/s.
; See Design/StorageConcurrency.md for the numbers.
Synchronous = FULL
; 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.
@@ -129,9 +152,8 @@ Port =
; 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 =
; The peer's node, a name or an id: the one in its own [BakaShrot] Node.
; It authenticates as it when it links to here.
Node =
; The topics sent to this peer (if it takes them), and the topics taken
@@ -140,9 +162,9 @@ Node =
; 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.
; the nodes whose messages are taken from it (default: every one, the names
; this server doesn't have yet are added as they come). AcceptNodes =
; kitchen-*;garage only takes those, named here or not.
; SendNodes = *
; AcceptNodes = kitchen-*;garage
@@ -159,13 +181,30 @@ PublicKey =
; 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 node this client writes as, a name or an id, required. Every message
; it pushes is stored under it, so the server decides which node each key
; writes as, and no client can push as another's node (or as a peer's).
; Its client.ini's Node must say the same. A key that writes as several
; nodes is listed in a section per node.
; ONE SERVER PER NODE: give a node a client section on the one server it
; pushes to, the others get its messages by replication. Two servers taking
; pushes for the same node end up with different messages under the same
; ids, which nothing detects (Design/ReplicationIssues.md #1). To read from
; another server, give the client another node there (or no write access:
; AllowWrite = 0).
Node =
; Where its pushes go when they don't name a topic, a name or an id.
; Optional: without it, every push must name its topic. Only a default, it
; may push to any topic in PushTopics.
; DefaultTopic = logs
; (Identities, the Topic:Node pairs before protocol 5, isn't read any more:
; the server refuses to start with it, saying what to write instead.)
; 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.
; may read the latest messages of. Both default to its DefaultTopic,
; nothing without one; empty allows none.
; PushTopics = logs;sensors
; ReadTopics = *