Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
cdc34979
Unverified
Commit
cdc34979
authored
Jun 13, 2018
by
Whyrusleeping
Committed by
GitHub
Jun 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5072 from Bren2010/review/core
Fix panic. Don't handle errors with fallthrough.
parents
aedc3217
8387c394
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
19 deletions
+11
-19
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+1
-1
core/core.go
core/core.go
+0
-1
core/corehttp/commands.go
core/corehttp/commands.go
+2
-2
core/corehttp/gateway_handler.go
core/corehttp/gateway_handler.go
+7
-14
core/corehttp/ipns_hostname.go
core/corehttp/ipns_hostname.go
+1
-1
No files found.
cmd/ipfs/daemon.go
View file @
cdc34979
...
...
@@ -150,7 +150,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
(
"d
efault
"
),
cmdkit
.
StringOption
(
routingOptionKwd
,
"Overrides the routing option"
)
.
WithDefault
(
routingOptionD
efault
Kwd
),
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
View file @
cdc34979
...
...
@@ -154,7 +154,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
View file @
cdc34979
...
...
@@ -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
View file @
cdc34979
...
...
@@ -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
View file @
cdc34979
...
...
@@ -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
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment