Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
eb454365
提交
eb454365
authored
6月 18, 2018
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
p2p: allow-custom-protocol option
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
c1910281
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
2 行删除
+21
-2
p2p.go
core/commands/p2p.go
+12
-2
t0180-p2p.sh
test/sharness/t0180-p2p.sh
+9
-0
没有找到文件。
core/commands/p2p.go
浏览文件 @
eb454365
...
...
@@ -19,6 +19,7 @@ import (
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
)
// P2PProtoPrefix is the default required prefix for protocol names
const
P2PProtoPrefix
=
"/x/"
// P2PListenerInfoOutput is output type of ls command
...
...
@@ -91,6 +92,9 @@ Examples:
cmdkit
.
StringArg
(
"listen-address"
,
true
,
false
,
"Listening endpoint."
),
cmdkit
.
StringArg
(
"target-address"
,
true
,
false
,
"Target endpoint."
),
},
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
"allow-custom-protocol"
,
"Don't require /x/ prefix"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
p2pGetNode
(
req
)
if
err
!=
nil
{
...
...
@@ -102,8 +106,14 @@ Examples:
listen
:=
req
.
Arguments
()[
1
]
target
:=
req
.
Arguments
()[
2
]
if
!
strings
.
HasPrefix
(
proto
,
P2PProtoPrefix
)
{
res
.
SetError
(
errors
.
New
(
"protocol name must be within '"
+
P2PProtoPrefix
+
"' namespace"
),
cmdkit
.
ErrNormal
)
allowCustom
,
_
,
err
:=
req
.
Option
(
"allow-custom-protocol"
)
.
Bool
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
if
!
allowCustom
&&
!
strings
.
HasPrefix
(
proto
,
P2PProtoPrefix
)
{
res
.
SetError
(
errors
.
New
(
"protocol name must be within '"
+
P2PProtoPrefix
+
"' namespace"
),
cmdkit
.
ErrNormal
)
return
}
...
...
test/sharness/t0180-p2p.sh
浏览文件 @
eb454365
...
...
@@ -239,6 +239,15 @@ test_expect_success "non /x/ scoped protocols are not allowed" '
check_test_ports
test_expect_success
'start p2p listener on custom proto'
'
ipfsi 0 p2p forward --allow-custom-protocol /p2p-test /ipfs /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
test_must_be_empty listener-stdouterr.log
'
test_expect_success
'C->S Close local listener'
'
ipfsi 0 p2p close -p /p2p-test
'
test_expect_success
'stop iptb'
'
iptb stop
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论