Unverified Commit 1af9e4f3 authored by Delweng's avatar Delweng Committed by GitHub

cm/puppeth: fix crash when of ethstats specifier doesn't contain `:` (#25405)

Signed-off-by: 's avatarDelweng <delweng@gmail.com>
parent 02905994
...@@ -150,3 +150,12 @@ func checkPort(host string, port int) error { ...@@ -150,3 +150,12 @@ func checkPort(host string, port int) error {
conn.Close() conn.Close()
return nil return nil
} }
// getEthName gets the Ethereum Name from ethstats
func getEthName(s string) string {
n := strings.Index(s, ":")
if n >= 0 {
return s[:n]
}
return s
}
...@@ -104,7 +104,7 @@ func deployExplorer(client *sshClient, network string, bootnodes []string, confi ...@@ -104,7 +104,7 @@ func deployExplorer(client *sshClient, network string, bootnodes []string, confi
"Datadir": config.node.datadir, "Datadir": config.node.datadir,
"DBDir": config.dbdir, "DBDir": config.dbdir,
"EthPort": config.node.port, "EthPort": config.node.port,
"EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")], "EthName": getEthName(config.node.ethstats),
"WebPort": config.port, "WebPort": config.port,
"Transformer": transformer, "Transformer": transformer,
}) })
......
...@@ -116,7 +116,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config ...@@ -116,7 +116,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
"VHost": config.host, "VHost": config.host,
"ApiPort": config.port, "ApiPort": config.port,
"EthPort": config.node.port, "EthPort": config.node.port,
"EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")], "EthName": getEthName(config.node.ethstats),
"CaptchaToken": config.captchaToken, "CaptchaToken": config.captchaToken,
"CaptchaSecret": config.captchaSecret, "CaptchaSecret": config.captchaSecret,
"FaucetAmount": config.amount, "FaucetAmount": config.amount,
......
...@@ -123,7 +123,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n ...@@ -123,7 +123,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
"TotalPeers": config.peersTotal, "TotalPeers": config.peersTotal,
"Light": config.peersLight > 0, "Light": config.peersLight > 0,
"LightPeers": config.peersLight, "LightPeers": config.peersLight,
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")], "Ethstats": getEthName(config.ethstats),
"Etherbase": config.etherbase, "Etherbase": config.etherbase,
"GasTarget": config.gasTarget, "GasTarget": config.gasTarget,
"GasLimit": config.gasLimit, "GasLimit": config.gasLimit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment