forked from decred/dcrstakepool
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6530be6
commit 3d56868
Showing
5 changed files
with
70 additions
and
54 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 |
---|---|---|
|
@@ -19,33 +19,35 @@ import ( | |
"github.com/decred/dcrd/dcrutil" | ||
"github.com/decred/dcrd/hdkeychain" | ||
"github.com/decred/dcrstakepool/internal/version" | ||
"github.com/decred/dcrstakepool/v3api" | ||
flags "github.com/jessevdk/go-flags" | ||
) | ||
|
||
const ( | ||
defaultBaseURL = "http://127.0.0.1:8000" | ||
defaultClosePoolMsg = "The voting service is temporarily closed to new signups." | ||
defaultConfigFilename = "dcrstakepool.conf" | ||
defaultDataDirname = "data" | ||
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 = "" | ||
defaultMinServers = 2 | ||
defaultMaxVotedTickets = 1000 | ||
defaultDescription = "" | ||
defaultDesignation = "" | ||
defaultBaseURL = "http://127.0.0.1:8000" | ||
defaultClosePoolMsg = "The voting service is temporarily closed to new signups." | ||
defaultConfigFilename = "dcrstakepool.conf" | ||
defaultDataDirname = "data" | ||
defaultLogLevel = "info" | ||
defaultLogDirname = "logs" | ||
defaultLogFilename = "dcrstakepool.log" | ||
defaultTicketChallengeMaxAge = 600 | ||
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 = "" | ||
defaultMinServers = 2 | ||
defaultMaxVotedTickets = 1000 | ||
defaultDescription = "" | ||
defaultDesignation = "" | ||
) | ||
|
||
var ( | ||
|
@@ -77,6 +79,7 @@ type config struct { | |
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"` | ||
// todo: can `ColdWalletExtPub` and `PoolFees` be read from stakepoold via rpc? | ||
ColdWalletExtPub string `long:"coldwalletextpub" description:"The extended public key for addresses to which voting service user fees are sent."` | ||
|
@@ -314,29 +317,30 @@ 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, | ||
DataDir: defaultDataDir, | ||
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, | ||
MinServers: defaultMinServers, | ||
MaxVotedTickets: defaultMaxVotedTickets, | ||
Description: defaultDescription, | ||
Designation: defaultDesignation, | ||
BaseURL: defaultBaseURL, | ||
ClosePool: false, | ||
ClosePoolMsg: defaultClosePoolMsg, | ||
ConfigFile: defaultConfigFile, | ||
DebugLevel: defaultLogLevel, | ||
DataDir: defaultDataDir, | ||
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, | ||
MinServers: defaultMinServers, | ||
MaxVotedTickets: defaultMaxVotedTickets, | ||
Description: defaultDescription, | ||
Designation: defaultDesignation, | ||
} | ||
|
||
// Service options which are only added on Windows. | ||
|
@@ -474,6 +478,12 @@ func loadConfig() (*config, []string, error) { | |
return nil, nil, err | ||
} | ||
|
||
// Ensure ticket challenge max age is not greater than permitted maximum. | ||
if cfg.TicketChallengeMaxAge > v3api.MaxTicketChallengeAge { | ||
return nil, nil, fmt.Errorf("%s: Tickat challenge max age cannot be higher than %v", | ||
funcName, v3api.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
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