mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
df61ef9719
- One optional attachment per message, any size up to the server's MaxAttachmentSize (default 1G), sent and stored in 1 MB parts, checked with its SHA-256. Uploaded before its message (UploadStart, UploadChunk), then attached by the PushMessage in the same transaction; uploads never pushed expire after UploadTimeout. Read back a part at a time (GetAttachment). - Replicated separately, after the messages: the message carries the size and SHA-256, then each check-in lists what the peer is missing (MissingAttachments) and sends the parts from where it stopped. Over the receiver's limit, the attachment is marked not kept. - Deleted with its message by the retention, parts cleaned up in the background. Schema v7 (attachments, blobs, blob_chunks), replacing the unused attachements table. - DLL: PushMessageWithFile/WithData, SaveAttachment, LoadAttachment, GetMessageAttachmentSize, IsMessageAttachmentReady. Python: push(..., attachment=), get_attachment(), save_attachment(). Tools: PushMessage -a, GetAttachment. The release smoke test round-trips one. - Tests/Attachments-Test.ps1 (39 checks) and Tests/AttachmentEdges-Test.ps1 (51 checks, with a raw protocol client): wrong SHA-256, bad parts, others' uploads, expiry, replication resuming after a kill, a corrupted stored copy. Found: a corrupted copy is re-sent to peers forever, noted as open item 3 in Notes.md with a proposed fix. - CLAUDE.md: how to build, test, the traps and working rules, for the next session. Notes.md and the Design docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVPXGLs3KK1MAQn3ouP
180 lines
6.9 KiB
INI
180 lines
6.9 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), and the attachments' leftovers.
|
|
RetentionInterval = 60
|
|
|
|
; Biggest attachment this server takes (one per message, see
|
|
; Design/Attachments.md): pushed to it, or replicated (a bigger one's message
|
|
; is kept, its attachment isn't). Bytes, or K M G T (1024-based). 0: none.
|
|
MaxAttachmentSize = 1G
|
|
|
|
; Seconds a client may take to upload an attachment and push its message,
|
|
; after which the upload is deleted.
|
|
UploadTimeout = 3600
|
|
|
|
|
|
; 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
|