readme: Azzamo Noteguard overview, build features, testing

- Intro: what this fork adds, the free and premium relay setups and
  their configs, and that unconfigured behavior matches upstream.
- Build feature table (remote, cloudflare, forwarder, nscript) and the
  Rust 1.88 requirement.
- Filter overview table; drop the stale "only one filter so far" line.
- Fix the ratelimit key name: posts_per_minute, not notes_per_minute.
- Testing: feature test commands, the golden test, and trying a config
  with sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-10-29 07:34:06 +00:00
co-authored by Claude Opus 5.5
parent 059e763022
commit d2f160e0f3
+78 -13
View File
@@ -1,8 +1,27 @@
# noteguard
# Azzamo Noteguard
A high performance note filter plugin system for [strfry]
A high performance note filter plugin system for [strfry], extended to run the
Azzamo relays. It is a fork of [damus-io/noteguard] and keeps all of its
filters; one binary and one codebase serve every relay, each with its own
`noteguard.toml`:
WIP!
| Relay | Who can write | Config |
|---|---|---|
| nostr.azzamo.net (free) | Everyone, rate limited per IP. Premium members skip the rate limit and IP bans. | [noteguard-free.example.toml](noteguard-free.example.toml) |
| relay, us, asia (premium) | Active premium members only. | [noteguard-premium.example.toml](noteguard-premium.example.toml) |
On both, every note is also checked against the Azzamo pubkey and word
blacklists. What this fork adds on top of upstream:
- **Remote lists ([Sources](#sources))**: premium members, blacklisted pubkeys and blocked words fetched from the Azzamo API (or a file), reloaded in the background, with the last good copy kept through outages and an optional disk cache for restarts. Premium entries carry an expiry that is checked on every note.
- **Premium gate**: `whitelist.pubkey_sources` lets only active members write, and fails closed if the member list could not be loaded.
- **Premium exemptions**: `ratelimit.exempt_source` and `content.exempt_source` let members skip rate limits and IP bans.
- **Custom rejection messages** for every filter ([Rejection messages](#rejection-messages)), with the old texts as defaults.
- **NIP-05 lists**: accept only the pubkeys in a `nostr.json` `names` map.
Without any of the new keys, noteguard behaves exactly like upstream; a golden
output test guards that. [DEPLOY.md](DEPLOY.md) is the rollout and rollback
checklist for the Azzamo relays.
## Usage
@@ -42,6 +61,21 @@ queue_size = 2000
You can install noteguard by copying the binary to the strfry directory.
Optional features are enabled at build time:
| Feature | What it adds | Needed by the Azzamo configs |
|---|---|---|
| `remote` | Fetching [sources](#sources) over http(s) | yes |
| `cloudflare` | Pushing IP bans to a Cloudflare WAF list ([details](#cloudflare-edge-banning)) | optional |
| `forwarder` | The [forwarder](#forwarder) filter | no |
| `nscript` | WASM filters ([details](#nscript-experimental)) | no |
`remote` and `cloudflare` need Rust 1.88 or newer:
```sh
$ cargo build --release --features remote,cloudflare
```
Static musl builds are convenient ways to package noteguard for deployment. It enables you to copy the binary directly to your server, ensure that you are using the correct architecture that your server is running.
You most likely want `x86_64-unknown-linux-musl` or `aarch64-unknown-linux-musl`. Install this target with rustup, build noteguard, and copy the binary to the server:
@@ -81,19 +115,26 @@ Ready-to-edit configs for the Azzamo relays, both served by the same binary:
- [noteguard-free.example.toml](noteguard-free.example.toml): everyone can write, rate limited per IP, premium members exempt, Azzamo blacklists applied.
- [noteguard-premium.example.toml](noteguard-premium.example.toml): only active premium members can write, Azzamo blacklists applied.
They fetch their lists over https, so build with the `remote` feature (Rust 1.88 or newer):
```sh
$ cargo build --release --features remote,cloudflare
```
[DEPLOY.md](DEPLOY.md) is the step-by-step checklist for rolling them out and rolling back.
They fetch their lists over https, so build them with the `remote` feature (see
above). Before deploying, replace every `CHANGEME` URL with the real Azzamo API
endpoint and set `AZZAMO_API_TOKEN` in strfry's environment.
[DEPLOY.md](DEPLOY.md) is the step-by-step checklist for rolling them out and
rolling back.
## Filters
You can use any of the builtin filters, or create your own!
This is the initial release, and only includes one filter so far:
| Filter | Does |
|---|---|
| [`protected_events`](#protected-events) | Rejects NIP-70 protected events |
| [`kinds`](#kinds) | Rejects listed event kinds |
| [`blacklist`](#blacklist) | Rejects listed pubkeys, IPs and CIDR ranges (static and remote) |
| [`whitelist`](#whitelist) | Accepts only listed pubkeys and IPs; with `pubkey_sources`, the premium gate |
| [`content`](#content) | Silently drops notes containing blocked words (static and remote) |
| [`ratelimit`](#ratelimit) | Limits notes per minute per IP, with optional IP bans |
| [`forwarder`](#forwarder) | Forwards notes to another relay |
| [`nscript`](#nscript-experimental) | Runs a WASM filter |
### Rejection messages
@@ -170,7 +211,7 @@ The ratelimit filter limits the rate at which notes are written to the relay per
Settings:
- `notes_per_minute`: the number of notes per minute which are allowed to be written per ip.
- `posts_per_minute`: the number of notes per minute which are allowed to be written per ip.
- `whitelist` *optional*: a list of IP4 or IP6 addresses that are allowed to bypass the ratelimit.
@@ -524,7 +565,21 @@ wiring.
## Testing
You can test your filters like so:
Run the test suite for the default build and for the feature builds:
```sh
$ cargo test
$ cargo test --features remote,cloudflare
```
`tests/golden.rs` pipes [test/golden.inputs](test/golden.inputs) through the
binary with a frozen config ([test/golden.toml](test/golden.toml)) and compares
the output line by line with [test/golden.expected](test/golden.expected). It
pins the behavior of an unmodified config, so any change that alters existing
verdicts or messages fails it. Regenerate the expected file only for an
intentional behavior change.
You can also feed notes to a build by hand:
```sh
$ cargo build
@@ -532,5 +587,15 @@ $ <test/inputs ./target/debug/noteguard
$ ./test/delayed | ./target/debug/noteguard
```
To try a config with http(s) sources, build with `remote`, point
`NOTEGUARD_CONFIG` at it and turn on logging to see each list load (with the
placeholder `CHANGEME` URLs every fetch fails, and the log says so):
```sh
$ cargo build --features remote
$ NOTEGUARD_CONFIG=noteguard-free.example.toml RUST_LOG=info ./target/debug/noteguard <test/inputs
```
[strfry]: https://github.com/hoytech/strfry
[damus-io/noteguard]: https://github.com/damus-io/noteguard
[nip70]: https://github.com/nostr-protocol/nips/blob/protected-events-tag/70.md