pipeline = ["protected_events", "kinds", "content", "whitelist", "ratelimit"] [filters.ratelimit] posts_per_minute = 8 whitelist = ["127.0.0.1"] message = "rate-limited: you note too much" # IP-ban persistent offenders: after this many *consecutive* rate-limit # rejections from the same IP (a streak broken by any accepted post), reject # everything from that IP for `ban_duration_secs`. Omit `ban_after` to disable # banning entirely (the filter then only ever rate-limits). ban_after = 10 ban_duration_secs = 3600 # one hour ban_message = "banned: too many rate-limit violations, try again later" # Substring blocklist. Matching is homoglyph- and case-insensitive: both the # note content and each term are folded to their UTS #39 confusables skeleton # and lowercased before comparison, so Cyrillic/look-alike spoofs like # "Dаmus Аirdrop" (Cyrillic а/А) are caught by the plain "Damus Airdrop" entry. [filters.content] filters = [ "https://cdn.nostr.build/i/some-spammy-or-abusive-image-image.png", "Damus Airdrop", ] # IP-ban repeat offenders (same knobs as `filters.ratelimit`). Content # violations accrue *cumulatively* per IP — unlike ratelimit's consecutive # streak, a clean note does not reset the count — and once they cross # `ban_after`, every note from that IP is silently shadow-rejected for # `ban_duration_secs`. Omit `ban_after` to disable banning (match-only, as # before). `ban_message` is unused here since the ban is a stealth shadow-reject. ban_after = 5 ban_duration_secs = 3600 # one hour # --------------------------------------------------------------------------- # Cloudflare edge-banning (optional; requires the `cloudflare` build feature) # # When present, every BanTracker ban — from `filters.ratelimit` OR # `filters.content` — is *also* pushed to a Cloudflare WAF IP list for the ban's # duration, then removed when it expires. A blocked IP is then dropped at # Cloudflare's edge before it ever reaches the relay. # # One-time setup on your side: create an IP list and a WAF custom rule that # blocks it, e.g. expression `(ip.src in $)` with action "block". # noteguard only manages the list's membership, not the rule. # # The API token is read from the CLOUDFLARE_API_TOKEN environment variable (it # needs Account Filter Lists: Edit), never from this file. Omit this whole # section to disable edge-banning; bans then stay relay-local as before. # [cloudflare] # account_id = "" # list_id = "" # comment = "noteguard auto-ban" # optional; stamped on each list item # timeout_secs = 10 # optional; per-request HTTP timeout # api_base = "https://api.cloudflare.com/client/v4" # optional override [filters.whitelist] pubkeys = ["16c21558762108afc34e4ff19e4ed51d9a48f79e0c34531efc423d21ab435e93"] ips = ["127.0.0.1"] [filters.kinds] kinds = [30065, 1064, 34550, 4550] [filters.kinds.messages] 30065 = "blocked: files on nostr is dumb" 1064 = "blocked: files on nostr is dumb" 34550 = "blocked: please use a dedicated relay for moderated communities" 4550 = "blocked: please use a dedicated relay for moderated communities" [filters.protected_events] # --------------------------------------------------------------------------- # Read policy — `noteguard read` # # Everything above is the write side: what gets *stored*. This section is the # read side: which already-stored events are *delivered* to a given subscriber. # Withholding an event never touches storage and never affects any other # subscriber. strfry runs it as a separate process against this same file: # # readPolicy { plugin = "./noteguard read" } # --------------------------------------------------------------------------- [readpolicy] # Read filters to compose, in order. Empty (the default) delivers everything, # and every subscription takes strfry's zero-copy passthrough fast path. The # filter tables below are inert until their name is listed here. pipeline = [] # pipeline = ["max_events_per_conn", "read_bandwidth", "nscript"] # Per-connection delivery cap: withhold once this connection has been delivered # `max` events, counted across all of its subscriptions and freed on disconnect. [readpolicy.filters.max_events_per_conn] max = 5000 # Read-bandwidth throttle: cap the BYTES of events delivered per minute, keyed # per client IP so reconnecting with a fresh connId does not reset the budget. # The read-side analogue of `filters.ratelimit` above. [readpolicy.filters.read_bandwidth] bytes_per_minute = 5000000 # Shared-memory buckets: strfry runs one plugin process per read-serving thread, # so per-process buckets would make the effective per-IP limit up to # `relay.numThreads.reqWorker + reqMonitor` times `bytes_per_minute`. To enforce # ONE authoritative per-IP bucket, every process mmaps a single tmpfs file (see # the README). This is now the DEFAULT: leave `shared_state_path` unset and each # process attaches to /dev/shm/noteguard-read-bandwidth automatically — no config # needed for normal use. Fails open (delivers) if the file can't be mapped or the # table fills. # shared_state_path = "/dev/shm/noteguard-read-bandwidth" # the default path; set to override # shared_state_path = "" # OPT OUT: per-process buckets — DISABLES cross-process # # enforcement (for hosts that can't use tmpfs) # max_ips = 65536 # distinct IPs the shared table holds before it fails open # Exempt entries; each matches a connection's client IP OR its authed pubkey # hex. A whitelisted connection is never metered, so this filter asks for no # per-event work for it (the subscription is then passthrough unless another # filter in the pipeline still needs events). whitelist = ["127.0.0.1"] # Guest wasm run per subscription, scoped to the subscriber (owner = the NIP-42 # authed pubkey), so a per-npub feed filter runs scoped to whoever is reading. # Requires the `nscript` build feature; without it this pipeline entry is logged # and skipped (fail open). [readpolicy.filters.nscript] module = "./mute_word.wasm" # STUB for follow-set distribution: owner-hex -> the hex pubkeys they follow, # backing the guest's `is_following` accessor, until scripts and follows are # sourced from signed on-relay submissions. [readpolicy.filters.nscript.follows] # "1111…1111" = ["2222…2222"]