Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
fc8e6de6
提交
fc8e6de6
authored
9月 11, 2016
作者:
Lars Gierth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gateway: fix --writable flag :|
License: MIT Signed-off-by:
Lars Gierth
<
larsg@systemli.org
>
上级
0e2b4eb4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
16 行删除
+25
-16
daemon.go
cmd/ipfs/daemon.go
+5
-5
main.go
cmd/ipfswatch/main.go
+1
-7
gateway.go
core/corehttp/gateway.go
+2
-2
gateway_test.go
core/corehttp/gateway_test.go
+1
-1
t0111-gateway-writeable.sh
test/sharness/t0111-gateway-writeable.sh
+15
-0
main.go
test/supernode_client/main.go
+1
-1
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
fc8e6de6
...
...
@@ -409,9 +409,9 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
if
err
!=
nil
{
return
fmt
.
Errorf
(
"serveHTTPApi: Option(%s) failed: %s"
,
unrestrictedApiAccessKwd
,
err
),
nil
}
gatewayOpt
:=
corehttp
.
GatewayOption
(
corehttp
.
WebUIPaths
...
)
gatewayOpt
:=
corehttp
.
GatewayOption
(
false
,
corehttp
.
WebUIPaths
...
)
if
unrestricted
{
gatewayOpt
=
corehttp
.
GatewayOption
(
"/ipfs"
,
"/ipns"
)
gatewayOpt
=
corehttp
.
GatewayOption
(
true
,
"/ipfs"
,
"/ipns"
)
}
var
opts
=
[]
corehttp
.
ServeOption
{
...
...
@@ -480,8 +480,8 @@ func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
if
err
!=
nil
{
return
fmt
.
Errorf
(
"serveHTTPGateway: req.Option(%s) failed: %s"
,
writableKwd
,
err
),
nil
}
if
writableOptionFound
{
cfg
.
Gateway
.
Writable
=
w
ritable
if
!
writableOptionFound
{
writable
=
cfg
.
Gateway
.
W
ritable
}
gwLis
,
err
:=
manet
.
Listen
(
gatewayMaddr
)
...
...
@@ -502,7 +502,7 @@ func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
corehttp
.
CommandsROOption
(
*
req
.
InvocContext
()),
corehttp
.
VersionOption
(),
corehttp
.
IPNSHostnameOption
(),
corehttp
.
GatewayOption
(
"/ipfs"
,
"/ipns"
),
corehttp
.
GatewayOption
(
writable
,
"/ipfs"
,
"/ipns"
),
}
if
len
(
cfg
.
Gateway
.
RootRedirect
)
>
0
{
...
...
cmd/ipfswatch/main.go
浏览文件 @
fc8e6de6
...
...
@@ -81,16 +81,10 @@ func run(ipfsPath, watchPath string) error {
}
defer
node
.
Close
()
cfg
,
err
:=
node
.
Repo
.
Config
()
if
err
!=
nil
{
return
err
}
cfg
.
Gateway
.
Writable
=
true
if
*
http
{
addr
:=
"/ip4/127.0.0.1/tcp/5001"
var
opts
=
[]
corehttp
.
ServeOption
{
corehttp
.
GatewayOption
(
"/ipfs"
,
"/ipns"
),
corehttp
.
GatewayOption
(
true
,
"/ipfs"
,
"/ipns"
),
corehttp
.
WebUIOption
,
corehttp
.
CommandsOption
(
cmdCtx
(
node
,
ipfsPath
)),
}
...
...
core/corehttp/gateway.go
浏览文件 @
fc8e6de6
...
...
@@ -16,7 +16,7 @@ type GatewayConfig struct {
PathPrefixes
[]
string
}
func
GatewayOption
(
paths
...
string
)
ServeOption
{
func
GatewayOption
(
writable
bool
,
paths
...
string
)
ServeOption
{
return
func
(
n
*
core
.
IpfsNode
,
_
net
.
Listener
,
mux
*
http
.
ServeMux
)
(
*
http
.
ServeMux
,
error
)
{
cfg
,
err
:=
n
.
Repo
.
Config
()
if
err
!=
nil
{
...
...
@@ -25,7 +25,7 @@ func GatewayOption(paths ...string) ServeOption {
gateway
:=
newGatewayHandler
(
n
,
GatewayConfig
{
Headers
:
cfg
.
Gateway
.
HTTPHeaders
,
Writable
:
cfg
.
Gateway
.
W
ritable
,
Writable
:
w
ritable
,
PathPrefixes
:
cfg
.
Gateway
.
PathPrefixes
,
})
...
...
core/corehttp/gateway_test.go
浏览文件 @
fc8e6de6
...
...
@@ -104,7 +104,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core
ts
.
Listener
,
VersionOption
(),
IPNSHostnameOption
(),
GatewayOption
(
"/ipfs"
,
"/ipns"
),
GatewayOption
(
false
,
"/ipfs"
,
"/ipns"
),
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
test/sharness/t0111-gateway-writeable.sh
浏览文件 @
fc8e6de6
...
...
@@ -9,7 +9,22 @@ test_description="Test HTTP Gateway (Writable)"
.
lib/test-lib.sh
test_init_ipfs
test_launch_ipfs_daemon
--writable
test_expect_success
"ipfs daemon --writable overrides config"
'
curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
grep "HTTP/1.1 201 Created" outfile &&
grep "Location: /ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" outfile
'
test_kill_ipfs_daemon
test_config_ipfs_gateway_writable
test_launch_ipfs_daemon
--writable
=
false
test_expect_success
"ipfs daemon --writable=false overrides Writable=true config"
'
curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
grep "HTTP/1.1 405 Method Not Allowed" outfile
'
test_kill_ipfs_daemon
test_launch_ipfs_daemon
port
=
$GWAY_PORT
...
...
test/supernode_client/main.go
浏览文件 @
fc8e6de6
...
...
@@ -109,7 +109,7 @@ func run() error {
opts
:=
[]
corehttp
.
ServeOption
{
corehttp
.
CommandsOption
(
cmdCtx
(
node
,
repoPath
)),
corehttp
.
GatewayOption
(),
corehttp
.
GatewayOption
(
false
),
}
if
*
cat
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论