; 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. 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 BakaShrotList 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 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 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 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] ; 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] ; 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 ; 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.] section per peer this node talks to. ; 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.]. ; The link only goes through if the peer proves it holds the private key ; of PublicKey below, and it's encrypted. ; 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 ; 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: 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 ; 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.] section per client allowed to connect. ; 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 = ; 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 its DefaultTopic, ; nothing without one; 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