Documentation
¶
Overview ¶
Package app implements the orly nostr relay.
Index ¶
- func MonitorResources(c context.T)
- type List
- type Relay
- func (r *Relay) AcceptEvent(c context.T, evt *event.E, hr *http.Request, origin string, ...) (accept bool, notice string, afterSave func())
- func (r *Relay) AcceptFilter(c context.T, hr *http.Request, f *filter.S, authedPubkey []byte) (allowed *filter.S, ok bool, modified bool)
- func (r *Relay) AcceptReq(c context.T, hr *http.Request, id []byte, ff *filters.T, authedPubkey []byte) (allowed *filters.T, ok bool, modified bool)
- func (r *Relay) Init() (err error)
- func (r *Relay) Name() string
- func (r *Relay) Storage() store.I
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MonitorResources ¶
MonitorResources periodically logs resource usage metrics such as the number of active goroutines and CGO calls at 15-minute intervals, and exits when the provided context signals cancellation.
Parameters ¶
- c: Context used to control the lifecycle of the resource monitoring process.
Expected behaviour ¶
The function runs indefinitely, logging metrics every 15 minutes until the context is cancelled. Upon cancellation, it logs a shutdown message and exits gracefully without returning any values.
Types ¶
type List ¶
type List map[string]struct{}
List represents a set-like structure using a map with empty struct values.
type Relay ¶
Relay is a struct that represents a relay for Nostr events. It contains a configuration and a persistence layer for storing the events. The Relay type implements various methods to handle event acceptance, filtering, and storage.
func (*Relay) AcceptEvent ¶
func (r *Relay) AcceptEvent( c context.T, evt *event.E, hr *http.Request, origin string, authedPubkey []byte, ) (accept bool, notice string, afterSave func())
AcceptEvent checks an event and determines whether the event should be accepted and if the client has the authority to submit it.
Parameters ¶
c - a context.T for signalling if the task has been canceled.
evt - an *event.E that is being evaluated.
hr - an *http.Request containing the information about the current connection.
origin - the address of the client.
authedPubkey - the public key, if authed, of the client for this connection.
Return Values ¶
accept - returns true if the event is accepted.
notice - if it is not accepted, a message in the form of `machine-readable-prefix: reason for error/blocked/rate-limited/etc`
afterSave - a closure to run after the event has been stored.
Expected behaviour ¶
This function checks whether the client has permission to store the event, and if they don't, returns false and some kind of error message. If they do, the event is forwarded to the database to be stored and indexed.
func (*Relay) AcceptFilter ¶
func (r *Relay) AcceptFilter( c context.T, hr *http.Request, f *filter.S, authedPubkey []byte, ) (allowed *filter.S, ok bool, modified bool)
AcceptFilter checks if a filter is allowed based on authentication status and relay policies
Parameters ¶
c: Context for task cancellation.
hr: HTTP request containing connection information.
f: Filter to evaluate for acceptance.
authedPubkey: Public key of authenticated client, if applicable.
Return values ¶
allowed: The filter if permitted; may be modified during processing.
ok: Boolean indicating whether the filter is accepted.
modified: Boolean indicating whether the filter was altered during evaluation.
Expected behaviour ¶
The method evaluates whether the provided filter should be allowed based on authentication status and relay-specific rules. If permitted, returns the filter (possibly modified) and true for ok; otherwise returns nil or false for ok accordingly.
func (*Relay) AcceptReq ¶
func (r *Relay) AcceptReq( c context.T, hr *http.Request, id []byte, ff *filters.T, authedPubkey []byte, ) (allowed *filters.T, ok bool, modified bool)
AcceptReq evaluates whether the provided filters are allowed based on authentication status and relay policies for an incoming HTTP request.
Parameters ¶
c: Context for task cancellation.
hr: HTTP request containing connection information.
id: Identifier associated with the request.
ff: Filters to evaluate for acceptance.
authedPubkey: Public key of authenticated client, if applicable.
Return Values ¶
allowed: The filters if permitted; may be modified during processing.
ok: Boolean indicating whether the filters are accepted.
modified: Boolean indicating whether the filters were altered during evaluation.
Expected Behaviour: ¶
The method evaluates whether the provided filters should be allowed based on authentication status and relay-specific rules. If permitted, returns the filters (possibly modified) and true for ok; otherwise returns nil or false for ok accordingly.
func (*Relay) Init ¶
Init initializes and sets up the relay for Nostr events.
#Return Values
- err: an error if any issues occurred during initialization.
#Expected behaviour
This function is responsible for setting up the relay, configuring it, and initializing the necessary components to handle Nostr events.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package config provides a go-simpler.org/env configuration table and helpers for working with the list of key/value lists stored in .env files.
|
Package config provides a go-simpler.org/env configuration table and helpers for working with the list of key/value lists stored in .env files. |
|
options
Package options provides some option configurations for the relay.
|
Package options provides some option configurations for the relay. |