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
e3255f46
Commit
e3255f46
authored
Apr 19, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comments from CR
parent
3d80b9d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
core/commands/publish.go
core/commands/publish.go
+7
-1
core/corehttp/ipns_hostname.go
core/corehttp/ipns_hostname.go
+2
-2
path/path.go
path/path.go
+12
-5
No files found.
core/commands/publish.go
View file @
e3255f46
...
...
@@ -107,9 +107,15 @@ Publish an <ipfs-path> to another public key (not implemented):
}
func
publish
(
n
*
core
.
IpfsNode
,
k
crypto
.
PrivKey
,
ref
path
.
Path
)
(
*
IpnsEntry
,
error
)
{
// First, verify the path exists
_
,
err
:=
n
.
Resolver
.
ResolvePath
(
ref
)
if
err
!=
nil
{
return
nil
,
err
}
pub
:=
nsys
.
NewRoutingPublisher
(
n
.
Routing
)
err
:
=
pub
.
Publish
(
n
.
Context
(),
k
,
ref
)
err
=
pub
.
Publish
(
n
.
Context
(),
k
,
ref
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
core/corehttp/ipns_hostname.go
View file @
e3255f46
...
...
@@ -19,8 +19,8 @@ func IPNSHostnameOption() ServeOption {
defer
cancel
()
host
:=
strings
.
SplitN
(
r
.
Host
,
":"
,
2
)[
0
]
if
k
,
err
:=
n
.
Namesys
.
Resolve
(
ctx
,
host
);
err
==
nil
{
r
.
URL
.
Path
=
"/ipfs/"
+
k
.
String
()
+
r
.
URL
.
Path
if
p
,
err
:=
n
.
Namesys
.
Resolve
(
ctx
,
host
);
err
==
nil
{
r
.
URL
.
Path
=
"/ipfs/"
+
p
.
String
()
+
r
.
URL
.
Path
}
childMux
.
ServeHTTP
(
w
,
r
)
})
...
...
path/path.go
View file @
e3255f46
...
...
@@ -49,11 +49,13 @@ func FromSegments(seg ...string) Path {
}
func
ParsePath
(
txt
string
)
(
Path
,
error
)
{
kp
,
err
:=
ParseKeyToPath
(
txt
)
if
err
==
nil
{
return
kp
,
nil
}
parts
:=
strings
.
Split
(
txt
,
"/"
)
if
len
(
parts
)
==
1
{
kp
,
err
:=
ParseKeyToPath
(
txt
)
if
err
==
nil
{
return
kp
,
nil
}
}
if
len
(
parts
)
<
3
{
return
""
,
ErrBadPath
}
...
...
@@ -66,7 +68,7 @@ func ParsePath(txt string) (Path, error) {
return
""
,
ErrBadPath
}
_
,
err
=
ParseKeyToPath
(
parts
[
2
])
_
,
err
:
=
ParseKeyToPath
(
parts
[
2
])
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -86,3 +88,8 @@ func ParseKeyToPath(txt string) (Path, error) {
}
return
FromKey
(
u
.
Key
(
chk
)),
nil
}
func
(
p
*
Path
)
IsValid
()
error
{
_
,
err
:=
ParsePath
(
p
.
String
())
return
err
}
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