app

package
v0.44.4 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Unlicense Imports: 97 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWriteWait    = 10 * time.Second
	DefaultPongWait     = 60 * time.Second
	DefaultPingWait     = DefaultPongWait / 2
	DefaultWriteTimeout = 3 * time.Second
	// DefaultMaxMessageSize is the maximum message size for WebSocket connections
	// Increased from 512KB to 10MB to support large kind 3 follow lists (10k+ follows)
	// and other large events without truncation
	DefaultMaxMessageSize = 10 * 1024 * 1024 // 10MB
	// ClientMessageSizeLimit is the maximum message size that clients can handle
	// This is set to 100MB to allow large messages
	ClientMessageSizeLimit = 100 * 1024 * 1024 // 100MB
)
View Source
const Type = "socketapi"

Variables

View Source
var Ok = OKs{
	Ok: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), true, []byte{},
		).Write(l)
	},
	AuthRequired: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.AuthRequired.F(format, params...),
		).Write(l)
	},
	PoW: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.PoW.F(format, params...),
		).Write(l)
	},
	Duplicate: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Duplicate.F(format, params...),
		).Write(l)
	},
	Blocked: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Blocked.F(format, params...),
		).Write(l)
	},
	RateLimited: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.RateLimited.F(format, params...),
		).Write(l)
	},
	Invalid: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Invalid.F(format, params...),
		).Write(l)
	},
	Error: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Error.F(format, params...),
		).Write(l)
	},
	Unsupported: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Unsupported.F(format, params...),
		).Write(l)
	},
	Restricted: func(
		l *Listener, env eventenvelope.I, format string,
		params ...any,
	) (err error) {
		return okenvelope.NewFrom(
			env.Id(), false, reason.Restricted.F(format, params...),
		).Write(l)
	},
}

Ok provides a collection of handler functions for managing different types of operational outcomes, each corresponding to specific error or status conditions such as authentication requirements, rate limiting, and invalid inputs.

Functions

func GetReactAppFS added in v0.6.0

func GetReactAppFS() http.FileSystem

GetReactAppFS returns a http.FileSystem from the embedded React app

func GetRemoteFromReq

func GetRemoteFromReq(r *http.Request) (rr string)

GetRemoteFromReq retrieves the originating IP address of the client from an HTTP request, considering standard and non-standard proxy headers.

Parameters

  • r: The HTTP request object containing details of the client and routing information.

Return Values

  • rr: A string value representing the IP address of the originating remote client.

Expected behaviour

The function first checks for the standardized "Forwarded" header (RFC 7239) to identify the original client IP. If that isn't available, it falls back to the "X-Forwarded-For" header. If both headers are absent, it defaults to using the request's RemoteAddr.

For the "Forwarded" header, it extracts the client IP from the "for" parameter. For the "X-Forwarded-For" header, if it contains one IP, it returns that. If it contains two IPs, it returns the second.

func IsPolicyConfigEvent added in v0.31.1

func IsPolicyConfigEvent(ev *event.E) bool

IsPolicyConfigEvent returns true if the event is a policy configuration event (kind 12345)

func LogProxyInfo added in v0.9.3

func LogProxyInfo(r *http.Request, prefix string)

LogProxyInfo logs comprehensive proxy information for debugging

func Run

func Run(
	ctx context.Context, cfg *config.C, db database.Database, limiter *ratelimit.Limiter,
) (quit chan struct{})

func ServeEmbeddedWeb added in v0.11.0

func ServeEmbeddedWeb(w http.ResponseWriter, r *http.Request)

ServeEmbeddedWeb serves the embedded web application

func TLSConfig added in v0.19.0

func TLSConfig(m *autocert.Manager, certs ...string) (tc *tls.Config)

TLSConfig returns a TLS configuration that works with LetsEncrypt automatic SSL cert issuer as well as any provided certificate files from providers.

The certs are provided in the form of paths where .pem and .key files exist

func ValidateTLSConfig added in v0.19.0

func ValidateTLSConfig(domains []string, certs []string) (err error)

ValidateTLSConfig checks if the TLS configuration is valid

Types

type AccessLogResponse added in v0.40.0

type AccessLogResponse struct {
	NostrPubkey string `json:"nostr_pubkey"`
	WGPublicKey string `json:"wg_public_key"`
	Sequence    uint32 `json:"sequence"`
	ClientIP    string `json:"client_ip"`
	Timestamp   int64  `json:"timestamp"`
	RemoteAddr  string `json:"remote_addr"`
}

AccessLogResponse is the JSON response for access logs.

type BunkerInfoResponse added in v0.41.0

type BunkerInfoResponse struct {
	RelayURL     string `json:"relay_url"`     // WebSocket URL for NIP-46 connections
	RelayNpub    string `json:"relay_npub"`    // Relay's npub
	RelayPubkey  string `json:"relay_pubkey"`  // Relay's hex pubkey
	ACLMode      string `json:"acl_mode"`      // Current ACL mode
	CashuEnabled bool   `json:"cashu_enabled"` // Whether CAT is required
	Available    bool   `json:"available"`     // Whether bunker is available
}

BunkerInfoResponse is returned by the /api/bunker/info endpoint.

type BunkerURLResponse added in v0.40.0

type BunkerURLResponse struct {
	URL         string `json:"url"`
	RelayNpub   string `json:"relay_npub"`
	RelayPubkey string `json:"relay_pubkey"`
	InternalIP  string `json:"internal_ip"`
}

BunkerURLResponse is returned by the /api/bunker/url endpoint.

type CashuMintRequest added in v0.41.0

type CashuMintRequest struct {
	BlindedMessage string  `json:"blinded_message"`       // Hex-encoded blinded point B_
	Scope          string  `json:"scope"`                 // Token scope (e.g., "relay", "nip46")
	Kinds          []int   `json:"kinds,omitempty"`       // Permitted event kinds
	KindRanges     [][]int `json:"kind_ranges,omitempty"` // Permitted kind ranges
}

CashuMintRequest is the request body for token issuance.

type CashuMintResponse added in v0.41.0

type CashuMintResponse struct {
	BlindedSignature string `json:"blinded_signature"` // Hex-encoded blinded signature C_
	KeysetID         string `json:"keyset_id"`         // Keyset ID used
	Expiry           int64  `json:"expiry"`            // Token expiration timestamp
	MintPubkey       string `json:"mint_pubkey"`       // Hex-encoded mint public key
}

CashuMintResponse is the response body for token issuance.

type Listener

type Listener struct {
	*Server
	// contains filtered or unexported fields
}

func (*Listener) Ctx added in v0.4.0

func (l *Listener) Ctx() context.Context

Ctx returns the listener's context, but creates a new context for each operation to prevent cancellation from affecting subsequent operations

func (*Listener) DroppedMessages added in v0.24.1

func (l *Listener) DroppedMessages() int

DroppedMessages returns the total number of messages that were dropped because the message processing queue was full.

func (*Listener) GetSerialsFromFilter

func (l *Listener) GetSerialsFromFilter(f *filter.F) (
	sers types.Uint40s, err error,
)

func (*Listener) HandleAuth

func (l *Listener) HandleAuth(b []byte) (err error)

func (*Listener) HandleClose

func (l *Listener) HandleClose(req []byte) (err error)

HandleClose processes a CLOSE envelope by unmarshalling the request, validates the presence of an <id> field, and signals cancellation for the associated listener through the server's publisher mechanism.

func (*Listener) HandleCount added in v0.10.0

func (l *Listener) HandleCount(msg []byte) (err error)

HandleCount processes a COUNT envelope by parsing the request, verifying permissions, invoking the database CountEvents for each provided filter, and responding with a COUNT response containing the aggregate count.

func (*Listener) HandleDelete

func (l *Listener) HandleDelete(env *eventenvelope.Submission) (err error)

func (*Listener) HandleEvent

func (l *Listener) HandleEvent(msg []byte) (err error)

func (*Listener) HandleMessage

func (l *Listener) HandleMessage(msg []byte, remote string)

func (*Listener) HandleNIP43JoinRequest added in v0.27.0

func (l *Listener) HandleNIP43JoinRequest(ev *event.E) error

HandleNIP43JoinRequest processes a kind 28934 join request

func (*Listener) HandleNIP43LeaveRequest added in v0.27.0

func (l *Listener) HandleNIP43LeaveRequest(ev *event.E) error

HandleNIP43LeaveRequest processes a kind 28936 leave request

func (*Listener) HandlePolicyAdminFollowListUpdate added in v0.31.1

func (l *Listener) HandlePolicyAdminFollowListUpdate(ev *event.E) error

HandlePolicyAdminFollowListUpdate processes kind 3 follow list events from policy admins. When a policy admin updates their follow list, we immediately refresh the policy follows cache.

Process flow: 1. Check if sender is a policy admin 2. If yes, extract p-tags from the follow list 3. Pause message processing 4. Aggregate all policy admin follows and update cache 5. Resume message processing

func (*Listener) HandlePolicyConfigUpdate added in v0.31.1

func (l *Listener) HandlePolicyConfigUpdate(ev *event.E) error

HandlePolicyConfigUpdate processes kind 12345 policy configuration events. Owners and policy admins can update policy configuration, with different permissions:

OWNERS can:

  • Modify all fields including owners and policy_admins
  • But owners list must remain non-empty (to prevent lockout)

POLICY ADMINS can:

  • Extend rules (add to allow lists, add new kinds, add blacklists)
  • CANNOT modify owners or policy_admins (protected fields)
  • CANNOT reduce owner-granted permissions

Process flow: 1. Check if sender is owner or policy admin 2. Validate JSON with appropriate rules for the sender type 3. Pause ALL message processing (lock mutex) 4. Reload policy (pause policy engine, update, save, resume) 5. Resume message processing (unlock mutex)

The message processing mutex is already released by the caller (HandleEvent), so we acquire it ourselves for the critical section.

func (*Listener) HandleReq

func (l *Listener) HandleReq(msg []byte) (err error)

func (*Listener) IsPolicyAdminFollowListEvent added in v0.31.1

func (l *Listener) IsPolicyAdminFollowListEvent(ev *event.E) bool

IsPolicyAdminFollowListEvent returns true if this is a follow list event from a policy admin. Used to detect when we need to refresh the policy follows cache.

func (*Listener) QueryAllVersions added in v0.17.4

func (l *Listener) QueryAllVersions(ctx context.Context, f *filter.F) (event.S, error)

QueryAllVersions queries events using the database QueryAllVersions method

func (*Listener) QueryEvents added in v0.17.4

func (l *Listener) QueryEvents(ctx context.Context, f *filter.F) (event.S, error)

QueryEvents queries events using the database QueryEvents method

func (*Listener) QueueMessage added in v0.24.1

func (l *Listener) QueueMessage(data []byte, remote string) bool

QueueMessage queues a message for asynchronous processing. Returns true if the message was queued, false if the queue was full.

func (*Listener) RemainingCapacity added in v0.24.1

func (l *Listener) RemainingCapacity() int

RemainingCapacity returns the number of slots available in the message processing queue.

func (*Listener) Write

func (l *Listener) Write(p []byte) (n int, err error)

func (*Listener) WriteControl added in v0.23.0

func (l *Listener) WriteControl(messageType int, data []byte, deadline time.Time) (err error)

WriteControl sends a control message through the write channel

type LogLevelRequest added in v0.37.3

type LogLevelRequest struct {
	Level string `json:"level"`
}

LogLevelRequest is the request structure for POST /api/logs/level

type LogLevelResponse added in v0.37.3

type LogLevelResponse struct {
	Level string `json:"level"`
}

LogLevelResponse is the response structure for GET /api/logs/level

type LogsResponse added in v0.37.3

type LogsResponse struct {
	Logs    []logbuffer.LogEntry `json:"logs"`
	Total   int                  `json:"total"`
	HasMore bool                 `json:"has_more"`
}

LogsResponse is the response structure for GET /api/logs

type Map

type Map map[*websocket.Conn]map[string]Subscription

Map is a map of filters associated with a collection of ws.Listener connections.

type NIP86Request added in v0.17.0

type NIP86Request struct {
	Method string        `json:"method"`
	Params []interface{} `json:"params"`
}

NIP86Request represents a NIP-86 JSON-RPC request

type NIP86Response added in v0.17.0

type NIP86Response struct {
	Result interface{} `json:"result,omitempty"`
	Error  string      `json:"error,omitempty"`
}

NIP86Response represents a NIP-86 JSON-RPC response

type OK

type OK func(
	l *Listener, env eventenvelope.I, format string, params ...any,
) (err error)

OK represents a function that processes events or operations, using provided parameters to generate formatted messages and return errors if any issues occur during processing.

type OKs

type OKs struct {
	Ok           OK
	AuthRequired OK
	PoW          OK
	Duplicate    OK
	Blocked      OK
	RateLimited  OK
	Invalid      OK
	Error        OK
	Unsupported  OK
	Restricted   OK
}

OKs provides a collection of handler functions for managing different types of operational outcomes, each corresponding to specific error or status conditions such as authentication requirements, rate limiting, and invalid inputs.

type P

type P struct {

	// Mx is the mutex for the Map.
	Mx sync.RWMutex
	// Map is the map of subscribers and subscriptions from the websocket api.
	Map
	// WriteChans maps websocket connections to their write channels
	WriteChans WriteChanMap
	// contains filtered or unexported fields
}

P is a structure that manages subscriptions and associated filters for websocket listeners. It uses a mutex to synchronize access to a map storing subscriber connections and their filter configurations.

func NewPublisher

func NewPublisher(c context.Context) (publisher *P)

func (*P) Deliver

func (p *P) Deliver(ev *event.E)

Deliver processes and distributes an event to all matching subscribers based on their filter configurations.

Parameters

- ev (*event.E): The event to be delivered to subscribed clients.

Expected behaviour

Delivers the event to all subscribers whose filters match the event. It applies authentication checks if required by the server and skips delivery for unauthenticated users when events are privileged.

func (*P) GetWriteChan added in v0.23.0

func (p *P) GetWriteChan(conn *websocket.Conn) (
	chan publish.WriteRequest, bool,
)

GetWriteChan returns the write channel for a websocket connection

func (*P) HasActiveNIP46Signer added in v0.43.0

func (p *P) HasActiveNIP46Signer(signerPubkey []byte) bool

HasActiveNIP46Signer checks if there's an active subscription for kind 24133 where the given pubkey is involved (either as author filter or in #p tag filter). This is used to authenticate clients by proving a signer is connected for that pubkey.

func (*P) Receive

func (p *P) Receive(msg typer.T)

Receive handles incoming messages to manage websocket listener subscriptions and associated filters.

Parameters

- msg (publisher.Message): The incoming message to process; expected to be of type *W to trigger subscription management actions.

Expected behaviour

- Checks if the message is of type *W.

- If Cancel is true, removes a subscriber by ID or the entire listener.

- Otherwise, adds the subscription to the map under a mutex lock.

- Logs actions related to subscription creation or removal.

func (*P) SetWriteChan added in v0.23.0

func (p *P) SetWriteChan(
	conn *websocket.Conn, writeChan chan publish.WriteRequest,
)

SetWriteChan stores the write channel for a websocket connection If writeChan is nil, the entry is removed from the map

func (*P) Type

func (p *P) Type() (typeName string)

type PaymentProcessor added in v0.8.0

type PaymentProcessor struct {
	// contains filtered or unexported fields
}

PaymentProcessor handles NWC payment notifications and updates subscriptions

func NewPaymentProcessor added in v0.8.0

func NewPaymentProcessor(
	ctx context.Context, cfg *config.C, db *database.D,
) (pp *PaymentProcessor, err error)

NewPaymentProcessor creates a new payment processor

func (*PaymentProcessor) CreateWelcomeNote added in v0.8.0

func (pp *PaymentProcessor) CreateWelcomeNote(userPubkey []byte) error

CreateWelcomeNote creates a welcome note for first-time users with private tag for authorization

func (*PaymentProcessor) SetDashboardURL added in v0.8.2

func (pp *PaymentProcessor) SetDashboardURL(url string)

SetDashboardURL sets the dynamic dashboard URL based on HTTP request

func (*PaymentProcessor) Start added in v0.8.0

func (pp *PaymentProcessor) Start() error

Start begins listening for payment notifications

func (*PaymentProcessor) Stop added in v0.8.0

func (pp *PaymentProcessor) Stop()

Stop gracefully stops the payment processor

func (*PaymentProcessor) UpdateRelayProfile added in v0.8.4

func (pp *PaymentProcessor) UpdateRelayProfile() error

UpdateRelayProfile creates or updates the relay's kind 0 profile with subscription information

type RevokedKeyResponse added in v0.40.0

type RevokedKeyResponse struct {
	NostrPubkey  string `json:"nostr_pubkey"`
	WGPublicKey  string `json:"wg_public_key"`
	Sequence     uint32 `json:"sequence"`
	ClientIP     string `json:"client_ip"`
	ServerIP     string `json:"server_ip"`
	CreatedAt    int64  `json:"created_at"`
	RevokedAt    int64  `json:"revoked_at"`
	AccessCount  int    `json:"access_count"`
	LastAccessAt int64  `json:"last_access_at"`
}

RevokedKeyResponse is the JSON response for revoked keys.

type Server

type Server struct {
	Config *config.C
	Ctx    context.Context

	Admins [][]byte
	Owners [][]byte
	DB     database.Database // Changed from embedded *database.D to interface field

	InviteManager *nip43.InviteManager

	// Cashu access token system (NIP-XX)
	CashuIssuer   *issuer.Issuer
	CashuVerifier *verifier.Verifier
	// contains filtered or unexported fields
}

func (*Server) AcquireMessageProcessingLock added in v0.31.0

func (s *Server) AcquireMessageProcessingLock()

AcquireMessageProcessingLock acquires a read lock for normal message processing. This allows concurrent message processing while blocking during policy updates. Call ReleaseMessageProcessingLock when message processing is complete.

func (*Server) CashuKeysetTTL added in v0.41.0

func (s *Server) CashuKeysetTTL() time.Duration

CashuKeysetTTL returns the configured keyset TTL.

func (*Server) CashuTokenTTL added in v0.41.0

func (s *Server) CashuTokenTTL() time.Duration

CashuTokenTTL returns the configured token TTL.

func (*Server) DashboardURL added in v0.8.2

func (s *Server) DashboardURL(req *http.Request) (url string)

func (*Server) HandleNIP43InviteRequest added in v0.27.0

func (s *Server) HandleNIP43InviteRequest(pubkey []byte) (*event.E, error)

HandleNIP43InviteRequest processes a kind 28935 invite request (REQ subscription)

func (*Server) HandleRelayInfo

func (s *Server) HandleRelayInfo(w http.ResponseWriter, r *http.Request)

HandleRelayInfo generates and returns a relay information document in JSON format based on the server's configuration and supported NIPs.

Parameters

  • w: HTTP response writer used to send the generated document.

  • r: HTTP request object containing incoming client request data.

Expected Behaviour

The function constructs a relay information document using either the Informer interface implementation or predefined server configuration. It returns this document as a JSON response to the client.

func (*Server) HandleWebsocket

func (s *Server) HandleWebsocket(w http.ResponseWriter, r *http.Request)

func (*Server) InitEventServices added in v0.36.15

func (s *Server) InitEventServices()

InitEventServices initializes the domain services for event handling. This should be called after the Server is created but before accepting connections.

func (*Server) InitializePolicyFollows added in v0.31.1

func (s *Server) InitializePolicyFollows() error

InitializePolicyFollows loads the follow lists of all policy admins at startup. This should be called after the policy manager is initialized but before the relay starts accepting connections. It's a method on Server so it can be called from main.go during initialization.

func (*Server) PauseMessageProcessing added in v0.31.0

func (s *Server) PauseMessageProcessing()

PauseMessageProcessing acquires an exclusive lock to pause all message processing. This should be called before updating policy configuration or follow lists. Call ResumeMessageProcessing to release the lock after updates are complete.

func (*Server) Pinger

func (s *Server) Pinger(
	ctx context.Context, listener *Listener, ticker *time.Ticker,
)

func (*Server) ReleaseMessageProcessingLock added in v0.31.0

func (s *Server) ReleaseMessageProcessingLock()

ReleaseMessageProcessingLock releases the read lock after message processing.

func (*Server) ResumeMessageProcessing added in v0.31.0

func (s *Server) ResumeMessageProcessing()

ResumeMessageProcessing releases the exclusive lock to resume message processing. This should be called after policy configuration or follow list updates are complete.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) ServiceURL

func (s *Server) ServiceURL(req *http.Request) (url string)

func (*Server) UserInterface added in v0.6.0

func (s *Server) UserInterface()

UserInterface sets up a basic Nostr NDK interface that allows users to log into the relay user interface

func (*Server) WebSocketURL added in v0.11.0

func (s *Server) WebSocketURL(req *http.Request) (url string)

type SprocketManager added in v0.12.0

type SprocketManager struct {
	// contains filtered or unexported fields
}

SprocketManager handles sprocket script execution and management

func NewSprocketManager added in v0.12.0

func NewSprocketManager(ctx context.Context, appName string, enabled bool) *SprocketManager

NewSprocketManager creates a new sprocket manager

func (*SprocketManager) DeleteSprocketVersion added in v0.12.0

func (sm *SprocketManager) DeleteSprocketVersion(filename string) error

DeleteSprocketVersion deletes a specific sprocket version

func (*SprocketManager) GetSprocketStatus added in v0.12.0

func (sm *SprocketManager) GetSprocketStatus() map[string]interface{}

GetSprocketStatus returns the current status of the sprocket

func (*SprocketManager) GetSprocketVersions added in v0.12.0

func (sm *SprocketManager) GetSprocketVersions() ([]map[string]interface{}, error)

GetSprocketVersions returns a list of all sprocket script versions

func (*SprocketManager) IsDisabled added in v0.12.2

func (sm *SprocketManager) IsDisabled() bool

IsDisabled returns whether sprocket is disabled due to failure

func (*SprocketManager) IsEnabled added in v0.12.0

func (sm *SprocketManager) IsEnabled() bool

IsEnabled returns whether sprocket is enabled

func (*SprocketManager) IsRunning added in v0.12.0

func (sm *SprocketManager) IsRunning() bool

IsRunning returns whether sprocket is currently running

func (*SprocketManager) ProcessEvent added in v0.12.0

func (sm *SprocketManager) ProcessEvent(evt *event.E) (*SprocketResponse, error)

ProcessEvent sends an event to the sprocket script and waits for a response

func (*SprocketManager) RestartSprocket added in v0.12.0

func (sm *SprocketManager) RestartSprocket() error

RestartSprocket stops and starts the sprocket script

func (*SprocketManager) Shutdown added in v0.12.0

func (sm *SprocketManager) Shutdown()

Shutdown gracefully shuts down the sprocket manager

func (*SprocketManager) StartSprocket added in v0.12.0

func (sm *SprocketManager) StartSprocket() error

StartSprocket starts the sprocket script

func (*SprocketManager) StopSprocket added in v0.12.0

func (sm *SprocketManager) StopSprocket() error

StopSprocket stops the sprocket script gracefully, with SIGKILL fallback

func (*SprocketManager) UpdateSprocket added in v0.12.0

func (sm *SprocketManager) UpdateSprocket(scriptContent string) error

UpdateSprocket updates the sprocket script and restarts it with zero downtime

type SprocketResponse added in v0.12.0

type SprocketResponse struct {
	ID     string `json:"id"`
	Action string `json:"action"` // accept, reject, or shadowReject
	Msg    string `json:"msg"`    // NIP-20 response message (only used for reject)
}

SprocketResponse represents a response from the sprocket script

type Subscription

type Subscription struct {
	AuthedPubkey []byte
	Receiver     event.C // Channel for delivering events to this subscription
	AuthRequired bool    // Whether ACL requires authentication for privileged events
	*filter.S
	// contains filtered or unexported fields
}

type W

type W struct {
	*websocket.Conn

	// If Cancel is true, this is a close command.
	Cancel bool

	// Id is the subscription Id. If Cancel is true, cancel the named
	// subscription, otherwise, cancel the publisher for the socket.
	Id string

	// The Receiver holds the event channel for receiving notifications or data
	// relevant to this WebSocket connection.
	Receiver event.C

	// Filters holds a collection of filters used to match or process events
	// associated with this WebSocket connection. It is used to determine which
	// notifications or data should be received by the subscriber.
	Filters *filter.S

	// AuthedPubkey is the authenticated pubkey associated with the listener (if any).
	AuthedPubkey []byte

	// AuthRequired indicates whether the ACL in operation requires auth. If
	// this is set to true, the publisher will not publish privileged or other
	// restricted events to non-authed listeners, otherwise, it will.
	AuthRequired bool
	// contains filtered or unexported fields
}

func (*W) Type

func (w *W) Type() (typeName string)

type WGInterface added in v0.40.0

type WGInterface struct {
	Address    string `json:"address"`
	PrivateKey string `json:"private_key"`
}

WGInterface represents the [Interface] section of a WireGuard config.

type WGPeer added in v0.40.0

type WGPeer struct {
	PublicKey  string `json:"public_key"`
	Endpoint   string `json:"endpoint"`
	AllowedIPs string `json:"allowed_ips"`
}

WGPeer represents the [Peer] section of a WireGuard config.

type WireGuardConfigResponse added in v0.40.0

type WireGuardConfigResponse struct {
	ConfigText string      `json:"config_text"`
	Interface  WGInterface `json:"interface"`
	Peer       WGPeer      `json:"peer"`
}

WireGuardConfigResponse is returned by the /api/wireguard/config endpoint.

type WriteChanMap added in v0.23.0

type WriteChanMap map[*websocket.Conn]chan publish.WriteRequest

WriteChanMap maps websocket connections to their write channels

Source Files

  • blossom.go
  • handle-auth.go
  • handle-bunker.go
  • handle-cashu.go
  • handle-close.go
  • handle-count.go
  • handle-delete.go
  • handle-event-types.go
  • handle-event.go
  • handle-logs.go
  • handle-message.go
  • handle-nip43.go
  • handle-nip86.go
  • handle-policy-config.go
  • handle-relayinfo.go
  • handle-req.go
  • handle-websocket.go
  • handle-wireguard.go
  • helpers.go
  • listener.go
  • main.go
  • ok.go
  • payment_processor.go
  • publisher.go
  • server.go
  • sprocket.go
  • tls.go
  • web.go
  • wireguard-helpers.go

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.

Jump to

Keyboard shortcuts

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