Skip to content

Add NIP-11 limitation field to relay info document - #102

Open
KTibow wants to merge 1 commit into
barrydeen:masterfrom
KTibow:nip11-limitation
Open

Add NIP-11 limitation field to relay info document#102
KTibow wants to merge 1 commit into
barrydeen:masterfrom
KTibow:nip11-limitation

Conversation

@KTibow

@KTibow KTibow commented May 9, 2026

Copy link
Copy Markdown

The relay's NIP-11 response was missing the limitation block entirely.
Since this is a Web-of-Trust relay that rejects events from untrusted pubkeys, it should use this standard format to communicate that it's locked down.

Change

Added a Limitation field to the RelayInformationDocument in main.go:

Limitation: &nip11.RelayLimitationDocument{
    MaxMessageLength: 512000,
    MaxLimit:         500,
    DefaultLimit:     500,
    AuthRequired:     false,
    PaymentRequired:  false,
    RestrictedWrites: true,
},

Evidence

restricted_writes: true

Once the trust network is built, only pubkeys in it may write events:

rg -n "not in web of trust" /tmp/wot-relay/
main.go:188:		return true, "not in web of trust"

rg -n "trusted := trustNetworkMap" /tmp/wot-relay/
main.go:174:		trusted := trustNetworkMap[pkHex]
main.go:773:	trusted := trustNetworkMap[ev.PubKey.Hex()]

max_message_length: 512000

Khatru's NewRelay() sets MaxMessageSize: 512000, which is applied via ws.conn.SetReadLimit(rl.MaxMessageSize). The wot-relay never overrides it.

rg -n "MaxMessageSize" /tmp/nostrlib/khatru/relay.go
55:		MaxMessageSize: 512000,
126:	MaxMessageSize          int64         // Maximum message size allowed from peer.

rg -n "SetReadLimit" /tmp/nostrlib/khatru/handlers.go
130:		ws.conn.SetReadLimit(rl.MaxMessageSize)

max_limit: 500

UseEventstore is called with 500:

rg -n "UseEventstore" /tmp/wot-relay/
main.go:164:	relay.UseEventstore(db, 500)

In khatru, maxQueryLimit is passed to QueryStored as maxLimit:

rg -n "func.*UseEventstore" /tmp/nostrlib/khatru/relay.go
138:func (rl *Relay) UseEventstore(store eventstore.Store, maxQueryLimit int) {

In the LMDB query engine, maxLimit caps the emitted count:

rg -n "totalEventsEmitted == limit" /tmp/nostrlib/eventstore/lmdb/query.go
170:			if totalEventsEmitted == limit {

default_limit: 500

When a filter has no limit, GetTheoreticalLimit() returns math.MaxInt, so maxQueryLimit (500) is the effective cap.

rg -n "return math.MaxInt" /tmp/nostrlib/filter.go
195:	return math.MaxInt

auth_required: false

No auth policy is installed:

rg -n "MustAuth" /tmp/wot-relay/
(no results)

payment_required: false

No payment infrastructure:

rg -n "Fees|PaymentsURL|payments_url|PaymentRequired|payment_required" /tmp/wot-relay/
(no results)

Fields deliberately omitted

None of these have code-enforced limits — using omitempty to leave them absent is correct:

Field Reason
max_subscriptions addListener() appends to []listenerSpec with no capacity check
max_subid_length Subscription IDs stored as-is, no length validation
max_event_tags PreventTooManyIndexableTags exists in khatru but is not wired in main.go
max_content_length PreventLargeContent exists in khatru but is not wired in main.go
min_pow_difficulty No PoW check; omitempty drops the zero value
created_at_lower_limit PreventTimestampsInThePast is not wired; deleteOldNotes() is post-hoc cleanup
created_at_upper_limit PreventTimestampsInTheFuture is not wired

Confirmed via:

rg -n "PreventLargeContent|PreventTooManyIndexableTags|PreventTimestampsIn|RestrictToSpecifiedKinds" /tmp/wot-relay/
(no results)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant