good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b45cc0c9
Unverified
Commit
b45cc0c9
authored
7 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
cmd/puppeth: use dumb textual IP filtering
parent
3680cd59
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/puppeth/wizard.go
+7
-6
7 additions, 6 deletions
cmd/puppeth/wizard.go
cmd/puppeth/wizard_ethstats.go
+26
-5
26 additions, 5 deletions
cmd/puppeth/wizard_ethstats.go
with
33 additions
and
11 deletions
cmd/puppeth/wizard.go
+
7
−
6
View file @
b45cc0c9
...
@@ -302,8 +302,10 @@ func (w *wizard) readJSON() string {
...
@@ -302,8 +302,10 @@ func (w *wizard) readJSON() string {
}
}
// readIPAddress reads a single line from stdin, trimming if from spaces and
// readIPAddress reads a single line from stdin, trimming if from spaces and
// converts it to a network IP address.
// returning it if it's convertible to an IP address. The reason for keeping
func
(
w
*
wizard
)
readIPAddress
()
net
.
IP
{
// 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
{
for
{
// Read the IP address from the user
// Read the IP address from the user
fmt
.
Printf
(
"> "
)
fmt
.
Printf
(
"> "
)
...
@@ -312,14 +314,13 @@ func (w *wizard) readIPAddress() net.IP {
...
@@ -312,14 +314,13 @@ func (w *wizard) readIPAddress() net.IP {
log
.
Crit
(
"Failed to read user input"
,
"err"
,
err
)
log
.
Crit
(
"Failed to read user input"
,
"err"
,
err
)
}
}
if
text
=
strings
.
TrimSpace
(
text
);
text
==
""
{
if
text
=
strings
.
TrimSpace
(
text
);
text
==
""
{
return
nil
return
""
}
}
// Make sure it looks ok and return it if so
// Make sure it looks ok and return it if so
ip
:=
net
.
ParseIP
(
text
)
if
ip
:=
net
.
ParseIP
(
text
);
ip
==
nil
{
if
ip
==
nil
{
log
.
Error
(
"Invalid IP address, please retry"
)
log
.
Error
(
"Invalid IP address, please retry"
)
continue
continue
}
}
return
ip
return
text
}
}
}
}
This diff is collapsed.
Click to expand it.
cmd/puppeth/wizard_ethstats.go
+
26
−
5
View file @
b45cc0c9
...
@@ -18,6 +18,7 @@ package main
...
@@ -18,6 +18,7 @@ package main
import
(
import
(
"fmt"
"fmt"
"sort"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -64,17 +65,37 @@ func (w *wizard) deployEthstats() {
...
@@ -64,17 +65,37 @@ func (w *wizard) deployEthstats() {
fmt
.
Println
()
fmt
.
Println
()
fmt
.
Printf
(
"Keep existing IP %v blacklist (y/n)? (default = yes)
\n
"
,
infos
.
banned
)
fmt
.
Printf
(
"Keep existing IP %v blacklist (y/n)? (default = yes)
\n
"
,
infos
.
banned
)
if
w
.
readDefaultString
(
"y"
)
!=
"y"
{
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
()
fmt
.
Println
(
"Which IP addresses should be blacklisted?"
)
fmt
.
Println
(
"Which IP addresses should
not
be blacklisted?"
)
for
{
for
{
if
ip
:=
w
.
readIPAddress
();
ip
!=
nil
{
if
ip
:=
w
.
readIPAddress
();
ip
!=
""
{
infos
.
banned
=
append
(
infos
.
banned
,
ip
.
String
())
for
i
,
addr
:=
range
infos
.
banned
{
if
ip
==
addr
{
infos
.
banned
=
append
(
infos
.
banned
[
:
i
],
infos
.
banned
[
i
+
1
:
]
...
)
break
}
}
continue
continue
}
}
break
break
}
}
sort
.
Strings
(
infos
.
banned
)
}
}
// Try to deploy the ethstats server on the host
// Try to deploy the ethstats server on the host
trusted
:=
make
([]
string
,
0
,
len
(
w
.
servers
))
trusted
:=
make
([]
string
,
0
,
len
(
w
.
servers
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment