config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config provides the shadowchat daemon configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets

type Assets struct {
	// DisableInternal disables the use of the assets bundled in the
	// shadowchat binary and instead looks under `data_dir/assets`.
	DisableInternal bool `yaml:"disable_internal"`

	// AssetDir is the directory containing the non-bundled (customized)
	// assets.
	AssetDir string `yaml:"asset_dir"`

	// DefaultLocale is the default locale to use for web assets.
	DefaultLocale string `yaml:"default_locale"`

	// ForceLocale forces a certain locale for all web assets.
	ForceLocale string `yaml:"force_locale"`
}

Assets is the section definition for the web asset config options.

type Config

type Config struct {
	// BindAddr is the bind address for the shadowchat http server.
	BindAddr string `yaml:"bind_addr"`

	// AdminAddr is the bind address for the AF_UNIX admin socket.
	AdminAddr string `yaml:"admin_addr"`

	// LogLevel is the log level.
	LogLevel slog.Level `yaml:"log_level"`

	// EnableCaptcha enables captcha rate-limiting.
	EnableCaptcha bool `yaml:"enable_captcha"`

	// DB is the persistent store related config options.
	DB DB `yaml:"db"`

	// Assets is the web asset related config options.
	Assets Assets `yaml:"assets"`

	// Wallet is the XMR wallet related config options.
	Wallet xmr.Config `yaml:"wallet"`

	// Superchat is the superchat related config options.
	Superchat Superchat `yaml:"superchat"`

	// Display is the display widget related config options.
	Display Display `yaml:"display"`
}

Config is a shadowchat config.

func Load

func Load(fn string, defaultConfig *Config, checkPerms bool) (*Config, error)

Load loads a config file.

func LoadRaw

func LoadRaw(b []byte) (*Config, error)

LoadRaw parses a raw config.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks if a Config appears to be valid.

type DB

type DB struct {
	// Path is the path to the database.
	Path string `yaml:"path"`

	// MaxCount is the maximum superchats to return per query.
	// This will override `display.view.max_count` if it is smaller.
	//
	// This also sets the size of the response cache.
	MaxCount uint `yaml:"max_count"`

	// MaxReceiptCount is the maximum number of completed superchat
	// statuses to store in-memory (0 is "unlimited").
	MaxReceiptCount *uint `yaml:"max_receipt_count"`

	// MaxPendingCount is the maximum number of pending superchats
	// to store in-memory (0 is "unlimited").
	MaxPendingCount *uint `yaml:"max_pending_count"`

	// DisablePending disables persisting pending superchats to
	// the database, in favor of only storing them in-memory.
	DisablePending bool `yaml:"disable_pending"`
}

DB is the section definition for the persistent store config options.

type Display

type Display struct {
	// AuthKey is the view auth key.
	// Eg:
	// - https://shadowchat.example.com/alert?auth=adminadmin
	// - https://shadowchat.example.com/view?auth=adminadmin
	AuthKey string `yaml:"auth_key"`

	// OBS is the OBS widget config options.
	OBS OBS `yaml:"obs"`

	// View is the View widget config options.
	View View `yaml:"view"`
}

Display is the section definition for the OBS and View widget config options.

type OBS

type OBS struct {
	// Disable disables the OBS widget.
	Disable bool `yaml:"disable"`

	// RefreshInterval is the OBS widget refresh interval in seconds.
	RefreshInterval uint `yaml:"refresh_interval"`
}

OBS is the OBS widget config options.

type Superchat

type Superchat struct {
	// DefaultName is the default name to use across all languages,
	// overriding the localized default name(s).
	DefaultName string `yaml:"default_name"`

	// MaxNameChars is the maximum length of a name in characters.
	MaxNameChars uint `yaml:"max_name_chars"`

	// MaxMessageChars is the maximum length of a superchat.
	MaxMessageChars uint `yaml:"max_message_chars"`

	// MinimumDonation is the minimum donation amount in XMR.
	MinimumDonation *xmr.Quantity `yaml:"minimum_donation,omitempty"`

	// ShowAmount sets if the amount donated will be shown by default.
	ShowAmount bool `yaml:"show_amount"`

	// supercahat form.
	DisplayLogo bool `yaml:"display_logo"`
}

Superchat is the section definition for superchat config options.

type View

type View struct {
	// Disable disables the View widget.
	Disable bool `yaml:"disable"`

	// RefreshInterval is the view widget refresh interval in seconds.
	RefreshInterval *uint `yaml:"refresh_interval,omitempty"`

	// MaxCount is the maximum number of superchats to display.
	MaxCount uint `yaml:"max_count"`
}

View is the View widget config options.

Jump to

Keyboard shortcuts

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