aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth/wizard.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-08-18 16:23:56 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-08-18 16:23:56 +0800
commit059c767adf4956d6d7bae16066a798d02a367f01 (patch)
tree1cbcce71bd2933d1e4ac1be7270d61f661cb20ba /cmd/puppeth/wizard.go
parent104375f398bdfca88183010cc3693e377ea74163 (diff)
downloadgo-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar.gz
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar.bz2
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar.lz
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar.xz
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.tar.zst
go-tangerine-059c767adf4956d6d7bae16066a798d02a367f01.zip
cmd/puppeth: support blacklisting malicious IPs on ethstats
Diffstat (limited to 'cmd/puppeth/wizard.go')
-rw-r--r--cmd/puppeth/wizard.go24
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
+ }
+}