Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
fd971ed9
提交
fd971ed9
authored
7月 09, 2016
作者:
Jeromy Johnson
提交者:
GitHub
7月 09, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2956 from ipfs/feature/unrestricted-api
Resurrect --unrestricted-api
上级
926ab83e
421add3d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
51 行增加
和
12 行删除
+51
-12
daemon.go
cmd/ipfs/daemon.go
+15
-2
Makefile
test/Makefile
+4
-6
t0110-gateway.sh
test/sharness/t0110-gateway.sh
+0
-4
t0400-api-security.sh
test/sharness/t0400-api-security.sh
+32
-0
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
fd971ed9
...
...
@@ -134,7 +134,7 @@ Headers.
cmds
.
BoolOption
(
writableKwd
,
"Enable writing objects (with POST, PUT and DELETE)"
)
.
Default
(
false
),
cmds
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."
),
cmds
.
StringOption
(
ipnsMountKwd
,
"Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."
),
cmds
.
BoolOption
(
unrestrictedApiAccessKwd
,
"
This option has no effect since v0.4.3
"
)
.
Default
(
false
),
cmds
.
BoolOption
(
unrestrictedApiAccessKwd
,
"
Allow API access to unlisted hashes
"
)
.
Default
(
false
),
cmds
.
BoolOption
(
unencryptTransportKwd
,
"Disable transport encryption (for debugging protocols)"
)
.
Default
(
false
),
cmds
.
BoolOption
(
enableGCKwd
,
"Enable automatic periodic repo garbage collection"
)
.
Default
(
false
),
cmds
.
BoolOption
(
adjustFDLimitKwd
,
"Check and raise file descriptor limits if needed"
)
.
Default
(
true
),
...
...
@@ -363,11 +363,24 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
apiMaddr
=
apiLis
.
Multiaddr
()
fmt
.
Printf
(
"API server listening on %s
\n
"
,
apiMaddr
)
// by default, we don't let you load arbitrary ipfs objects through the api,
// because this would open up the api to scripting vulnerabilities.
// only the webui objects are allowed.
// if you know what you're doing, go ahead and pass --unrestricted-api.
unrestricted
,
_
,
err
:=
req
.
Option
(
unrestrictedApiAccessKwd
)
.
Bool
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"serveHTTPApi: Option(%s) failed: %s"
,
unrestrictedApiAccessKwd
,
err
),
nil
}
gatewayOpt
:=
corehttp
.
GatewayOption
(
corehttp
.
WebUIPaths
...
)
if
unrestricted
{
gatewayOpt
=
corehttp
.
GatewayOption
(
"/ipfs"
,
"/ipns"
)
}
var
opts
=
[]
corehttp
.
ServeOption
{
corehttp
.
MetricsCollectionOption
(
"api"
),
corehttp
.
CommandsOption
(
*
req
.
InvocContext
()),
corehttp
.
WebUIOption
,
corehttp
.
GatewayOption
(
corehttp
.
WebUIPaths
...
)
,
gatewayOpt
,
corehttp
.
VersionOption
(),
defaultMux
(
"/debug/vars"
),
defaultMux
(
"/debug/pprof/"
),
...
...
test/Makefile
浏览文件 @
fd971ed9
...
...
@@ -7,8 +7,6 @@ RANDOM_FILES_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random-files
POLLENDPOINT_SRC
=
../thirdparty/pollEndpoint
GOSLEEP_SRC
=
./dependencies/go-sleep
GX_RELATIVE_PATH
=
gx/ipfs
export
PATH
:=
../bin:
${
PATH
}
# User might want to override those on the command line
...
...
@@ -53,16 +51,16 @@ bin/go-sleep: $(call find_go_files, $(GOSLEEP_SRC)) IPFS-BUILD-OPTIONS
# gx dependencies
multihash_src
:
$
(
eval
MULTIHASH_HASH :
=
$(
shell
cd
..
&&
gx deps find go-multihash
)
)
$
(
eval
MULTIHASH_SRC :
=
$(GX_RELATIVE_PATH)
/
$(MULTIHASH_HASH)
/go-multihash
)
$
(
eval
MULTIHASH_HASH :
=
$(
shell
cd
..
&&
bin/
gx deps find go-multihash
)
)
$
(
eval
MULTIHASH_SRC :
=
gx/ipfs
/
$(MULTIHASH_HASH)
/go-multihash
)
bin/multihash
:
multihash_src $(call find_go_files
,
$(MULTIHASH_SRC)) IPFS-BUILD-OPTIONS
@
echo
"*** installing
$@
***"
go build
$(GOFLAGS)
-o
bin/multihash
$(MULTIHASH_SRC)
/multihash
iptb_src
:
$
(
eval
IPTB_HASH :
=
$(
shell
cd
..
&&
gx deps find iptb
)
)
$
(
eval
IPTB_SRC :
=
$(GX_RELATIVE_PATH)
/
$(IPTB_HASH)
/iptb
)
$
(
eval
IPTB_HASH :
=
$(
shell
cd
..
&&
bin/
gx deps find iptb
)
)
$
(
eval
IPTB_SRC :
=
gx/ipfs
/
$(IPTB_HASH)
/iptb
)
bin/iptb
:
iptb_src $(call find_go_files
,
$(IPTB_SRC)) IPFS-BUILD-OPTIONS
@
echo
"*** installing
$@
***"
...
...
test/sharness/t0110-gateway.sh
浏览文件 @
fd971ed9
...
...
@@ -32,10 +32,6 @@ test_expect_success "GET IPFS path output looks good" '
rm actual
'
test_expect_success
"GET IPFS path on API unavailable"
'
test_curl_resp_http_code "http://127.0.0.1:$apiport/ipfs/$HASH" "HTTP/1.1 404 Not Found"
'
test_expect_success
"GET IPFS directory path succeeds"
'
mkdir dir &&
echo "12345" >dir/test &&
...
...
test/sharness/t0400-api-security.sh
0 → 100755
浏览文件 @
fd971ed9
#!/bin/sh
#
# Copyright (c) 2016 Lars Gierth
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test API security"
.
lib/test-lib.sh
test_init_ipfs
# by default, we don't let you load arbitrary ipfs objects through the api,
# because this would open up the api to scripting vulnerabilities.
# only the webui objects are allowed.
# if you know what you're doing, go ahead and pass --unrestricted-api.
test_launch_ipfs_daemon
test_expect_success
"Gateway on API unavailable"
'
HASH=$(echo "testing" | ipfs add -q)
test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found"
'
test_kill_ipfs_daemon
test_launch_ipfs_daemon
--unrestricted-api
test_expect_success
"Gateway on --unrestricted-api API available"
'
HASH=$(echo "testing" | ipfs add -q)
test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK"
'
test_kill_ipfs_daemon
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论