diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-10 17:35:09 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-10-10 17:35:09 +0800 |
commit | b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe (patch) | |
tree | 34ccc255b171270755fce8f820893a2dde654098 /cmd/puppeth/wizard_ethstats.go | |
parent | 3680cd5926c1185b2338648bad29fae15e5f34b8 (diff) | |
download | dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar.gz dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar.bz2 dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar.lz dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar.xz dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.tar.zst dexon-b45cc0c9e8c8724f9db6420a0ea7fbf6d5401fbe.zip |
cmd/puppeth: use dumb textual IP filtering
Diffstat (limited to 'cmd/puppeth/wizard_ethstats.go')
-rw-r--r-- | cmd/puppeth/wizard_ethstats.go | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/cmd/puppeth/wizard_ethstats.go b/cmd/puppeth/wizard_ethstats.go index 504d8fd9c..8bfa1d6e5 100644 --- a/cmd/puppeth/wizard_ethstats.go +++ b/cmd/puppeth/wizard_ethstats.go @@ -18,6 +18,7 @@ package main import ( "fmt" + "sort" "github.com/ethereum/go-ethereum/log" ) @@ -64,17 +65,37 @@ func (w *wizard) deployEthstats() { fmt.Println() fmt.Printf("Keep existing IP %v blacklist (y/n)? (default = yes)\n", infos.banned) if w.readDefaultString("y") != "y" { - infos.banned = nil - + // The user might want to clear the entire list, although generally probably not + fmt.Println() + fmt.Printf("Clear out blacklist and start over (y/n)? (default = no)\n") + if w.readDefaultString("n") != "n" { + infos.banned = nil + } + // Offer the user to explicitly add/remove certain IP addresses + fmt.Println() + fmt.Println("Which additional IP addresses should be blacklisted?") + for { + if ip := w.readIPAddress(); ip != "" { + infos.banned = append(infos.banned, ip) + continue + } + break + } fmt.Println() - fmt.Println("Which IP addresses should be blacklisted?") + fmt.Println("Which IP addresses should not be blacklisted?") for { - if ip := w.readIPAddress(); ip != nil { - infos.banned = append(infos.banned, ip.String()) + if ip := w.readIPAddress(); ip != "" { + for i, addr := range infos.banned { + if ip == addr { + infos.banned = append(infos.banned[:i], infos.banned[i+1:]...) + break + } + } continue } break } + sort.Strings(infos.banned) } // Try to deploy the ethstats server on the host trusted := make([]string, 0, len(w.servers)) |