-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove maxticketchallengeage config option, use constant value
- Loading branch information
1 parent
d3f119e
commit d140358
Showing
5 changed files
with
110 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,30 +26,27 @@ import ( | |
) | ||
|
||
const ( | ||
defaultBaseURL = "http://127.0.0.1:8000" | ||
defaultClosePoolMsg = "The voting service is temporarily closed to new signups." | ||
defaultConfigFilename = "dcrstakepool.conf" | ||
defaultLogLevel = "info" | ||
defaultLogDirname = "logs" | ||
defaultLogFilename = "dcrstakepool.log" | ||
defaultTicketChallengeMaxAge = 600 // 10 minutes | ||
defaultCookieSecure = false | ||
defaultDBHost = "localhost" | ||
defaultDBName = "stakepool" | ||
defaultDBPort = "3306" | ||
defaultDBUser = "stakepool" | ||
defaultListen = ":8000" | ||
defaultPoolEmail = "[email protected]" | ||
defaultPoolFees = 7.5 | ||
defaultPoolLink = "https://forum.decred.org/threads/rfp-6-setup-and-operate-10-stake-pools.1361/" | ||
defaultPublicPath = "public" | ||
defaultTemplatePath = "views" | ||
defaultSMTPHost = "" | ||
defaultMaxVotedTickets = 1000 | ||
defaultDescription = "" | ||
defaultDesignation = "" | ||
|
||
MaxTicketChallengeAge = 60 * 30 // 30 minutes | ||
defaultBaseURL = "http://127.0.0.1:8000" | ||
defaultClosePoolMsg = "The voting service is temporarily closed to new signups." | ||
defaultConfigFilename = "dcrstakepool.conf" | ||
defaultLogLevel = "info" | ||
defaultLogDirname = "logs" | ||
defaultLogFilename = "dcrstakepool.log" | ||
defaultCookieSecure = false | ||
defaultDBHost = "localhost" | ||
defaultDBName = "stakepool" | ||
defaultDBPort = "3306" | ||
defaultDBUser = "stakepool" | ||
defaultListen = ":8000" | ||
defaultPoolEmail = "[email protected]" | ||
defaultPoolFees = 7.5 | ||
defaultPoolLink = "https://forum.decred.org/threads/rfp-6-setup-and-operate-10-stake-pools.1361/" | ||
defaultPublicPath = "public" | ||
defaultTemplatePath = "views" | ||
defaultSMTPHost = "" | ||
defaultMaxVotedTickets = 1000 | ||
defaultDescription = "" | ||
defaultDesignation = "" | ||
) | ||
|
||
var ( | ||
|
@@ -68,59 +65,58 @@ var runServiceCommand func(string) error | |
// | ||
// See loadConfig for details on the configuration load process. | ||
type config struct { | ||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` | ||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` | ||
DataDir string `short:"b" long:"datadir" description:"Deprecated. Unused, do not set."` | ||
LogDir string `long:"logdir" description:"Directory to log output."` | ||
Listen string `long:"listen" description:"Listen for connections on the specified interface/port (default all interfaces port: 9113, testnet: 19113)"` | ||
TestNet bool `long:"testnet" description:"Use the test network"` | ||
SimNet bool `long:"simnet" description:"Use the simulation test network"` | ||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"` | ||
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"` | ||
MemProfile string `long:"memprofile" description:"Write mem profile to the specified file"` | ||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"` | ||
APISecret string `long:"apisecret" description:"Secret string used to encrypt API tokens."` | ||
TicketChallengeMaxAge int64 `long:"ticketchallengemaxage" description:"Max age (in seconds) for API v3 ticket authentication timestamps. Max allowed value is 1800 (30 minutes)."` | ||
BaseURL string `long:"baseurl" description:"BaseURL to use when sending links via email"` | ||
ColdWalletExtPub string `long:"coldwalletextpub" description:"The extended public key for addresses to which voting service user fees are sent."` | ||
ClosePool bool `long:"closepool" description:"Disable user registration actions (sign-ups and submitting addresses)"` | ||
ClosePoolMsg string `long:"closepoolmsg" description:"Message to display when closepool is set."` | ||
CookieSecret string `long:"cookiesecret" description:"Secret string used to encrypt session data."` | ||
CookieSecure bool `long:"cookiesecure" description:"Set whether cookies can be sent in clear text or not."` | ||
DBHost string `long:"dbhost" description:"Hostname for database connection"` | ||
DBUser string `long:"dbuser" description:"Username for database connection"` | ||
DBPassword string `long:"dbpassword" description:"Password for database connection"` | ||
DBPort string `long:"dbport" description:"Port for database connection"` | ||
DBName string `long:"dbname" description:"Name of database"` | ||
PublicPath string `long:"publicpath" description:"Path to the public folder which contains css/fonts/images/javascript."` | ||
TemplatePath string `long:"templatepath" description:"Path to the views folder which contains html files."` | ||
PoolEmail string `long:"poolemail" description:"Email address to for support inquiries"` | ||
PoolFees float64 `long:"poolfees" description:"The per-ticket fees the user must send to the pool with their tickets"` | ||
PoolLink string `long:"poollink" description:"URL for support inquiries such as forum, IRC, etc"` | ||
RealIPHeader string `long:"realipheader" description:"The name of an HTTP request header containing the actual remote client IP address, typically set by a reverse proxy. An empty string (default) indicates to use net/Request.RemodeAddr."` | ||
SMTPFrom string `long:"smtpfrom" description:"From address to use on outbound mail"` | ||
SMTPHost string `long:"smtphost" description:"SMTP hostname/ip and port, e.g. mail.example.com:25"` | ||
SMTPUsername string `long:"smtpusername" description:"SMTP username for authentication if required"` | ||
SMTPPassword string `long:"smtppassword" description:"SMTP password for authentication if required"` | ||
UseSMTPS bool `long:"usesmtps" description:"Connect to the SMTP server using smtps."` | ||
SMTPSkipVerify bool `long:"smtpskipverify" description:"Skip SMTP TLS cert verification. Will only skip if SMTPCert is empty"` | ||
SMTPCert string `long:"smtpcert" description:"Path for the smtp certificate file"` | ||
SystemCerts *x509.CertPool | ||
StakepooldHosts []string `long:"stakepooldhosts" description:"Hostnames for stakepoold servers"` | ||
StakepooldCerts []string `long:"stakepooldcerts" description:"Certificate paths for stakepoold servers"` | ||
WalletHosts []string `long:"wallethosts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletUsers []string `long:"walletusers" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletPasswords []string `long:"walletpasswords" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletCerts []string `long:"walletcerts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
VotingWalletExtPub string `long:"votingwalletextpub" description:"The extended public key of the default account of the voting wallet"` | ||
AdminIPs []string `long:"adminips" description:"Expected admin host"` | ||
AdminUserIDs []string `long:"adminuserids" description:"User IDs of users who are allowed to access administrative functions."` | ||
MinServers int `long:"minservers" description:"Deprecated: Do not use. Minimum of 2 servers are required when running on mainnet. Testnet and simnet require minimum 1."` | ||
EnableStakepoold bool `long:"enablestakepoold" description:"Deprecated: Do not use. Stakepoold is required."` | ||
MaxVotedAge int64 `long:"maxvotedage" description:"Deprecated: Use maxvotedtickets instead"` | ||
MaxVotedTickets int `long:"maxvotedtickets" description:"Maximum number of voted tickets to show on tickets page."` | ||
Description string `long:"description" description:"Operators own description of their VSP"` | ||
Designation string `long:"designation" description:"VSP designation (eg. Alpha, Bravo, etc)"` | ||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` | ||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` | ||
DataDir string `short:"b" long:"datadir" description:"Deprecated. Unused, do not set."` | ||
LogDir string `long:"logdir" description:"Directory to log output."` | ||
Listen string `long:"listen" description:"Listen for connections on the specified interface/port (default all interfaces port: 9113, testnet: 19113)"` | ||
TestNet bool `long:"testnet" description:"Use the test network"` | ||
SimNet bool `long:"simnet" description:"Use the simulation test network"` | ||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"` | ||
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"` | ||
MemProfile string `long:"memprofile" description:"Write mem profile to the specified file"` | ||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"` | ||
APISecret string `long:"apisecret" description:"Secret string used to encrypt API tokens."` | ||
BaseURL string `long:"baseurl" description:"BaseURL to use when sending links via email"` | ||
ColdWalletExtPub string `long:"coldwalletextpub" description:"The extended public key for addresses to which voting service user fees are sent."` | ||
ClosePool bool `long:"closepool" description:"Disable user registration actions (sign-ups and submitting addresses)"` | ||
ClosePoolMsg string `long:"closepoolmsg" description:"Message to display when closepool is set."` | ||
CookieSecret string `long:"cookiesecret" description:"Secret string used to encrypt session data."` | ||
CookieSecure bool `long:"cookiesecure" description:"Set whether cookies can be sent in clear text or not."` | ||
DBHost string `long:"dbhost" description:"Hostname for database connection"` | ||
DBUser string `long:"dbuser" description:"Username for database connection"` | ||
DBPassword string `long:"dbpassword" description:"Password for database connection"` | ||
DBPort string `long:"dbport" description:"Port for database connection"` | ||
DBName string `long:"dbname" description:"Name of database"` | ||
PublicPath string `long:"publicpath" description:"Path to the public folder which contains css/fonts/images/javascript."` | ||
TemplatePath string `long:"templatepath" description:"Path to the views folder which contains html files."` | ||
PoolEmail string `long:"poolemail" description:"Email address to for support inquiries"` | ||
PoolFees float64 `long:"poolfees" description:"The per-ticket fees the user must send to the pool with their tickets"` | ||
PoolLink string `long:"poollink" description:"URL for support inquiries such as forum, IRC, etc"` | ||
RealIPHeader string `long:"realipheader" description:"The name of an HTTP request header containing the actual remote client IP address, typically set by a reverse proxy. An empty string (default) indicates to use net/Request.RemodeAddr."` | ||
SMTPFrom string `long:"smtpfrom" description:"From address to use on outbound mail"` | ||
SMTPHost string `long:"smtphost" description:"SMTP hostname/ip and port, e.g. mail.example.com:25"` | ||
SMTPUsername string `long:"smtpusername" description:"SMTP username for authentication if required"` | ||
SMTPPassword string `long:"smtppassword" description:"SMTP password for authentication if required"` | ||
UseSMTPS bool `long:"usesmtps" description:"Connect to the SMTP server using smtps."` | ||
SMTPSkipVerify bool `long:"smtpskipverify" description:"Skip SMTP TLS cert verification. Will only skip if SMTPCert is empty"` | ||
SMTPCert string `long:"smtpcert" description:"Path for the smtp certificate file"` | ||
SystemCerts *x509.CertPool | ||
StakepooldHosts []string `long:"stakepooldhosts" description:"Hostnames for stakepoold servers"` | ||
StakepooldCerts []string `long:"stakepooldcerts" description:"Certificate paths for stakepoold servers"` | ||
WalletHosts []string `long:"wallethosts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletUsers []string `long:"walletusers" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletPasswords []string `long:"walletpasswords" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
WalletCerts []string `long:"walletcerts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"` | ||
VotingWalletExtPub string `long:"votingwalletextpub" description:"The extended public key of the default account of the voting wallet"` | ||
AdminIPs []string `long:"adminips" description:"Expected admin host"` | ||
AdminUserIDs []string `long:"adminuserids" description:"User IDs of users who are allowed to access administrative functions."` | ||
MinServers int `long:"minservers" description:"Deprecated: Do not use. Minimum of 2 servers are required when running on mainnet. Testnet and simnet require minimum 1."` | ||
EnableStakepoold bool `long:"enablestakepoold" description:"Deprecated: Do not use. Stakepoold is required."` | ||
MaxVotedAge int64 `long:"maxvotedage" description:"Deprecated: Use maxvotedtickets instead"` | ||
MaxVotedTickets int `long:"maxvotedtickets" description:"Maximum number of voted tickets to show on tickets page."` | ||
Description string `long:"description" description:"Operators own description of their VSP"` | ||
Designation string `long:"designation" description:"VSP designation (eg. Alpha, Bravo, etc)"` | ||
} | ||
|
||
// serviceOptions defines the configuration options for the daemon as a service | ||
|
@@ -317,28 +313,27 @@ func newConfigParser(cfg *config, so *serviceOptions, options flags.Options) *fl | |
func loadConfig() (*config, []string, error) { | ||
// Default config. | ||
cfg := config{ | ||
BaseURL: defaultBaseURL, | ||
ClosePool: false, | ||
ClosePoolMsg: defaultClosePoolMsg, | ||
ConfigFile: defaultConfigFile, | ||
DebugLevel: defaultLogLevel, | ||
LogDir: defaultLogDir, | ||
TicketChallengeMaxAge: defaultTicketChallengeMaxAge, | ||
CookieSecure: defaultCookieSecure, | ||
DBHost: defaultDBHost, | ||
DBName: defaultDBName, | ||
DBPort: defaultDBPort, | ||
DBUser: defaultDBUser, | ||
Listen: defaultListen, | ||
PoolEmail: defaultPoolEmail, | ||
PoolFees: defaultPoolFees, | ||
PoolLink: defaultPoolLink, | ||
PublicPath: defaultPublicPath, | ||
TemplatePath: defaultTemplatePath, | ||
SMTPHost: defaultSMTPHost, | ||
MaxVotedTickets: defaultMaxVotedTickets, | ||
Description: defaultDescription, | ||
Designation: defaultDesignation, | ||
BaseURL: defaultBaseURL, | ||
ClosePool: false, | ||
ClosePoolMsg: defaultClosePoolMsg, | ||
ConfigFile: defaultConfigFile, | ||
DebugLevel: defaultLogLevel, | ||
LogDir: defaultLogDir, | ||
CookieSecure: defaultCookieSecure, | ||
DBHost: defaultDBHost, | ||
DBName: defaultDBName, | ||
DBPort: defaultDBPort, | ||
DBUser: defaultDBUser, | ||
Listen: defaultListen, | ||
PoolEmail: defaultPoolEmail, | ||
PoolFees: defaultPoolFees, | ||
PoolLink: defaultPoolLink, | ||
PublicPath: defaultPublicPath, | ||
TemplatePath: defaultTemplatePath, | ||
SMTPHost: defaultSMTPHost, | ||
MaxVotedTickets: defaultMaxVotedTickets, | ||
Description: defaultDescription, | ||
Designation: defaultDesignation, | ||
} | ||
|
||
// Service options which are only added on Windows. | ||
|
@@ -475,12 +470,6 @@ func loadConfig() (*config, []string, error) { | |
return nil, nil, err | ||
} | ||
|
||
// Ensure ticket challenge max age is not greater than permitted maximum. | ||
if cfg.TicketChallengeMaxAge > MaxTicketChallengeAge { | ||
return nil, nil, fmt.Errorf("%s: Ticket challenge max age cannot be higher than %v", | ||
funcName, MaxTicketChallengeAge) | ||
} | ||
|
||
// Validate profile port number | ||
if cfg.Profile != "" { | ||
profilePort, err := strconv.Atoi(cfg.Profile) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.