From e026ca3b39513d4b8c9911a4cbe43d60fa13d3b1 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sat, 10 Oct 2026 19:03:47 -0700 Subject: [PATCH] Renew XMPP router mappings automatically Refresh UPnP forwarding at boot and every five minutes, deriving all listeners and relay ports from the XMPP network definition. Record production protocol checks and preserve the stopped preview. Assisted-by: gpt-6 --- nixos/zenith.nix | 21 ++++++++++++++++++--- tools/xmpp.md | 34 ++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/nixos/zenith.nix b/nixos/zenith.nix index 7dc047f978f0d75e4fae2f229e268c30937f3d48..1a56e52db9a7aacbafc78190f3a390fe23dfd8c6 100644 --- a/nixos/zenith.nix +++ b/nixos/zenith.nix @@ -1,8 +1,10 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: let adminKey = lib.fileContents ../config/admin.pub; pool = "globe"; xmppNetwork = builtins.fromJSON (builtins.readFile ../service/xmpp/network.json); + xmppTCPPorts = map (name: xmppNetwork.${name}) [ "c2s" "c2s_tls" "s2s" "turn" "turn_tls" ]; + xmppUDPPorts = [ xmppNetwork.turn xmppNetwork.turn_tls ]; encryptionRoots = { apps = "apps"; clover = "clover"; @@ -17,11 +19,24 @@ in networking.hostName = "zenith"; networking.hostId = "4fa19ccb"; - networking.firewall.allowedTCPPorts = [ 80 443 ] ++ map (name: xmppNetwork.${name}) [ "c2s" "c2s_tls" "s2s" "turn" "turn_tls" ]; - networking.firewall.allowedUDPPorts = [ xmppNetwork.turn xmppNetwork.turn_tls ]; + networking.firewall.allowedTCPPorts = [ 80 443 ] ++ xmppTCPPorts; + networking.firewall.allowedUDPPorts = xmppUDPPorts; networking.firewall.allowedUDPPortRanges = [{ from = xmppNetwork.relay_first; to = xmppNetwork.relay_last; }]; networking.firewall.interfaces.enp4s0.allowedTCPPorts = [ 445 ]; + systemd.services.xmpp-nat = { + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + startAt = "*:0/5"; + serviceConfig = { Type = "oneshot"; DynamicUser = true; }; + script = '' + ${pkgs.miniupnpc}/bin/upnpc -u http://${config.networking.defaultGateway.address}:1900/whaoc/rootDesc.xml -e "Snow Globe XMPP" -r \ + ${lib.concatMapStringsSep " " (port: "${toString port} TCP") xmppTCPPorts} \ + ${lib.concatMapStringsSep " " (port: "${toString port} UDP") (xmppUDPPorts ++ lib.range xmppNetwork.relay_first xmppNetwork.relay_last)} + ''; + }; + boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; boot.zfs.forceImportRoot = false; diff --git a/tools/xmpp.md b/tools/xmpp.md index 011c2c8cf11de27566beb3489edd6472e86623ce..1a47e9ef7365ed60699e8d5c27b7d5cade10ccc3 100644 --- a/tools/xmpp.md +++ b/tools/xmpp.md @@ -24,12 +24,33 @@ Production firewall rules are declared in `nixos/zenith.nix`. The DNS provider provisions client, direct-TLS client, and federation SRV records pointing at `xmpp.paperclover.net`; the website keeps its existing apex address. Router forwarding must send the TCP listeners, UDP TURN listeners, and UDP relay range -to Zenith. Production activation uses the normal described-main deployment: +to Zenith. `xmpp-nat.service` refreshes UPnP mappings on startup and every five +minutes, using the Archer AX3000's description URL at the configured gateway. +The description is fetched directly; multicast SSDP discovery failed on this +host. Production activation uses the normal described-main deployment: ```sh STUDIO_DEPLOY_HOST=root@10.0.0.1 STUDIO_DEPLOY_PORT=22 python3 tools/deploy.py prod ``` +## Zenith production, 2026-10-10 + +The owner-readable connection file on Clover's Mac is +`~/.local/share/snowglobe/xmpp.json`. Monal can use the production JID and its +generated password; the explicit server is `xmpp.paperclover.net`, port `5223`, +with direct TLS. Client and federation SRV records resolve to that server. + +Verified through the public address from the home LAN: TLS authentication, two +resources, carbons, MAM retrieval, stream resumption, PEP publication/deletion, +private group creation/history/destruction, PNG upload/download, WebSocket, +authenticated UDP TURN allocation/deallocation, relay address/range, rejection +of a private peer, STARTTLS, and TURN TLS certificate validation. All three tasks +had zero restarts. The normal deployment took backup +`20261011T015942Z-a7e251` and passed all service route checks. A transient systemd +probe confirmed UPnP refresh works with `DynamicUser`. Off-LAN calls, iOS push +delivery, federation with another server, and recovery after a router restart +need client-side verification. + ## Zenith preview, 2026-10-10 Stage: `xmpp-preview-c035f9fb` @@ -37,13 +58,10 @@ Hostname: `xmpp-preview-c035f9fb.paperclover.net` JID: `clover@xmpp-preview-c035f9fb.paperclover.net` Dataset: `globe/staging/xmpp-preview-c035f9fb` -The generated password is in Nomad variables. Clover's Mac also has an -owner-readable connection file at -`~/.local/share/snowglobe/xmpp-preview.json`; credentials are not tracked here. -Monal can use the preview JID and password with a manual server of `10.0.0.1`, -port `5223`, and direct TLS while on the home LAN. The public hostname serves -HTTPS media and WebSocket; public native connections require router forwarding -to Zenith for the listeners and UDP relay range in `network.json`. +The preview Nomad job and its transient firewall service were stopped for the +production cutover. Its dataset, Nomad variables, and owner-readable Mac +connection file at `~/.local/share/snowglobe/xmpp-preview.json` are retained. +Preview account data was not copied into production. Delete the preview, including its accounts and history: -- 2.54.1