Phase 9 of PLAN.md. - noteguard-free.example.toml: everyone writes; blacklist, content and ratelimit use the Azzamo sources; premium exempt from rate limit and IP bans. - noteguard-premium.example.toml: whitelist gate on the premium source (fails closed when no list or cache), blacklists, 60/min runaway guard with no exemption and no bans. - DEPLOY.md: build, host prep (env, cache dir), smoke test, install, rollout order, rollback, operational notes. - README: Sources section (keys, loading model, accepted bodies) and an Azzamo deployments section. - Tests load both examples and the repo noteguard.toml with sources declared but not fetched, and check the gate fails closed. API URLs are placeholders (CHANGEME) until the endpoints are confirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.5 KiB
Deploying Azzamo Noteguard
One binary, two configs:
| Relay | Config |
|---|---|
| nostr.azzamo.net (free) | noteguard-free.example.toml |
| relay, us, asia (premium) | noteguard-premium.example.toml |
1. Build
Rust 1.88 or newer is required for the remote and cloudflare features.
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.tomlor/etc/noteguard/premium.toml. -
Create the cache directory, writable by the user strfry runs as:
install -d -o strfry -g strfry /var/lib/noteguard(orStateDirectory=noteguardin 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
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 largeMmeans 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
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
- 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.
- One premium relay (asia). Post as a member (accepted) and as a non-member (rejected). Watch for one reload interval.
- The remaining premium relays (us, then relay).
6. Rollback
On the affected relay:
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_messageuntil the first successful fetch. Keepcache_pathset 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.