-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
writing files inside ipns works now! also implemented resolve cli com…
…mand
- Loading branch information
1 parent
006b68b
commit 6080944
Showing
14 changed files
with
144 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" | ||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" | ||
"github.com/jbenet/go-ipfs/core/commands" | ||
"github.com/jbenet/go-ipfs/daemon" | ||
u "github.com/jbenet/go-ipfs/util" | ||
) | ||
|
||
var cmdIpfsResolve = &commander.Command{ | ||
UsageLine: "resolve", | ||
Short: "resolve an ipns link to a hash", | ||
Long: `ipfs resolve <hash>... - Resolve hash. | ||
`, | ||
Run: resolveCmd, | ||
Flag: *flag.NewFlagSet("ipfs-resolve", flag.ExitOnError), | ||
} | ||
|
||
func resolveCmd(c *commander.Command, inp []string) error { | ||
u.Debug = true | ||
if len(inp) < 1 { | ||
u.POut(c.Long) | ||
return nil | ||
} | ||
conf, err := getConfigDir(c.Parent) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd := daemon.NewCommand() | ||
cmd.Command = "resolve" | ||
cmd.Args = inp | ||
err = daemon.SendCommand(cmd, conf) | ||
if err != nil { | ||
now := time.Now() | ||
// Resolve requires working DHT | ||
n, err := localNode(conf, true) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
took := time.Now().Sub(now) | ||
fmt.Printf("localNode creation took %s\n", took.String()) | ||
|
||
return commands.Resolve(n, cmd.Args, cmd.Opts, os.Stdout) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/jbenet/go-ipfs/core" | ||
) | ||
|
||
func Resolve(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error { | ||
res, err := n.Namesys.Resolve(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Fprintf(out, "%s -> %s\n", args[0], res) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package namesys | ||
|
||
type Resolver interface { | ||
// Resolve returns a base58 encoded string | ||
Resolve(string) (string, error) | ||
|
||
Matches(string) bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.