fix cast panic in ipfs name resolve when daemon is running Addresses bug #689
fix cast panic in ipfs name resolve when daemon is running Addresses bug #689
Jeromy committed
Jan 31, 2015 at 23:31 UTC
b57ba192e68817b3bfbfd871f06983b8937f7458
1 file changed
+11
-3
core/commands/resolve.go
+11
-3
@@ -9,6 +9,10 @@ import (
9
u "github.com/jbenet/go-ipfs/util"
10
)
11
12
+type ResolvedKey struct {
13
+ Key u.Key
14
+}
15
+
16
var resolveCmd = &cmds.Command{
17
Helptext: cmds.HelpText{
18
Tagline: "Gets the value currently published at an IPNS name",
@@ -78,12 +82,16 @@ Resolve te value of another name:
82
83
// TODO: better errors (in the case of not finding the name, we get "failed to find any peer in table")
84
81
- res.SetOutput(output)
85
+ res.SetOutput(&ResolvedKey{output})
86
},
87
Marshalers: cmds.MarshalerMap{
88
cmds.Text: func(res cmds.Response) (io.Reader, error) {
85
- output := res.Output().(u.Key)
86
- return strings.NewReader(output.B58String()), nil
89
+ output, ok := res.Output().(*ResolvedKey)
90
+ if !ok {
91
+ return nil, u.ErrCast()
92
+ }
93
+ return strings.NewReader(output.Key.B58String()), nil
94
},
95
},
96
+ Type: ResolvedKey{},
97
}