diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-12 18:46:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-12 18:46:57 +0800 |
commit | 8d8034fe59e40d606e6feea4c71b4798e7862e2f (patch) | |
tree | de4bfbf5480c595dfec75f4b41ce146f65391ee3 /cmd/puppeth/wizard.go | |
parent | fd0e7b1c679ff4535513ae2d01c81803b7eb8f9b (diff) | |
parent | b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe (diff) | |
download | dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar.gz dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar.bz2 dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar.lz dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar.xz dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.tar.zst dexon-8d8034fe59e40d606e6feea4c71b4798e7862e2f.zip |
Merge pull request #15269 from karalabe/puppeth-dumb-ip-filtering
cmd/puppeth: use dumb textual IP filtering
Diffstat (limited to 'cmd/puppeth/wizard.go')
-rw-r--r-- | cmd/puppeth/wizard.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index 3fdd639f8..5fbc11cb9 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -302,8 +302,10 @@ func (w *wizard) readJSON() string { } // 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 { +// returning it if it's convertible to an IP address. The reason for keeping +// the user input format instead of returning a Go net.IP is to match with +// weird formats used by ethstats, which compares IPs textually, not by value. +func (w *wizard) readIPAddress() string { for { // Read the IP address from the user fmt.Printf("> ") @@ -312,14 +314,13 @@ func (w *wizard) readIPAddress() net.IP { log.Crit("Failed to read user input", "err", err) } if text = strings.TrimSpace(text); text == "" { - return nil + return "" } // Make sure it looks ok and return it if so - ip := net.ParseIP(text) - if ip == nil { + if ip := net.ParseIP(text); ip == nil { log.Error("Invalid IP address, please retry") continue } - return ip + return text } } |