app

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	AppData:    defaultApplicationDirectory,
	ConfigPath: defaultConfigPath,
	LogConfig:  LogConfig{DebugLevel: defaultLogLevel},
	RPCConfig: RPCConfig{
		CertHosts: []string{defaultTestnetHost, defaultSimnetHost, defaultMainnetHost},
	},
}
View Source
var (

	// Version is the application version per the semantic versioning 2.0.0 spec
	// (https://semver.org/).
	//
	// It is defined as a variable so it can be overridden during the build
	// process with:
	// '-ldflags "-X main.Version=fullsemver"'
	// if needed.
	//
	// It MUST be a full semantic version per the semantic versioning spec or
	// the package will panic at runtime.  Of particular note is the pre-release
	// and build metadata portions MUST only contain characters from
	// semanticAlphabet.
	// NOTE: The Version string is overridden on init.
	Version = "1.0.2+release.local"
)

Functions

func DefaultHostByNetwork

func DefaultHostByNetwork(network dex.Network) string

DefaultHostByNetwork accepts configured network and returns the network specific default host

func FilePathToURL

func FilePathToURL(name string) (string, error)

func InitLogging

func InitLogging(logFilename, lvl string, stdout bool, utc bool) (lm *dex.LoggerMaker, closeFn func())

initLogging initializes the logging rotater to write logs to logFile and create roll files in the same directory. initLogging must be called before the package-global log rotator variables are used.

func ParseCLIConfig

func ParseCLIConfig(cfg any) error

ParseCLIConfig parses the command-line arguments into the provided struct with go-flags tags. If the --help flag has been passed, the struct is described back to the terminal and the program exits using os.Exit.

func ParseFileConfig

func ParseFileConfig(path string, cfg any) error

ParseFileConfig parses the INI file into the provided struct with go-flags tags. The CLI args are then parsed, and take precedence over the file values.

func ResolveCLIConfigPaths

func ResolveCLIConfigPaths(cfg *Config) (appData, configPath string)

ResolveCLIConfigPaths resolves the app data directory path and the configuration file path from the CLI config, (presumably parsed with ParseCLIConfig).

func ResolveConfig

func ResolveConfig(appData string, cfg *Config) error

ResolveConfig sets derivative fields of the Config struct using the specified app data directory (presumably returned from ResolveCLIConfigPaths). Some unset values are given defaults.

Types

type Config

type Config struct {
	CoreConfig
	RPCConfig
	WebConfig
	LogConfig
	MMConfig
	// AppData and ConfigPath should be parsed from the command-line,
	// as it makes no sense to set these in the config file itself. If no values
	// are assigned, defaults will be used.
	AppData    string `long:"appdata" description:"Path to application directory."`
	ConfigPath string `long:"config" description:"Path to an INI configuration file."`
	// Testnet and Simnet are used to set the derivative CoreConfig.Net
	// dex.Network field.
	Testnet    bool   `long:"testnet" description:"use testnet"`
	Simnet     bool   `long:"simnet" description:"use simnet"`
	RPCOn      bool   `long:"rpc" description:"turn on the rpc server"`
	NoWeb      bool   `long:"noweb" description:"disable the web server."`
	CPUProfile string `long:"cpuprofile" description:"File for CPU profiling."`
	ShowVer    bool   `short:"V" long:"version" description:"Display version information and exit"`
	Language   string `long:"lang" description:"BCP 47 tag for preferred language, e.g. en-GB, fr, zh-CN"`
}

Config is the common application configuration definition. This composite struct captures the configuration needed for core and both web and rpc servers, as well as some application-level directives.

func (*Config) Core

func (cfg *Config) Core(log dex.Logger) *core.Config

Core creates a core.Core configuration. This is a Config method instead of a CoreConfig method because Language is an app-level setting used by both core and rpcserver.

func (*Config) Web

func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc bool) *webserver.Config

Web creates a configuration for the webserver. This is a Config method instead of a WebConfig method because Language is an app-level setting used by both core and rpcserver.

type CoreConfig

type CoreConfig struct {
	DBPath       string `long:"db" description:"Database filepath. Database will be created if it does not exist."`
	Onion        string `long:"onion" description:"Proxy for .onion addresses, if torproxy not set (eg. 127.0.0.1:9050)."`
	TorProxy     string `long:"torproxy" description:"Connect via TOR (eg. 127.0.0.1:9050)."`
	TorIsolation bool   `long:"torisolation" description:"Enable TOR circuit isolation."`
	// Net is a derivative field set by ResolveConfig.
	Net dex.Network

	TheOneHost string `long:"onehost" description:"Only connect with this server."`

	NoAutoWalletLock   bool `` /* 172-byte string literal not displayed */
	NoAutoDBBackup     bool `long:"no-db-backup" description:"Disable creation of a database backup on shutdown."`
	UnlockCoinsOnLogin bool `` /* 136-byte string literal not displayed */

	ExtensionModeFile string `long:"extension-mode-file" description:"path to a file that specifies options for running core as an extension."`

	PruneArchive uint64 `` /* 128-byte string literal not displayed */
}

CoreConfig encapsulates the settings specific to core.Core.

type LogConfig

type LogConfig struct {
	LogPath    string `long:"logpath" description:"A file to save app logs"`
	DebugLevel string `long:"log" description:"Logging level {trace, debug, info, warn, error, critical}"`
	LocalLogs  bool   `long:"loglocal" description:"Use local time zone time stamps in log entries."`
}

LogConfig encapsulates the logging-related settings.

type MMConfig

type MMConfig struct {
	BotConfigPath  string `long:"botConfigPath"`
	EventLogDBPath string `long:"eventLogDBPath"`
}

MMConfig encapsulates the settings specific to market making.

type RPCConfig

type RPCConfig struct {
	RPCAddr string `long:"rpcaddr" description:"RPC server listen address"`
	RPCUser string `long:"rpcuser" description:"RPC server user name"`
	RPCPass string `long:"rpcpass" description:"RPC server password"`
	RPCCert string `long:"rpccert" description:"RPC server certificate file location"`
	RPCKey  string `long:"rpckey" description:"RPC server key file location"`
	// CertHosts is a list of hosts given to certgen.NewTLSCertPair for the
	// "Subject Alternate Name" values of the generated TLS certificate. It is
	// set automatically, not via the config file or cli args.
	CertHosts []string
}

RPCConfig encapsulates the configuration needed for the RPC server.

func (*RPCConfig) RPC

func (cfg *RPCConfig) RPC(c *core.Core, marketMaker *mm.MarketMaker, log dex.Logger) *rpcserver.Config

RPC creates a rpc server configuration.

type WebConfig

type WebConfig struct {
	WebAddr     string `long:"webaddr" description:"HTTP server address"`
	WebTLS      bool   `` /* 239-byte string literal not displayed */
	SiteDir     string `` /* 127-byte string literal not displayed */
	NoEmbedSite bool   `` /* 168-byte string literal not displayed */
	HTTPProfile bool   `long:"httpprof" description:"Start HTTP profiler on /pprof."`
	// Deprecated
	Experimental bool `long:"experimental" description:"DEPRECATED: Enable experimental features"`
}

WebConfig encapsulates the configuration needed for the web server.

Jump to

Keyboard shortcuts

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