qriton 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ # A qriton mesh relay on Azure
2
+
3
+ The relay is a plain NATS server. qriton seals every payload end to end, so the relay sees only opaque bytes on opaque subjects: it cannot read, forge or replay messages, and it never holds a group key. It still sees client IP addresses, message sizes and timing.
4
+
5
+ On a trusted local network you can skip all of this and run `nats-server` on any machine; the mesh is end-to-end encrypted either way.
6
+
7
+ ## 1. A small VM with a DNS name
8
+
9
+ ```bash
10
+ az group create -n qriton-mesh -l westeurope
11
+ az vm create -g qriton-mesh -n relay --image Ubuntu2404 --size Standard_B1s \
12
+ --admin-username azureuser --generate-ssh-keys --public-ip-address-dns-name <label>
13
+ az vm open-port -g qriton-mesh -n relay --port 4222 --priority 900
14
+ az vm open-port -g qriton-mesh -n relay --port 80 --priority 910 # only while issuing the certificate
15
+ ```
16
+
17
+ The relay's name is `<label>.westeurope.cloudapp.azure.com`.
18
+
19
+ ## 2. nats-server, pinned and verified
20
+
21
+ ```bash
22
+ ssh azureuser@<label>.westeurope.cloudapp.azure.com
23
+ curl -fsSL -o nats.tar.gz https://github.com/nats-io/nats-server/releases/download/v2.15.0/nats-server-v2.15.0-linux-amd64.tar.gz
24
+ echo "5d2c51caca950333aba84911df7d377f826f3a59ec36061c6539105084f65c92 nats.tar.gz" | sha256sum -c -
25
+ tar -xzf nats.tar.gz && sudo install -m 755 nats-server-v2.15.0-linux-amd64/nats-server /usr/local/bin/
26
+ sudo useradd --system --no-create-home --shell /usr/sbin/nologin nats
27
+ ```
28
+
29
+ ## 3. A TLS certificate
30
+
31
+ ```bash
32
+ sudo apt-get install -y certbot
33
+ sudo certbot certonly --standalone -d <label>.westeurope.cloudapp.azure.com
34
+ sudo install -d -o root -g nats -m 750 /etc/nats/tls
35
+ sudo cp /etc/letsencrypt/live/<label>.westeurope.cloudapp.azure.com/{fullchain,privkey}.pem /etc/nats/tls/
36
+ sudo chgrp nats /etc/nats/tls/*.pem && sudo chmod 640 /etc/nats/tls/*.pem
37
+ ```
38
+
39
+ Then close port 80 again (`az network nsg rule delete ...`, or open it only for renewals) and add a renewal hook that copies the new files and runs `systemctl reload nats-server`.
40
+
41
+ ## 4. Configuration and machine keys
42
+
43
+ Copy `nats-server.conf` and `nats-server.service` from this folder to `/etc/nats/nats-server.conf` and `/etc/systemd/system/nats-server.service`. On each machine that will join, run `qriton mesh status` and add its **NATS user key** to the `users` list:
44
+
45
+ ```
46
+ users = [
47
+ { nkey: "UCCBXLED...", permissions: $QRITON } # laptop
48
+ { nkey: "UD4K2P7Q...", permissions: $QRITON } # windows server
49
+ ]
50
+ ```
51
+
52
+ ```bash
53
+ sudo nats-server -c /etc/nats/nats-server.conf -t # check the file
54
+ sudo systemctl daemon-reload && sudo systemctl enable --now nats-server
55
+ ```
56
+
57
+ To remove a machine, delete its line and `sudo systemctl reload nats-server`. The server stores public keys only.
58
+
59
+ ## 5. The group
60
+
61
+ ```bash
62
+ qriton mesh init tls://<label>.westeurope.cloudapp.azure.com:4222 # on the first machine; prints an invite code
63
+ qriton mesh join <code> # on each other machine
64
+ ```
65
+
66
+ The invite code contains the group secret: pass it only over a channel you trust, never through the relay. Then set `"mesh": { "enabled": true }` in each machine's `~/.qriton/config.json`. `/peers` shows every machine's fingerprint; compare fingerprints out of band once.
67
+
68
+ If a machine is lost or no longer trusted, remove its NATS key from the server and create a new group (`mesh leave`, `mesh init`, fresh invites) so the old group secret stops working.
@@ -0,0 +1,31 @@
1
+ # NATS server for the qriton mesh. qriton seals every payload end to end, so
2
+ # this server only relays opaque bytes on opaque subjects (q.<hex>). It never
3
+ # holds a group key and cannot read or forge messages.
4
+
5
+ listen: "0.0.0.0:4222"
6
+
7
+ # TLS is required for any server reachable from the internet.
8
+ tls {
9
+ cert_file: "/etc/nats/tls/fullchain.pem"
10
+ key_file: "/etc/nats/tls/privkey.pem"
11
+ timeout: 5
12
+ }
13
+
14
+ # One entry per machine: the "NATS user key" printed by `qriton mesh status`.
15
+ # Removing a line removes that machine; no shared password to rotate.
16
+ authorization {
17
+ QRITON = {
18
+ publish: { allow: ["q.*"], deny: ["$SYS.>", "_INBOX.>"] }
19
+ subscribe: { allow: ["q.*"], deny: ["$SYS.>", "_INBOX.>"] }
20
+ }
21
+ users = [
22
+ # { nkey: "UXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", permissions: $QRITON }
23
+ ]
24
+ }
25
+
26
+ # Small messages only, and no monitoring or clustering port exposed.
27
+ max_payload: 65536
28
+ max_connections: 256
29
+ max_subscriptions: 64
30
+ write_deadline: "10s"
31
+ ping_interval: "30s"
@@ -0,0 +1,31 @@
1
+ [Unit]
2
+ Description=NATS server for the qriton mesh
3
+ After=network-online.target
4
+ Wants=network-online.target
5
+
6
+ [Service]
7
+ User=nats
8
+ Group=nats
9
+ ExecStart=/usr/local/bin/nats-server -c /etc/nats/nats-server.conf
10
+ ExecReload=/bin/kill -HUP $MAINPID
11
+ Restart=on-failure
12
+ RestartSec=2
13
+
14
+ # The relay needs its config, its certificate and a socket; nothing else.
15
+ NoNewPrivileges=yes
16
+ ProtectSystem=strict
17
+ ProtectHome=yes
18
+ PrivateTmp=yes
19
+ PrivateDevices=yes
20
+ ProtectKernelTunables=yes
21
+ ProtectKernelModules=yes
22
+ ProtectControlGroups=yes
23
+ RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
24
+ RestrictNamespaces=yes
25
+ LockPersonality=yes
26
+ MemoryDenyWriteExecute=yes
27
+ CapabilityBoundingSet=
28
+ ReadOnlyPaths=/etc/nats
29
+
30
+ [Install]
31
+ WantedBy=multi-user.target