app

package
v1.2.22 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv added in v1.0.10

func GetEnv() (requested bool)

func HelpRequested added in v1.0.5

func HelpRequested() (help bool)

HelpRequested returns true if any of the common types of help invocation are found as the first command line parameter/flag.

func MonitorResources

func MonitorResources(c context.T)

func NewConfig added in v1.0.5

func NewConfig() (cfg *Config, err E)

func PrintEnv added in v1.0.10

func PrintEnv(cfg *Config, printer io.Writer)

func PrintHelp added in v1.0.5

func PrintHelp(cfg *Config, printer io.Writer)

PrintHelp outputs a help text listing the configuration options and default values to a provided io.Writer (usually os.Stderr or os.Stdout).

Types

type B added in v1.0.5

type B = []byte

type Config added in v1.0.5

type Config struct {
	AppName      S    `env:"APP_NAME" default:"realy"`
	Profile      S    `env:"PROFILE" usage:"root path for all other path configurations (based on APP_NAME and OS specific location)"`
	Listen       S    `env:"LISTEN" default:"0.0.0.0" usage:"network listen address"`
	Port         N    `env:"PORT" default:"3334" usage:"port to listen on"`
	AdminUser    S    `env:"ADMIN_USER" default:"admin" usage:"admin user"`
	AdminPass    S    `env:"ADMIN_PASS" usage:"admin password"`
	LogLevel     S    `env:"LOG_LEVEL" default:"info" usage:"debug level: fatal error warn info debug trace"`
	DbLogLevel   S    `env:"DB_LOG_LEVEL" default:"info" usage:"debug level: fatal error warn info debug trace"`
	AuthRequired bool `env:"AUTH_REQUIRED" default:"false" usage:"requires auth for all access"`
	Owners       []S  `` /* 239-byte string literal not displayed */
	DBSizeLimit  int  `` /* 149-byte string literal not displayed */
	DBLowWater   int  `env:"DB_LOW_WATER" default:"60" usage:"the percentage of DBSizeLimit a GC run will reduce the used storage down to"`
	DBHighWater  int  `env:"DB_HIGH_WATER" default:"80" usage:"the trigger point at which a GC run should start if exceeded"`
	GCFrequency  int  `env:"GC_FREQUENCY" default:"3600" usage:"the frequency of checks of the current utilisation in minutes"`
	Pprof        bool `env:"PPROF" default:"false" usage:"enable pprof on 127.0.0.1:6060"`
	MemLimit     int  `env:"MEMLIMIT" default:"250000000" usage:"set memory limit, default is 250Mb"`
	NWC          S    `env:"NWC" usage:"NWC connection string for relay to interact with an NWC enabled wallet"`
}

type Ctx added in v1.0.5

type Ctx = context.T

type E added in v1.0.5

type E = error

type N added in v1.0.5

type N = int

type Relay

type Relay struct {
	sync.Mutex
	*Config
	Store store.I
	// Owners' pubkeys
	Owners          []B
	Followed, Muted map[S]struct{}
	// OwnersFollowLists are the event IDs of owners follow lists, which must not be deleted, only
	// replaced.
	OwnersFollowLists []B
	// OwnersMuteLists are the event IDs of owners mute lists, which must not be deleted, only
	// replaced.
	OwnersMuteLists []B
}

func (*Relay) AcceptEvent

func (r *Relay) AcceptEvent(c context.T, evt *event.T, hr *http.Request, origin S,
	authedPubkey B) (accept bool, notice S)

func (*Relay) AcceptReq

func (r *Relay) AcceptReq(c Ctx, hr *http.Request, idB, ff *filters.T,
	authedPubkey B) (allowed *filters.T, ok bool)

func (*Relay) AuthEnabled

func (r *Relay) AuthEnabled() bool

func (*Relay) CheckOwnerLists

func (r *Relay) CheckOwnerLists(c context.T)

CheckOwnerLists regenerates the owner follow and mute lists if they are empty.

It also adds the followed npubs of the follows.

func (*Relay) Init

func (r *Relay) Init() (err E)

func (*Relay) Name

func (r *Relay) Name() S

func (*Relay) ServiceUrl

func (r *Relay) ServiceUrl(req *http.Request) (s S)

ServiceUrl returns the address of the relay to send back in auth responses. If auth is disabled this returns an empty string.

func (*Relay) Storage

func (r *Relay) Storage(c context.T) store.I

type S added in v1.0.5

type S = string

Jump to

Keyboard shortcuts

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