FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Nostr relay: add size limits (and optional write auth and persistence), in line with strfry and others · Issue #648 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub

Repository navigation

Nostr relay: add size limits (and optional write auth and persistence), in line with strfry and others #648

Open

Description

The built-in Nostr relay (--nostr) has no size limits of its own. It's barely used beyond one pod so far, so this isn't urgent, but it's worth matching what other relays do before anyone leans on it.

What JSS does now (at 2b9555b)

  • src/server.js:417 registers @fastify/websocket with no options, so ws uses its default maxPayload of 100 MB per message.
  • src/nostr/relay.js checks no event size, keeps up to 1,000 events in memory only (DEFAULT_MAX_EVENTS, lost on restart), allows anyone to write, and rate-limits to 60 events per minute per connection.

So a client can send very large events, and a handful of them can use a lot of memory.

What other relays default to

Relay Max event Max websocket message Other defaults
strfry 64 KB (maxEventSize) 128 KB (maxWebsocketPayloadSize) ≤ 2,000 tags, tag values ≤ 1 KB, created_at window (15 min ahead, 3 years back), write-policy plugin, LMDB on disk
nostr-rs-relay 128 KB 128 KB kind allow/block lists, pubkey allowlist, NIP-42, SQLite/Postgres
khatru — 500 KB (MaxMessageSize) policies as plug-in functions
nostream 100 KB content per kind range 512 KB (maxPayloadSize) per-kind limits, rate limits, Postgres
JSS none 100 MB 60 events/min/connection, 1,000 in memory, open writes

Suggested defaults

  1. Websocket message cap of 128 KB for the relay (configurable).
  2. Event size cap of 64 KB (configurable), like strfry.
  3. Tag limits: at most 2,000 tags, tag values at most 1 KB.
  4. created_at window, like strfry's.
  5. Optional write allowlist (e.g. only the pod owner's key) or NIP-42 auth, off by default.
  6. Optional persistence to disk under the pod, for events meant to last.

1–4 close the size issue; 5–6 make the relay usable for real data (for example, publishing mind maps as Nostr events, which are 4–5 KB each).

Sources: strfry.conf, nostr-rs-relay config.toml and config.rs, khatru relay.go, nostream default-settings.yaml.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL