Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
8387c394
提交
8387c394
authored
6月 03, 2018
作者:
Brendan McMillion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix panic. Don't handle errors with fallthrough.
License: MIT Signed-off-by:
Brendan McMillion
<
brendan@cloudflare.com
>
上级
f7a98092
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
11 行增加
和
19 行删除
+11
-19
daemon.go
cmd/ipfs/daemon.go
+1
-1
core.go
core/core.go
+0
-1
commands.go
core/corehttp/commands.go
+2
-2
gateway_handler.go
core/corehttp/gateway_handler.go
+7
-14
ipns_hostname.go
core/corehttp/ipns_hostname.go
+1
-1
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
8387c394
...
...
@@ -151,7 +151,7 @@ Headers.
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
initOptionKwd
,
"Initialize ipfs with default settings if not already initialized"
),
cmdkit
.
StringOption
(
initProfileOptionKwd
,
"Configuration profiles to apply for --init. See ipfs init --help for more"
),
cmdkit
.
StringOption
(
routingOptionKwd
,
"Overrides the routing option"
)
.
WithDefault
(
"default"
),
cmdkit
.
StringOption
(
routingOptionKwd
,
"Overrides the routing option"
)
.
WithDefault
(
routingOptionDefaultKwd
),
cmdkit
.
BoolOption
(
mountKwd
,
"Mounts IPFS to the filesystem"
),
cmdkit
.
BoolOption
(
writableKwd
,
"Enable writing objects (with POST, PUT and DELETE)"
),
cmdkit
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."
),
...
...
core/core.go
浏览文件 @
8387c394
...
...
@@ -158,7 +158,6 @@ type Mounts struct {
}
func
(
n
*
IpfsNode
)
startOnlineServices
(
ctx
context
.
Context
,
routingOption
RoutingOption
,
hostOption
HostOption
,
do
DiscoveryOption
,
pubsub
,
ipnsps
,
mplex
bool
)
error
{
if
n
.
PeerHost
!=
nil
{
// already online.
return
errors
.
New
(
"node already online"
)
}
...
...
core/corehttp/commands.go
浏览文件 @
8387c394
...
...
@@ -162,10 +162,10 @@ func CheckVersionOption() ServeOption {
pth
:=
path
.
SplitList
(
cmdqry
)
// backwards compatibility to previous version check
if
pth
[
1
]
!=
"version"
{
if
len
(
pth
)
>=
2
&&
pth
[
1
]
!=
"version"
{
clientVersion
:=
r
.
UserAgent
()
// skips check if client is not go-ipfs
if
clientVersion
!=
""
&&
strings
.
Contains
(
clientVersion
,
"/go-ipfs/"
)
&&
daemonVersion
!=
clientVersion
{
if
strings
.
Contains
(
clientVersion
,
"/go-ipfs/"
)
&&
daemonVersion
!=
clientVersion
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"%s (%s != %s)"
,
errAPIVersionMismatch
,
daemonVersion
,
clientVersion
),
http
.
StatusBadRequest
)
return
}
...
...
core/corehttp/gateway_handler.go
浏览文件 @
8387c394
...
...
@@ -132,7 +132,6 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request)
}
func
(
i
*
gatewayHandler
)
getOrHeadHandler
(
ctx
context
.
Context
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
urlPath
:=
r
.
URL
.
Path
escapedURLPath
:=
r
.
URL
.
EscapedPath
()
...
...
@@ -140,8 +139,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
// the prefix header can be set to signal this sub-path.
// It will be prepended to links in directory listings and the index.html redirect.
prefix
:=
""
if
prefixHdr
:=
r
.
Header
[
"X-Ipfs-Gateway-Prefix"
];
len
(
prefixHdr
)
>
0
{
prfx
:=
prefixHdr
[
0
]
if
prfx
:=
r
.
Header
.
Get
(
"X-Ipfs-Gateway-Prefix"
);
len
(
prfx
)
>
0
{
for
_
,
p
:=
range
i
.
config
.
PathPrefixes
{
if
prfx
==
p
||
strings
.
HasPrefix
(
prfx
,
p
+
"/"
)
{
prefix
=
prfx
...
...
@@ -157,8 +155,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
// the redirects and links would end up as http://example.net/ipns/example.net
originalUrlPath
:=
prefix
+
urlPath
ipnsHostname
:=
false
if
hdr
:=
r
.
Header
[
"X-Ipns-Original-Path"
]
;
len
(
hdr
)
>
0
{
originalUrlPath
=
prefix
+
hdr
[
0
]
if
hdr
:=
r
.
Header
.
Get
(
"X-Ipns-Original-Path"
)
;
len
(
hdr
)
>
0
{
originalUrlPath
=
prefix
+
hdr
ipnsHostname
=
true
}
...
...
@@ -170,15 +168,10 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
// Resolve path to the final DAG node for the ETag
resolvedPath
,
err
:=
i
.
api
.
ResolvePath
(
ctx
,
parsedPath
)
switch
err
{
case
nil
:
case
coreiface
.
ErrOffline
:
if
!
i
.
node
.
OnlineMode
()
{
webError
(
w
,
"ipfs resolve -r "
+
escapedURLPath
,
err
,
http
.
StatusServiceUnavailable
)
return
}
fallthrough
default
:
if
err
==
coreiface
.
ErrOffline
&&
!
i
.
node
.
OnlineMode
()
{
webError
(
w
,
"ipfs resolve -r "
+
escapedURLPath
,
err
,
http
.
StatusServiceUnavailable
)
return
}
else
if
err
!=
nil
{
webError
(
w
,
"ipfs resolve -r "
+
escapedURLPath
,
err
,
http
.
StatusNotFound
)
return
}
...
...
core/corehttp/ipns_hostname.go
浏览文件 @
8387c394
...
...
@@ -26,7 +26,7 @@ func IPNSHostnameOption() ServeOption {
if
len
(
host
)
>
0
&&
isd
.
IsDomain
(
host
)
{
name
:=
"/ipns/"
+
host
if
_
,
err
:=
n
.
Namesys
.
Resolve
(
ctx
,
name
,
nsopts
.
Depth
(
1
));
err
==
nil
{
r
.
Header
[
"X-Ipns-Original-Path"
]
=
[]
string
{
r
.
URL
.
Path
}
r
.
Header
.
Set
(
"X-Ipns-Original-Path"
,
r
.
URL
.
Path
)
r
.
URL
.
Path
=
name
+
r
.
URL
.
Path
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论