relay

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvancedDeleter

type AdvancedDeleter interface {
	BeforeDelete(ctx Ctx, id, pubkey B)
	AfterDelete(id, pubkey B)
}

AdvancedDeleter methods are called before and after [Storage.DeleteEvent].

type AdvancedSaver

type AdvancedSaver interface {
	BeforeSave(Ctx, *event.T)
	AfterSave(*event.T)
}

AdvancedSaver methods are called before and after [Storage.SaveEvent].

type Authenticator

type Authenticator interface {
	AuthEnabled() bool
	ServiceUrl(r *http.Request) S
}

Authenticator is the interface for implementing NIP-42. ServiceURL() returns the URL used to verify the "AUTH" event from clients.

type B

type B = []byte

type Ctx

type Ctx = context.T

type E

type E = error

type EventCounter

type EventCounter interface {
	CountEvents(c Ctx, f *filter.T) (count N, err E)
}

type I added in v1.0.5

type I interface {
	// Name is used as the "name" field in NIP-11 and as a prefix in default Server logging.
	// For other NIP-11 fields, see [Informationer].
	Name() S
	// Init is called at the very beginning by [Server.Start], allowing a realy
	// to initialize its internal resources.
	// Also see [eventstore.I.Init].
	Init() E
	// AcceptEvent is called for every nostr event received by the server.
	// If the returned value is true, the event is passed on to [Storage.SaveEvent].
	// Otherwise, the server responds with a negative and "blocked" message as described
	// in NIP-20.
	AcceptEvent(c Ctx, ev *event.T, hr *http.Request, authedPubkey B) bool
	// Storage returns the realy storage implementation.
	Storage(Ctx) store.I
}

I is the main interface for implementing a nostr

type Informationer

type Informationer interface {
	GetNIP11InformationDocument() *relayinfo.T
}

Informationer is called to compose NIP-11 response to an HTTP request with application/nostr+json mime type. See also [I.Name].

type Injector

type Injector interface {
	InjectEvents() event.C
}

type Logger

type Logger interface {
	Infof(format S, v ...any)
	Warningf(format S, v ...any)
	Errorf(format S, v ...any)
}

Logger is what [Server] uses to log messages.

type N

type N = int

type ReqAcceptor

type ReqAcceptor interface {
	// AcceptReq is called for every nostr request filters received by the
	// server. If the returned value is true, the filtres is passed on to
	// [Storage.QueryEvent].
	AcceptReq(ctx Ctx, hr *http.Request, id B, ff *filters.T, authedPubkey B) bool
}

ReqAcceptor is the main interface for implementing a nostr

type S

type S = string

type ShutdownAware

type ShutdownAware interface {
	OnShutdown(Ctx)
}

ShutdownAware is called during the server shutdown. See [Server.Shutdown] for details.

type WebSocketHandler added in v1.0.5

type WebSocketHandler interface {
	HandleUnknownType(ws *web.Socket, t S, request B)
}

WebSocketHandler is passed nostr message types unrecognized by the server. The server handles "EVENT", "REQ" and "CLOSE" messages, as described in NIP-01.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL