config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: ISC Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName is the politeiawww application name that is used to create the
	// application home directory.
	AppName = "politeiawww"

	// DefaultMainnetPort is the default port that the HTTPS server will be
	// listening on when politeiawww is configured to use the DCR mainnet.
	DefaultMainnetPort = "4443"

	// DefaultTestnetPort is the default port that the HTTPS server will be
	// listening on when politeiawww is configured to use the DCR testnet.
	DefaultTestnetPort = "4443"
)

The following defaults are exported so that they can be used by external tools such as sysadmin and dev CLI tools.

View Source
const (

	// Database settings
	LevelDB     = "leveldb"
	CockroachDB = "cockroachdb"
	MySQL       = "mysql"
)
View Source
const (
	// Currently available modes to run politeia, by default piwww, is used.
	PiWWWMode  = "piwww"
	CMSWWWMode = "cmswww"
)

Variables

View Source
var (
	// DefaultHomeDir is the default path for the  politeiawww application home
	// directory.
	DefaultHomeDir = dcrutil.AppDataDir(AppName, false)

	// DefaultDataDir is the default path for the politeiawww application data
	// directory. In practice, the data directory is namespaced by network, so
	// the network name must be appended onto this path at runtime in order to
	// get the true data directory.
	DefaultDataDir = filepath.Join(DefaultHomeDir, defaultDataDirname)

	// DefaultHTTPSCert is the default path for the politeiawww HTTPS
	// certificate.
	DefaultHTTPSCert = filepath.Join(DefaultHomeDir, defaultHTTPSCertFilename)
)

The following defaults are exported so that they can be used by external tools such as sysadmin and dev CLI tools.

View Source
var MainNetParams = ChainParams{
	Params:              chaincfg.MainNetParams(),
	WalletRPCServerPort: "9111",
}

mainNetParams contains parameters specific to the main network (wire.MainNet). NOTE: The RPC port is intentionally different than the reference implementation because dcrd does not handle wallet requests. The separate wallet process listens on the well-known port and forwards requests it does not handle on to dcrd. This approach allows the wallet process to emulate the full reference implementation RPC API.

View Source
var SimNetParams = ChainParams{
	Params:              chaincfg.SimNetParams(),
	WalletRPCServerPort: "19558",
}

simNetParams contains parameters specific to the simulation test network (wire.SimNet).

View Source
var TestNet3Params = ChainParams{
	Params:              chaincfg.TestNet3Params(),
	WalletRPCServerPort: "19111",
}

Functions

func DisableLog added in v1.3.0

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger added in v1.3.0

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type ChainParams added in v1.3.0

type ChainParams struct {
	*chaincfg.Params
	WalletRPCServerPort string
}

ChainParams is used to group parameters for various networks such as the main network and test networks.

type Config

type Config struct {
	// General application settings
	ShowVersion bool   `short:"V" long:"version" description:"Display version information and exit"`
	HomeDir     string `short:"A" long:"appdata" description:"Path to application home directory"`
	ConfigFile  string `short:"C" long:"configfile" description:"Path to configuration file"`
	DataDir     string `short:"b" long:"datadir" description:"Directory to store data"`
	LogDir      string `long:"logdir" description:"Directory to log output."`
	TestNet     bool   `long:"testnet" description:"Use the test network"`
	DebugLevel  string `` /* 275-byte string literal not displayed */

	// HTTP server settings
	Listeners          []string `long:"listen" description:"Add an interface/port to listen for connections (default all interfaces port: 4443)"`
	HTTPSCert          string   `long:"httpscert" description:"File containing the https certificate file"`
	HTTPSKey           string   `long:"httpskey" description:"File containing the https certificate key"`
	CookieKeyFile      string   `long:"cookiekey" description:"File containing the secret cookies key"`
	ReadTimeout        int64    `long:"readtimeout" description:"Maximum duration in seconds that is spent reading the request headers and body"`
	WriteTimeout       int64    `long:"writetimeout" description:"Maximum duration in seconds that a request connection is kept open"`
	ReqBodySizeLimit   int64    `long:"reqbodysizelimit" description:"Maximum number of bytes allowed in a request body submitted by a client"`
	WebsocketReadLimit int64    `long:"websocketreadlimit" description:"Maximum number of bytes allowed for a message read from a websocket client"`
	PluginBatchLimit   uint32   `long:"pluginbatchlimit" description:"Maximum number of plugins command allowed in a batch request."`

	// politeiad RPC settings
	RPCHost         string `long:"rpchost" description:"politeiad host <host>:<port>"`
	RPCCert         string `long:"rpccert" description:"File containing the politeiad https certificate file"`
	RPCIdentityFile string `long:"rpcidentityfile" description:"Path to file containing the politeiad identity"`
	RPCUser         string `long:"rpcuser" description:"RPC username for privileged politeaid commands"`
	RPCPass         string `long:"rpcpass" description:"RPC password for privileged politeiad commands"`
	FetchIdentity   bool   `long:"fetchidentity" description:"Fetch the identity from politeiad"`
	Interactive     string `long:"interactive" description:"Set to i-know-this-is-a-bad-idea to turn off interactive mode during --fetchidentity"`

	// User database settings
	UserDB string `long:"userdb" description:"Database choice for the user database"`
	DBHost string `long:"dbhost" description:"Database ip:port"`
	DBPass string // Provided in env variable "DBPASS"

	// SMTP settings
	MailHost       string `long:"mailhost" description:"Email server address <host>:<port>"`
	MailCert       string `long:"mailcert" description:"Email server certificate file"`
	MailSkipVerify bool   `long:"mailskipverify" description:"Skip email server TLS verification"`
	MailUser       string `long:"mailuser" description:"Email server username"`
	MailPass       string `long:"mailpass" description:"Email server password"`
	MailAddress    string `long:"mailaddress" description:"Email address for outgoing email in the format: name <address>"`

	// User layer settings
	DisableUsers bool   `long:"disableusers" description:"Disable the user layer"`
	UserPlugin   string `long:"userplugin" description:"ID of the plugin that manages user accounts"`
	AuthPlugin   string `long:"authplugin" description:"ID of the plugin that handles user authorization"`

	// Plugin settings
	Plugins        []string `long:"plugin" description:"IDs of all plugins to be registered"`
	PluginSettings []string `long:"pluginsetting" description:"Plugin settings"`

	// Embedded legacy settings. This will be deleted soon.
	DisableLegacy bool `long:"disablelegacy" description:"Disable legacy routes"`
	LegacyConfig

	Version     string
	ActiveNet   *ChainParams             // Active DCR network
	Identity    *identity.PublicIdentity // politeiad identity
	SystemCerts *x509.CertPool
}

Config defines the configuration options for politeiawww.

func Load added in v1.3.0

func Load() (*Config, []string, error)

Load initializes and parses the config using a config file and command line options.

The configuration proceeds as follows:

  1. Start with a default config with sane settings
  2. Pre-parse the command line to check for an alternative config file
  3. Load configuration file overwriting defaults with any specified options
  4. Parse CLI options and overwrite/add any specified options

The above results in rpc functioning properly without any config settings while still allowing the user to override settings with config files and command line options. Command line options always take precedence.

type LegacyConfig added in v1.3.0

type LegacyConfig struct {
	// Legacy user database settings
	DBRootCert       string `long:"dbrootcert" description:"File containing the CA certificate for the database"`
	DBCert           string `long:"dbcert" description:"File containing the politeiawww client certificate for the database"`
	DBKey            string `long:"dbkey" description:"File containing the politeiawww client certificate key for the database"`
	EncryptionKey    string `long:"encryptionkey" description:"File containing encryption key used for encrypting user data at rest"`
	OldEncryptionKey string `long:"oldencryptionkey" description:"File containing old encryption key (only set when rotating keys)"`

	// Settings the need to be turned into plugin settings.
	MailRateLimit    int    `long:"mailratelimit" description:"Limits the amount of emails a user can receive in 24h"`
	WebServerAddress string `long:"webserveraddress" description:"Web server address used to create email links (format: <scheme>://<host>[:<port>])"`

	// Legacy API settings
	Mode        string `long:"mode" description:"Mode www runs as. Supported values: piwww, cmswww"`
	DcrdataHost string `long:"dcrdatahost" description:"Dcrdata ip:port"`

	// Legacy pi settings
	PaywallAmount            uint64 `long:"paywallamount" description:"Amount of DCR (in atoms) required for a user to register or submit a proposal."`
	PaywallXpub              string `long:"paywallxpub" description:"Extended public key for deriving paywall addresses."`
	MinConfirmationsRequired uint64 `long:"minconfirmations" description:"Minimum blocks confirmation for accepting paywall as paid. Only works in TestNet."`

	// Legacy cmswww settings
	BuildCMSDB           bool     `long:"buildcmsdb" description:"Build the cmsdb from scratch"`
	GithubAPIToken       string   `` /* 141-byte string literal not displayed */
	CodeStatRepos        []string `long:"codestatrepos" description:"Org/Repositories to crawl for code statistics"`
	CodeStatOrganization string   `long:"codestatorg" description:"Organization to crawl for code statistics"`
	CodeStatStart        int64    `long:"codestatstart" description:"Date in which to look back to for code stat crawl (default 6 months back)"`
	CodeStatEnd          int64    `long:"codestatend" description:"Date in which to end look back to for code stat crawl (default today)"`
	CodeStatSkipSync     bool     `long:"codestatskipsync" description:"Skip pull request crawl on startup"`
	VoteDurationMin      uint32   `long:"votedurationmin" description:"Minimum duration of a dcc vote in blocks"`
	VoteDurationMax      uint32   `long:"votedurationmax" description:"Maximum duration of a dcc vote in blocks"`
}

LegacyConfig represents the config options for legacy API.

Everything in this config is DEPRECATED and will be removed in the near future.

Jump to

Keyboard shortcuts

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