@@ -18,6 +18,7 @@ package main
18
18
19
19
import (
20
20
"fmt"
21
+ "sort"
21
22
22
23
"github.com/ethereum/go-ethereum/log"
23
24
)
@@ -64,17 +65,37 @@ func (w *wizard) deployEthstats() {
64
65
fmt .Println ()
65
66
fmt .Printf ("Keep existing IP %v blacklist (y/n)? (default = yes)\n " , infos .banned )
66
67
if w .readDefaultString ("y" ) != "y" {
67
- infos .banned = nil
68
-
68
+ // The user might want to clear the entire list, although generally probably not
69
+ fmt .Println ()
70
+ fmt .Printf ("Clear out blacklist and start over (y/n)? (default = no)\n " )
71
+ if w .readDefaultString ("n" ) != "n" {
72
+ infos .banned = nil
73
+ }
74
+ // Offer the user to explicitly add/remove certain IP addresses
75
+ fmt .Println ()
76
+ fmt .Println ("Which additional IP addresses should be blacklisted?" )
77
+ for {
78
+ if ip := w .readIPAddress (); ip != "" {
79
+ infos .banned = append (infos .banned , ip )
80
+ continue
81
+ }
82
+ break
83
+ }
69
84
fmt .Println ()
70
- fmt .Println ("Which IP addresses should be blacklisted?" )
85
+ fmt .Println ("Which IP addresses should not be blacklisted?" )
71
86
for {
72
- if ip := w .readIPAddress (); ip != nil {
73
- infos .banned = append (infos .banned , ip .String ())
87
+ if ip := w .readIPAddress (); ip != "" {
88
+ for i , addr := range infos .banned {
89
+ if ip == addr {
90
+ infos .banned = append (infos .banned [:i ], infos .banned [i + 1 :]... )
91
+ break
92
+ }
93
+ }
74
94
continue
75
95
}
76
96
break
77
97
}
98
+ sort .Strings (infos .banned )
78
99
}
79
100
// Try to deploy the ethstats server on the host
80
101
trusted := make ([]string , 0 , len (w .servers ))
0 commit comments