Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
8d8034fe
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8d8034fe
编写于
10月 12, 2017
作者:
P
Péter Szilágyi
提交者:
GitHub
10月 12, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15269 from karalabe/puppeth-dumb-ip-filtering
cmd/puppeth: use dumb textual IP filtering
上级
fd0e7b1c
b45cc0c9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
11 deletion
+33
-11
cmd/puppeth/wizard.go
cmd/puppeth/wizard.go
+7
-6
cmd/puppeth/wizard_ethstats.go
cmd/puppeth/wizard_ethstats.go
+26
-5
未找到文件。
cmd/puppeth/wizard.go
浏览文件 @
8d8034fe
...
...
@@ -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
}
}
cmd/puppeth/wizard_ethstats.go
浏览文件 @
8d8034fe
...
...
@@ -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
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录