diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-17 01:53:27 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-04-17 01:53:27 +0800 |
commit | af48a331bf1ec8d30cff7d411afcce37741cbede (patch) | |
tree | 45463b9cf2bb65345ac748ccbf358c587dc678e4 /cmd/puppeth/module_faucet.go | |
parent | 80e74fc1e09ccc3cf48a65fd89d2d872dc68fda3 (diff) | |
download | dexon-af48a331bf1ec8d30cff7d411afcce37741cbede.tar.gz dexon-af48a331bf1ec8d30cff7d411afcce37741cbede.tar.zst dexon-af48a331bf1ec8d30cff7d411afcce37741cbede.zip |
cmd: integrate invisible recaptcha into puppeth
Diffstat (limited to 'cmd/puppeth/module_faucet.go')
-rw-r--r-- | cmd/puppeth/module_faucet.go | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/cmd/puppeth/module_faucet.go b/cmd/puppeth/module_faucet.go index 44016c53e..fc957721d 100644 --- a/cmd/puppeth/module_faucet.go +++ b/cmd/puppeth/module_faucet.go @@ -54,6 +54,7 @@ CMD [ \ "/faucet", "--genesis", "/genesis.json", "--network", "{{.NetworkID}}", "--bootnodes", "{{.Bootnodes}}", "--ethstats", "{{.Ethstats}}", \ "--ethport", "{{.EthPort}}", "--faucet.name", "{{.FaucetName}}", "--faucet.amount", "{{.FaucetAmount}}", "--faucet.minutes", "{{.FaucetMinutes}}", \ "--github.user", "{{.GitHubUser}}", "--github.token", "{{.GitHubToken}}", "--account.json", "/account.json", "--account.pass", "/account.pass" \ + {{if .CaptchaToken}}, "--captcha.token", "{{.CaptchaToken}}", "--captcha.secret", "{{.CaptchaSecret}}"{{end}} \ ]` // faucetComposefile is the docker-compose.yml file required to deploy and maintain @@ -75,7 +76,9 @@ services: - FAUCET_AMOUNT={{.FaucetAmount}} - FAUCET_MINUTES={{.FaucetMinutes}} - GITHUB_USER={{.GitHubUser}} - - GITHUB_TOKEN={{.GitHubToken}}{{if .VHost}} + - GITHUB_TOKEN={{.GitHubToken}} + - CAPTCHA_TOKEN={{.CaptchaToken}} + - CAPTCHA_SECRET={{.CaptchaSecret}}{{if .VHost}} - VIRTUAL_HOST={{.VHost}} - VIRTUAL_PORT=8080{{end}} restart: always @@ -97,6 +100,8 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config "EthPort": config.node.portFull, "GitHubUser": config.githubUser, "GitHubToken": config.githubToken, + "CaptchaToken": config.captchaToken, + "CaptchaSecret": config.captchaSecret, "FaucetName": strings.Title(network), "FaucetAmount": config.amount, "FaucetMinutes": config.minutes, @@ -113,6 +118,8 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config "EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")], "GitHubUser": config.githubUser, "GitHubToken": config.githubToken, + "CaptchaToken": config.captchaToken, + "CaptchaSecret": config.captchaSecret, "FaucetAmount": config.amount, "FaucetMinutes": config.minutes, }) @@ -135,18 +142,20 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config // faucetInfos is returned from an faucet status check to allow reporting various // configuration parameters. type faucetInfos struct { - node *nodeInfos - host string - port int - amount int - minutes int - githubUser string - githubToken string + node *nodeInfos + host string + port int + amount int + minutes int + githubUser string + githubToken string + captchaToken string + captchaSecret string } // String implements the stringer interface. func (info *faucetInfos) String() string { - return fmt.Sprintf("host=%s, api=%d, eth=%d, amount=%d, minutes=%d, github=%s, ethstats=%s", info.host, info.port, info.node.portFull, info.amount, info.minutes, info.githubUser, info.node.ethstats) + return fmt.Sprintf("host=%s, api=%d, eth=%d, amount=%d, minutes=%d, github=%s, captcha=%v, ethstats=%s", info.host, info.port, info.node.portFull, info.amount, info.minutes, info.githubUser, info.captchaToken != "", info.node.ethstats) } // checkFaucet does a health-check against an faucet server to verify whether @@ -200,11 +209,13 @@ func checkFaucet(client *sshClient, network string) (*faucetInfos, error) { keyJSON: keyJSON, keyPass: keyPass, }, - host: host, - port: port, - amount: amount, - minutes: minutes, - githubUser: infos.envvars["GITHUB_USER"], - githubToken: infos.envvars["GITHUB_TOKEN"], + host: host, + port: port, + amount: amount, + minutes: minutes, + githubUser: infos.envvars["GITHUB_USER"], + githubToken: infos.envvars["GITHUB_TOKEN"], + captchaToken: infos.envvars["CAPTCHA_TOKEN"], + captchaSecret: infos.envvars["CAPTCHA_SECRET"], }, nil } |