diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-18 17:39:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 17:39:48 +0800 |
commit | 998abb910776f61fcea1d9350b157994abf5224b (patch) | |
tree | 1cbcce71bd2933d1e4ac1be7270d61f661cb20ba /cmd/puppeth/wizard.go | |
parent | 104375f398bdfca88183010cc3693e377ea74163 (diff) | |
parent | 059c767adf4956d6d7bae16066a798d02a367f01 (diff) | |
download | dexon-998abb910776f61fcea1d9350b157994abf5224b.tar dexon-998abb910776f61fcea1d9350b157994abf5224b.tar.gz dexon-998abb910776f61fcea1d9350b157994abf5224b.tar.bz2 dexon-998abb910776f61fcea1d9350b157994abf5224b.tar.lz dexon-998abb910776f61fcea1d9350b157994abf5224b.tar.xz dexon-998abb910776f61fcea1d9350b157994abf5224b.tar.zst dexon-998abb910776f61fcea1d9350b157994abf5224b.zip |
Merge pull request #14999 from karalabe/puppeth-ethstats-blacklist
cmd/puppeth: support blacklisting malicious IPs on ethstats
Diffstat (limited to 'cmd/puppeth/wizard.go')
-rw-r--r-- | cmd/puppeth/wizard.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index f19bcbbcd..518741279 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -22,6 +22,7 @@ import ( "fmt" "io/ioutil" "math/big" + "net" "os" "path/filepath" "sort" @@ -277,3 +278,26 @@ func (w *wizard) readJSON() string { return string(blob) } } + +// readIPAddress reads a single line from stdin, trimming if from spaces and +// converts it to a network IP address. +func (w *wizard) readIPAddress() net.IP { + for { + // Read the IP address from the user + fmt.Printf("> ") + text, err := w.in.ReadString('\n') + if err != nil { + log.Crit("Failed to read user input", "err", err) + } + if text = strings.TrimSpace(text); text == "" { + return nil + } + // Make sure it looks ok and return it if so + ip := net.ParseIP(text) + if ip == nil { + log.Error("Invalid IP address, please retry") + continue + } + return ip + } +} |