# Deploying Azzamo Noteguard One binary, two configs: | Relay | Config | |---|---| | nostr.azzamo.net (free) | [noteguard-free.example.toml](noteguard-free.example.toml) | | relay, us, asia (premium) | [noteguard-premium.example.toml](noteguard-premium.example.toml) | ## 1. Build Rust 1.88 or newer is required for the `remote` and `cloudflare` features. ```sh cargo build --release --features remote,cloudflare cargo test --features remote,cloudflare ``` For a static binary, build for `x86_64-unknown-linux-musl` with the same features. rustls pulls in `ring`, which needs a musl C toolchain (`musl-tools` on Debian) on the build host. ## 2. Prepare each relay host - [ ] Fill in the real API URLs in the config (replace every `CHANGEME`). - [ ] Copy the config to e.g. `/etc/noteguard/free.toml` or `/etc/noteguard/premium.toml`. - [ ] Create the cache directory, writable by the user strfry runs as: `install -d -o strfry -g strfry /var/lib/noteguard` (or `StateDirectory=noteguard` in the systemd unit). - [ ] Give strfry the environment. noteguard inherits strfry's environment, so set it on the strfry service, for example in a systemd drop-in: ```ini [Service] Environment=NOTEGUARD_CONFIG=/etc/noteguard/premium.toml Environment=RUST_LOG=info EnvironmentFile=/etc/noteguard/secrets.env ``` with `/etc/noteguard/secrets.env` (mode 600) holding `AZZAMO_API_TOKEN=...` and, if Cloudflare edge bans are used, `CLOUDFLARE_API_TOKEN=...`. Then `systemctl daemon-reload`. ## 3. Smoke test on the host, before switching strfry over ```sh sudo -u strfry env NOTEGUARD_CONFIG=/etc/noteguard/premium.toml RUST_LOG=info \ AZZAMO_API_TOKEN=... ./noteguard.new < test/inputs ``` Check the log lines on stderr: - `source premium: loaded N entries (M skipped)` for every source. A large `M` means the API shape does not match what noteguard expects. - No `token_env $AZZAMO_API_TOKEN is not set`. - No `fetch failed ... no usable cache`. Then check the cache files exist in `/var/lib/noteguard/`. Expected verdicts: on the premium config, a note from a non-member is rejected with the `whitelist.message`; on the free config it is accepted. ## 4. Install ```sh cp /path/strfry/noteguard /path/strfry/noteguard.prev cp /etc/noteguard/premium.toml /etc/noteguard/premium.toml.prev # if one existed install -m755 noteguard.new /path/strfry/noteguard.tmp mv /path/strfry/noteguard.tmp /path/strfry/noteguard ``` Always replace the binary with `mv` (an atomic rename), never `cp` over the running file. strfry relaunches the write plugin when the plugin file changes; if in doubt, restart strfry. noteguard reads its config only at startup, so after a config-only change `touch` the binary or restart strfry. Point strfry at it (`strfry.conf`): ``` writePolicy { plugin = "/path/strfry/noteguard" } ``` ## 5. Rollout order 1. Free relay first. Watch the log for one reload interval (5 minutes): every source should reload cleanly, and premium members should not be rate limited. 2. One premium relay (asia). Post as a member (accepted) and as a non-member (rejected). Watch for one reload interval. 3. The remaining premium relays (us, then relay). ## 6. Rollback On the affected relay: ```sh mv /path/strfry/noteguard.prev /path/strfry/noteguard mv /etc/noteguard/premium.toml.prev /etc/noteguard/premium.toml # if the config changed ``` Then make sure strfry picked it up: restart strfry, or `touch` the binary if only the config changed. The cache files in `/var/lib/noteguard/` can stay; older binaries ignore them. Every new config key is optional, so the previous config also runs on the new binary: rolling back the config alone turns the new behavior off. ## Operational notes - If the API is down, each relay keeps its last good lists. Member expiries still apply to that stale copy, but new payments and revocations wait until the API is back. - A premium relay that starts with no list and no cache rejects every non-whitelisted writer with `whitelist.unavailable_message` until the first successful fetch. Keep `cache_path` set to avoid this. - API load is roughly (relays x strfry ingester threads x sources) requests every `reload_secs`. - Zap receipts (kind 9735) and NIP-17 gift wraps (kind 1059) addressed to members are signed by non-member keys, so premium relays reject them. - Events arriving through strfry router or sync pass through the same filters, so an expired member's notes stop syncing into premium relays.