Skip to content

Commit 1af9e4f

Browse files
authored
cm/puppeth: fix crash when of ethstats specifier doesn't contain : (#25405)
Signed-off-by: Delweng <[email protected]>
1 parent 0290599 commit 1af9e4f

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

cmd/puppeth/module.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,12 @@ func checkPort(host string, port int) error {
150150
conn.Close()
151151
return nil
152152
}
153+
154+
// getEthName gets the Ethereum Name from ethstats
155+
func getEthName(s string) string {
156+
n := strings.Index(s, ":")
157+
if n >= 0 {
158+
return s[:n]
159+
}
160+
return s
161+
}

cmd/puppeth/module_explorer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func deployExplorer(client *sshClient, network string, bootnodes []string, confi
104104
"Datadir": config.node.datadir,
105105
"DBDir": config.dbdir,
106106
"EthPort": config.node.port,
107-
"EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")],
107+
"EthName": getEthName(config.node.ethstats),
108108
"WebPort": config.port,
109109
"Transformer": transformer,
110110
})

cmd/puppeth/module_faucet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
116116
"VHost": config.host,
117117
"ApiPort": config.port,
118118
"EthPort": config.node.port,
119-
"EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")],
119+
"EthName": getEthName(config.node.ethstats),
120120
"CaptchaToken": config.captchaToken,
121121
"CaptchaSecret": config.captchaSecret,
122122
"FaucetAmount": config.amount,

cmd/puppeth/module_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
123123
"TotalPeers": config.peersTotal,
124124
"Light": config.peersLight > 0,
125125
"LightPeers": config.peersLight,
126-
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")],
126+
"Ethstats": getEthName(config.ethstats),
127127
"Etherbase": config.etherbase,
128128
"GasTarget": config.gasTarget,
129129
"GasLimit": config.gasLimit,

0 commit comments

Comments
 (0)