Skip to content

Latest commit

 

History

329 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nostr Relay Framework -- use it to implement your own custom relay.

There is an example/reference implementation at basic. Binaries for that are also available under Releases.

GoDoc

Supported NIPs

These are handled by the framework itself, so every relay built on it gets them:

NIP
01 Basic protocol flow (EVENT, REQ, CLOSE, EOSE, OK, CLOSED, NOTICE), including what used to be NIPs 12, 15, 16, 20 and 33
09 Event deletion request
11 Relay information document
67 EOSE completeness hint
77 Negentropy syncing (NEG-OPEN, NEG-MSG, NEG-CLOSE)

These depend on what your relay implements:

NIP requires
42 Auther — authentication of clients to relays
17, 59 Auther — gift-wrapped events are only served to the pubkey they are addressed to
45 a storage implementing EventCounterCOUNT

The default NIP-11 document reports exactly this set. A relay implementing Informationer replaces the document wholesale and is responsible for its own supported_nips.

Note that the numbers 12, 15, 16, 20 and 33 still appear in that document for the benefit of older clients; those NIPs were merged into NIP-01 and no longer exist on their own.

Running several instances on one storage

Live subscriptions are tracked in memory, so out of the box an event published to one instance is only pushed to the clients of that instance. To run several instances (behind a load balancer, say) against one shared storage, implement Notifier on your relay or on your storage:

type Notifier interface {
	Notify(context.Context, *nostr.Event) error
	Notifications(context.Context) (<-chan *nostr.Event, error)
}

Notify is called for every accepted event; Notifications must deliver the events accepted by every instance, this one included. With a Notifier present, events reach local subscribers only through Notifications, so there is a single delivery path and no duplicates.

Notifier is eventstore.Notifier, and the postgresql storage implements it with LISTEN/NOTIFY, so a relay on PostgreSQL gets this for free. For any other storage the transport is up to you — Redis pub/sub, NATS, anything that carries events from Notify on one instance to Notifications on all of them; see multi-instance for SQLite kept in sync over Redis.

About

A Nostr relay server framework.

Topics

Resources

Stars

344 stars

Watchers

9 watching

Forks

Used by

Contributors

Languages