utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthRequiredProvider func() bool

AuthRequiredProvider is set by higher-level packages to report the current auth requirement without introducing an import cycle into config.

Functions

func DetermineEventCategory

func DetermineEventCategory(kind int) string

func EnsureFileExists

func EnsureFileExists(filePath string, content []byte)

EnsureFileExists creates a file from embedded content if it doesn't exist

func FetchPubkeysFromDomains

func FetchPubkeysFromDomains(domains []string) ([]string, error)

FetchPubkeysFromDomains fetches nostr.json pubkeys from multiple domains This function is called by the pubkey cache system and doesn't maintain its own cache

func GenerateChallenge added in v0.5.0

func GenerateChallenge(length int) string

GenerateChallenge creates a random hex string for NIP-42 authentication

func GetClientIP

func GetClientIP(r *http.Request) string

func LoadRelayMetadata

func LoadRelayMetadata(filename string) error

func LoadRelayMetadataJSON

func LoadRelayMetadataJSON() error

func RelayInfoHandler

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

func SendToBackupRelay

func SendToBackupRelay(backupURL string, evt nostr.Event) error

func SetVersion added in v0.5.0

func SetVersion(v string)

SetVersion records the build-time version string. Called from server.SetVersionInfo during startup; kept in this leaf package to avoid a server -> server/utils import cycle.

func ToInt

func ToInt(i interface{}) *int

func ToInt64

func ToInt64(i interface{}) *int64

func ToIntArray

func ToIntArray(i interface{}) []int

func ToStringArray

func ToStringArray(i interface{}) []string

func ToTagsMap

func ToTagsMap(i interface{}) map[string][]string

func ToTime

func ToTime(data interface{}) *time.Time

Types

type NostrJSON

type NostrJSON struct {
	Names map[string]string `json:"names"`
}

NostrJSON represents the structure of .well-known/nostr.json

type RelayMetadata

type RelayMetadata struct {
	Name           string `json:"name"`
	Description    string `json:"description"`
	Banner         string `json:"banner"`
	Icon           string `json:"icon"`
	Pubkey         string `json:"pubkey"`
	Contact        string `json:"contact"`
	SupportedNIPs  []int  `json:"supported_nips"`
	Software       string `json:"software"`
	Version        string `json:"version"`
	PrivacyPolicy  string `json:"privacy_policy"`
	TermsOfService string `json:"terms_of_service"`
	Limitation     struct {
		MaxMessageLength    int    `json:"max_message_length"`
		MaxContentLength    int    `json:"max_content_length"`
		MaxSubscriptions    int    `json:"max_subscriptions"`
		MaxLimit            int    `json:"max_limit"`
		AuthRequired        bool   `json:"auth_required"`
		PaymentRequired     bool   `json:"payment_required"`
		RestrictedWrites    bool   `json:"restricted_writes"`
		CreatedAtLowerLimit *int64 `json:"created_at_lower_limit"`
		CreatedAtUpperLimit *int64 `json:"created_at_upper_limit"`
	} `json:"limitation"`
	RelayCountries []string `json:"relay_countries"`
	LanguageTags   []string `json:"language_tags"`
	Tags           []string `json:"tags"`
	PostingPolicy  string   `json:"posting_policy"`
}

Directories

Path Synopsis
Package relayurl applies NIP-42-flavored URL normalization for the purpose of comparing a client-supplied AUTH `relay` tag against the relay's configured Auth.RelayURL.
Package relayurl applies NIP-42-flavored URL normalization for the purpose of comparing a client-supplied AUTH `relay` tag against the relay's configured Auth.RelayURL.

Jump to

Keyboard shortcuts

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