Documentation ¶
Index ¶
- Variables
- func CommandsCmd(root *cmds.Command) *cmds.Command
- func KeyListTextMarshaler(res cmds.Response) (io.Reader, error)
- func MessageTextMarshaler(res cmds.Response) (io.Reader, error)
- func Mount(node *core.IpfsNode, fsdir, nsdir string) error
- func ParsePeerParam(text string) (ma.Multiaddr, peer.ID, error)
- type AddedObject
- type BlockStat
- type BootstrapOutput
- type Command
- type ConfigField
- type DiagnosticConnection
- type DiagnosticOutput
- type DiagnosticPeer
- type ErrPassThroughReader
- type IdOutput
- type IpnsEntry
- type KeyList
- type Link
- type LsOutput
- type MessageOutput
- type Node
- type Object
- type PinOutput
- type PingResult
- type RefWriter
- type ResolvedKey
- type TestOutput
- type UpdateOutput
- type VersionOutput
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Add an object to ipfs.", ShortDescription: ` Adds contents of <path> to ipfs. Use -r to add directories. Note that directories are added recursively, to form the ipfs MerkleDAG. A smarter partial add with a staging area (like git) remains to be implemented. `, }, Arguments: []cmds.Argument{ cmds.FileArg("path", true, true, "The path to a file to be added to IPFS").EnableRecursive().EnableStdin(), }, Options: []cmds.Option{ cmds.OptionRecursivePath, cmds.BoolOption("quiet", "q", "Write minimal output"), cmds.BoolOption(progressOptionName, "p", "Stream progress data"), cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object"), cmds.BoolOption("t", "trickle", "Use trickle-dag format for dag generation"), }, PreRun: func(req cmds.Request) error { if quiet, _, _ := req.Option("quiet").Bool(); quiet { return nil } req.SetOption(progressOptionName, true) sizeFile, ok := req.Files().(files.SizeFile) if !ok { return nil } size, err := sizeFile.Size() if err != nil { return nil } log.Debugf("Total size of file being added: %v\n", size) req.Values()["size"] = size return nil }, Run: func(req cmds.Request, res cmds.Response) { n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } progress, _, _ := req.Option(progressOptionName).Bool() wrap, _, _ := req.Option(wrapOptionName).Bool() outChan := make(chan interface{}) res.SetOutput((<-chan interface{})(outChan)) go func() { defer close(outChan) for { file, err := req.Files().NextFile() if (err != nil && err != io.EOF) || file == nil { return } _, err = addFile(n, file, outChan, progress, wrap) if err != nil { return } } }() }, PostRun: func(req cmds.Request, res cmds.Response) { if res.Error() != nil { return } outChan, ok := res.Output().(<-chan interface{}) if !ok { res.SetError(u.ErrCast(), cmds.ErrNormal) return } res.SetOutput(nil) quiet, _, err := req.Option("quiet").Bool() if err != nil { res.SetError(u.ErrCast(), cmds.ErrNormal) return } size := int64(0) s, found := req.Values()["size"] if found { size = s.(int64) } showProgressBar := !quiet && size >= progressBarMinSize var bar *pb.ProgressBar var terminalWidth int if showProgressBar { bar = pb.New64(size).SetUnits(pb.U_BYTES) bar.ManualUpdate = true bar.Start() terminalWidth = 0 bar.Callback = func(line string) { terminalWidth = len(line) bar.Callback = nil bar.Output = res.Stderr() log.Infof("terminal width: %v\n", terminalWidth) } bar.Update() } lastFile := "" var totalProgress, prevFiles, lastBytes int64 for out := range outChan { output := out.(*AddedObject) if len(output.Hash) > 0 { if showProgressBar { fmt.Fprintf(res.Stderr(), "\r%s\r", strings.Repeat(" ", terminalWidth)) } if quiet { fmt.Fprintf(res.Stdout(), "%s\n", output.Hash) } else { fmt.Fprintf(res.Stdout(), "added %s %s\n", output.Hash, output.Name) } } else { log.Debugf("add progress: %v %v\n", output.Name, output.Bytes) if !showProgressBar { continue } if len(lastFile) == 0 { lastFile = output.Name } if output.Name != lastFile || output.Bytes < lastBytes { prevFiles += lastBytes lastFile = output.Name } lastBytes = output.Bytes delta := prevFiles + lastBytes - totalProgress totalProgress = bar.Add64(delta) } if showProgressBar { bar.Update() } } }, Type: AddedObject{}, }
View Source
var BlockCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Manipulate raw IPFS blocks", ShortDescription: ` 'ipfs block' is a plumbing command used to manipulate raw ipfs blocks. Reads from stdin or writes to stdout, and <key> is a base58 encoded multihash. `, }, Subcommands: map[string]*cmds.Command{ "stat": blockStatCmd, "get": blockGetCmd, "put": blockPutCmd, }, }
View Source
var BootstrapCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Show or edit the list of bootstrap peers", Synopsis: ` ipfs bootstrap list - Show peers in the bootstrap list ipfs bootstrap add <peer>... - Add peers to the bootstrap list ipfs bootstrap rm <peer>... - Removes peers from the bootstrap list `, ShortDescription: ` Running 'ipfs bootstrap' with no arguments will run 'ipfs bootstrap list'. ` + bootstrapSecurityWarning, }, Run: bootstrapListCmd.Run, Marshalers: bootstrapListCmd.Marshalers, Type: bootstrapListCmd.Type, Subcommands: map[string]*cmds.Command{ "list": bootstrapListCmd, "add": bootstrapAddCmd, "rm": bootstrapRemoveCmd, }, }
View Source
var CatCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Show IPFS object data", ShortDescription: ` Retrieves the object named by <ipfs-path> and outputs the data it contains. `, }, Arguments: []cmds.Argument{ cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted").EnableStdin(), }, Run: func(req cmds.Request, res cmds.Response) { node, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } readers, length, err := cat(req.Context().Context, node, req.Arguments()) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetLength(length) reader := io.MultiReader(readers...) res.SetOutput(reader) }, PostRun: func(req cmds.Request, res cmds.Response) { if res.Length() < progressBarMinSize { return } bar := pb.New(int(res.Length())).SetUnits(pb.U_BYTES) bar.Output = res.Stderr() bar.Start() reader := bar.NewProxyReader(res.Output().(io.Reader)) res.SetOutput(reader) }, }
View Source
var CommandsDaemonCmd = CommandsCmd(Root)
commandsDaemonCmd is the "ipfs commands" command for daemon
View Source
var ConfigCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "get and set IPFS config values", Synopsis: ` ipfs config <key> - Get value of <key> ipfs config <key> <value> - Set value of <key> to <value> ipfs config show - Show config file ipfs config edit - Edit config file in $EDITOR ipfs config replace <file> - Replaces the config file with <file> `, ShortDescription: ` ipfs config controls configuration variables. It works like 'git config'. The configuration values are stored in a config file inside your IPFS repository.`, LongDescription: ` ipfs config controls configuration variables. It works much like 'git config'. The configuration values are stored in a config file inside your IPFS repository. EXAMPLES: Get the value of the 'datastore.path' key: ipfs config datastore.path Set the value of the 'datastore.path' key: ipfs config datastore.path ~/.go-ipfs/datastore `, }, Arguments: []cmds.Argument{ cmds.StringArg("key", true, false, "The key of the config entry (e.g. \"Addresses.API\")"), cmds.StringArg("value", false, false, "The value to set the config entry to"), }, Options: []cmds.Option{ cmds.BoolOption("bool", "Set a boolean value"), }, Run: func(req cmds.Request, res cmds.Response) { args := req.Arguments() key := args[0] r := fsrepo.At(req.Context().ConfigRoot) if err := r.Open(); err != nil { res.SetError(err, cmds.ErrNormal) return } defer r.Close() var err error var output *ConfigField if len(args) == 2 { value := args[1] if isbool, _, _ := req.Option("bool").Bool(); isbool { output, err = setConfig(r, key, value == "true") } else { output, err = setConfig(r, key, value) } } else { output, err = getConfig(r, key) } if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { if len(res.Request().Arguments()) == 2 { return nil, nil } v := res.Output() if v == nil { k := res.Request().Arguments()[0] return nil, fmt.Errorf("config does not contain key: %s", k) } vf, ok := v.(*ConfigField) if !ok { return nil, u.ErrCast() } buf, err := config.HumanOutput(vf.Value) if err != nil { return nil, err } buf = append(buf, byte('\n')) return bytes.NewReader(buf), nil }, }, Type: ConfigField{}, Subcommands: map[string]*cmds.Command{ "show": configShowCmd, "edit": configEditCmd, "replace": configReplaceCmd, }, }
View Source
var DefaultDiagnosticTimeout = time.Second * 20
View Source
var DhtCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Issue commands directly through the DHT", ShortDescription: ``, }, Subcommands: map[string]*cmds.Command{ "query": queryDhtCmd, "findprovs": findProvidersDhtCmd, "findpeer": findPeerDhtCmd, "get": getValueDhtCmd, "put": putValueDhtCmd, }, }
View Source
var DiagCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Generates diagnostic reports", }, Subcommands: map[string]*cmds.Command{ "net": diagNetCmd, }, }
View Source
var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")
Error indicating the max depth has been exceded.
View Source
var ErrInvalidCompressionLevel = errors.New("Compression level must be between 1 and 9")
View Source
var ErrNotDHT = errors.New("routing service is not a DHT")
View Source
var ErrObjectTooLarge = errors.New("input object was too large. limit is 512kbytes")
ErrObjectTooLarge is returned when too much data was read from stdin. current limit 512k
View Source
var ErrUnknownObjectEnc = errors.New("unknown object encoding")
ErrUnknownObjectEnc is returned if a invalid encoding is supplied
View Source
var GetCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Download IPFS objects", ShortDescription: ` Retrieves the object named by <ipfs-path> and stores the data to disk. By default, the output will be stored at ./<ipfs-path>, but an alternate path can be specified with '--output=<path>' or '-o=<path>'. To output a TAR archive instead of unpacked files, use '--archive' or '-a'. To compress the output with GZIP compression, use '--compress' or '-C'. You may also specify the level of compression by specifying '-l=<1-9>'. `, }, Arguments: []cmds.Argument{ cmds.StringArg("ipfs-path", true, false, "The path to the IPFS object(s) to be outputted").EnableStdin(), }, Options: []cmds.Option{ cmds.StringOption("output", "o", "The path where output should be stored"), cmds.BoolOption("archive", "a", "Output a TAR archive"), cmds.BoolOption("compress", "C", "Compress the output with GZIP compression"), cmds.IntOption("compression-level", "l", "The level of compression (1-9)"), }, PreRun: func(req cmds.Request) error { _, err := getCompressOptions(req) return err }, Run: func(req cmds.Request, res cmds.Response) { cmplvl, err := getCompressOptions(req) if err != nil { res.SetError(err, cmds.ErrClient) return } node, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } reader, err := get(node, req.Arguments()[0], cmplvl) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(reader) }, PostRun: func(req cmds.Request, res cmds.Response) { if res.Output() == nil { return } outReader := res.Output().(io.Reader) res.SetOutput(nil) outPath, _, _ := req.Option("output").String() if len(outPath) == 0 { _, outPath = gopath.Split(req.Arguments()[0]) outPath = gopath.Clean(outPath) } cmplvl, err := getCompressOptions(req) if err != nil { res.SetError(err, cmds.ErrClient) return } if archive, _, _ := req.Option("archive").Bool(); archive { if !strings.HasSuffix(outPath, ".tar") { outPath += ".tar" } if cmplvl != gzip.NoCompression { outPath += ".gz" } fmt.Printf("Saving archive to %s\n", outPath) file, err := os.Create(outPath) if err != nil { res.SetError(err, cmds.ErrNormal) return } defer file.Close() bar := pb.New(0).SetUnits(pb.U_BYTES) bar.Output = os.Stderr pbReader := bar.NewProxyReader(outReader) bar.Start() defer bar.Finish() _, err = io.Copy(file, pbReader) if err != nil { res.SetError(err, cmds.ErrNormal) return } return } fmt.Printf("Saving file(s) to %s\n", outPath) bar := pb.New(0).SetUnits(pb.U_BYTES) bar.Output = os.Stderr // wrap the reader with the progress bar proxy reader // if the output is compressed, also wrap it in a gzip.Reader var reader io.Reader if cmplvl != gzip.NoCompression { gzipReader, err := gzip.NewReader(outReader) if err != nil { res.SetError(err, cmds.ErrNormal) return } defer gzipReader.Close() reader = bar.NewProxyReader(gzipReader) } else { reader = bar.NewProxyReader(outReader) } bar.Start() defer bar.Finish() extractor := &tar.Extractor{outPath} err = extractor.Extract(reader) if err != nil { res.SetError(err, cmds.ErrNormal) } }, }
View Source
var IDCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Show IPFS Node ID info", ShortDescription: ` Prints out information about the specified peer, if no peer is specified, prints out local peers info. ipfs id supports the format option for output with the following keys: <id> : the peers id <aver>: agent version <pver>: protocol version <pubkey>: public key `, }, Arguments: []cmds.Argument{ cmds.StringArg("peerid", false, false, "peer.ID of node to look up").EnableStdin(), }, Options: []cmds.Option{ cmds.StringOption("f", "format", "optional output format"), }, Run: func(req cmds.Request, res cmds.Response) { node, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } if len(req.Arguments()) == 0 { output, err := printSelf(node) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) return } pid := req.Arguments()[0] id := peer.ID(b58.Decode(pid)) if len(id) == 0 { res.SetError(cmds.ClientError("Invalid peer id"), cmds.ErrClient) return } ctx, _ := context.WithTimeout(context.TODO(), time.Second*5) if !node.OnlineMode() { res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient) return } p, err := node.Routing.FindPeer(ctx, id) if err == kb.ErrLookupFailure { res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient) return } if err != nil { res.SetError(err, cmds.ErrNormal) return } output, err := printPeer(node.Peerstore, p.ID) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { val, ok := res.Output().(*IdOutput) if !ok { return nil, u.ErrCast() } format, found, err := res.Request().Option("format").String() if err != nil { return nil, err } if found { output := format output = strings.Replace(output, "<id>", val.ID, -1) output = strings.Replace(output, "<aver>", val.AgentVersion, -1) output = strings.Replace(output, "<pver>", val.ProtocolVersion, -1) output = strings.Replace(output, "<pubkey>", val.PublicKey, -1) return strings.NewReader(output), nil } else { marshaled, err := json.MarshalIndent(val, "", "\t") if err != nil { return nil, err } return bytes.NewReader(marshaled), nil } }, }, Type: IdOutput{}, }
View Source
var LogCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Interact with the daemon log output", ShortDescription: ` 'ipfs log' contains utility commands to affect or read the logging output of a running daemon. `, }, Subcommands: map[string]*cmds.Command{ "level": logLevelCmd, "tail": logTailCmd, }, }
View Source
var LsCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "List links from an object.", ShortDescription: ` Retrieves the object named by <ipfs-path> and displays the links it contains, with the following format: <link base58 hash> <link size in bytes> <link name> `, }, Arguments: []cmds.Argument{ cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from").EnableStdin(), }, Run: func(req cmds.Request, res cmds.Response) { node, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } paths := req.Arguments() dagnodes := make([]*merkledag.Node, 0) for _, fpath := range paths { dagnode, err := node.Resolver.ResolvePath(path.Path(fpath)) if err != nil { res.SetError(err, cmds.ErrNormal) return } dagnodes = append(dagnodes, dagnode) } output := make([]Object, len(req.Arguments())) for i, dagnode := range dagnodes { output[i] = Object{ Hash: paths[i], Links: make([]Link, len(dagnode.Links)), } for j, link := range dagnode.Links { output[i].Links[j] = Link{ Name: link.Name, Hash: link.Hash.B58String(), Size: link.Size, } } } res.SetOutput(&LsOutput{output}) }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { s := "" output := res.Output().(*LsOutput).Objects for _, object := range output { if len(output) > 1 { s += fmt.Sprintf("%s:\n", object.Hash) } s += marshalLinks(object.Links) if len(output) > 1 { s += "\n" } } return strings.NewReader(s), nil }, }, Type: LsOutput{}, }
View Source
var MountCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Mounts IPFS to the filesystem (read-only)", Synopsis: ` ipfs mount [-f <ipfs mount path>] [-n <ipns mount path>] `, ShortDescription: ` Mount ipfs at a read-only mountpoint on the OS (default: /ipfs and /ipns). All ipfs objects will be accessible under that directory. Note that the root will not be listable, as it is virtual. Access known paths directly. You may have to create /ipfs and /ipfs before using 'ipfs mount': > sudo mkdir /ipfs /ipns > sudo chown ` + "`" + `whoami` + "`" + ` /ipfs /ipns > ipfs daemon & > ipfs mount `, LongDescription: ` Mount ipfs at a read-only mountpoint on the OS (default: /ipfs and /ipns). All ipfs objects will be accessible under that directory. Note that the root will not be listable, as it is virtual. Access known paths directly. You may have to create /ipfs and /ipfs before using 'ipfs mount': > sudo mkdir /ipfs /ipns > sudo chown ` + "`" + `whoami` + "`" + ` /ipfs /ipns > ipfs daemon & > ipfs mount EXAMPLE: # setup > mkdir foo > echo "baz" > foo/bar > ipfs add -r foo added QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR foo/bar added QmSh5e7S6fdcu75LAbXNZAFY2nGyZUJXyLCJDvn2zRkWyC foo > ipfs ls QmSh5e7S6fdcu75LAbXNZAFY2nGyZUJXyLCJDvn2zRkWyC QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR 12 bar > ipfs cat QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR baz # mount > ipfs daemon & > ipfs mount IPFS mounted at: /ipfs IPNS mounted at: /ipns > cd /ipfs/QmSh5e7S6fdcu75LAbXNZAFY2nGyZUJXyLCJDvn2zRkWyC > ls bar > cat bar baz > cat /ipfs/QmSh5e7S6fdcu75LAbXNZAFY2nGyZUJXyLCJDvn2zRkWyC/bar baz > cat /ipfs/QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR baz `, }, Options: []cmds.Option{ cmds.StringOption("f", "The path where IPFS should be mounted"), cmds.StringOption("n", "The path where IPNS should be mounted"), }, Run: func(req cmds.Request, res cmds.Response) { cfg, err := req.Context().GetConfig() if err != nil { res.SetError(err, cmds.ErrNormal) return } node, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } if !node.OnlineMode() { res.SetError(errNotOnline, cmds.ErrClient) return } fsdir, found, err := req.Option("f").String() if err != nil { res.SetError(err, cmds.ErrNormal) return } if !found { fsdir = cfg.Mounts.IPFS } nsdir, found, err := req.Option("n").String() if err != nil { res.SetError(err, cmds.ErrNormal) return } if !found { nsdir = cfg.Mounts.IPNS } err = Mount(node, fsdir, nsdir) if err != nil { res.SetError(err, cmds.ErrNormal) return } var output config.Mounts output.IPFS = fsdir output.IPNS = nsdir res.SetOutput(&output) }, Type: config.Mounts{}, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { v := res.Output().(*config.Mounts) s := fmt.Sprintf("IPFS mounted at: %s\n", v.IPFS) s += fmt.Sprintf("IPNS mounted at: %s\n", v.IPNS) return strings.NewReader(s), nil }, }, }
View Source
var NameCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "IPFS namespace (IPNS) tool", Synopsis: ` ipfs name publish [<name>] <ipfs-path> - Publish an object to IPNS ipfs name resolve [<name>] - Gets the value currently published at an IPNS name `, ShortDescription: ` IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In both publish and resolve, the default value of <name> is your own identity public key. `, LongDescription: ` IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In both publish and resolve, the default value of <name> is your own identity public key. Examples: Publish a <ref> to your identity name: > ipfs name publish QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy published name QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n to QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Publish a <ref> to another public key: > ipfs name publish QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy published name QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n to QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Resolve the value of your identity: > ipfs name resolve QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Resolve the value of another name: > ipfs name resolve QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy `, }, Subcommands: map[string]*cmds.Command{ "publish": publishCmd, "resolve": resolveCmd, }, }
View Source
var ObjectCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Interact with ipfs objects", ShortDescription: ` 'ipfs object' is a plumbing command used to manipulate DAG objects directly.`, Synopsis: ` ipfs object get <key> - Get the DAG node named by <key> ipfs object put <data> <encoding> - Stores input, outputs its key ipfs object data <key> - Outputs raw bytes in an object ipfs object links <key> - Outputs links pointed to by object ipfs object stat <key> - Outputs statistics of object `, }, Subcommands: map[string]*cmds.Command{ "data": objectDataCmd, "links": objectLinksCmd, "get": objectGetCmd, "put": objectPutCmd, "stat": objectStatCmd, }, }
View Source
var PinCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Pin (and unpin) objects to local storage", }, Subcommands: map[string]*cmds.Command{ "add": addPinCmd, "rm": rmPinCmd, "ls": listPinCmd, }, }
View Source
var PingCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "send echo request packets to IPFS hosts", Synopsis: ` Send pings to a peer using the routing system to discover its address `, ShortDescription: ` ipfs ping is a tool to test sending data to other nodes. It finds nodes via the routing system, send pings, wait for pongs, and print out round- trip latency information. `, }, Arguments: []cmds.Argument{ cmds.StringArg("peer ID", true, true, "ID of peer to be pinged").EnableStdin(), }, Options: []cmds.Option{ cmds.IntOption("count", "n", "number of ping messages to send"), }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { outChan, ok := res.Output().(<-chan interface{}) if !ok { fmt.Println(reflect.TypeOf(res.Output())) return nil, u.ErrCast() } marshal := func(v interface{}) (io.Reader, error) { obj, ok := v.(*PingResult) if !ok { return nil, u.ErrCast() } buf := new(bytes.Buffer) if len(obj.Text) > 0 { buf = bytes.NewBufferString(obj.Text + "\n") } else if obj.Success { fmt.Fprintf(buf, "Pong received: time=%.2f ms\n", obj.Time.Seconds()*1000) } else { fmt.Fprintf(buf, "Pong failed\n") } return buf, nil } return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, }, nil }, }, Run: func(req cmds.Request, res cmds.Response) { ctx := req.Context().Context n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } if !n.OnlineMode() { res.SetError(errNotOnline, cmds.ErrClient) return } addr, peerID, err := ParsePeerParam(req.Arguments()[0]) if err != nil { res.SetError(err, cmds.ErrNormal) return } if addr != nil { n.Peerstore.AddAddr(peerID, addr, peer.TempAddrTTL) } numPings := 10 val, found, err := req.Option("count").Int() if err != nil { res.SetError(err, cmds.ErrNormal) return } if found { numPings = val } outChan := pingPeer(ctx, n, peerID, numPings) res.SetOutput(outChan) }, Type: PingResult{}, }
View Source
var RefsCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Lists links (references) from an object", ShortDescription: ` Retrieves the object named by <ipfs-path> and displays the link hashes it contains, with the following format: <link base58 hash> Note: list all refs recursively with -r. `, }, Subcommands: map[string]*cmds.Command{ "local": RefsLocalCmd, }, Arguments: []cmds.Argument{ cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from").EnableStdin(), }, Options: []cmds.Option{ cmds.StringOption("format", "Emit edges with given format. tokens: <src> <dst> <linkname>"), cmds.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`"), cmds.BoolOption("unique", "u", "Omit duplicate refs from output"), cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"), }, Run: func(req cmds.Request, res cmds.Response) { ctx := req.Context().Context n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } unique, _, err := req.Option("unique").Bool() if err != nil { res.SetError(err, cmds.ErrNormal) return } recursive, _, err := req.Option("recursive").Bool() if err != nil { res.SetError(err, cmds.ErrNormal) return } edges, _, err := req.Option("edges").Bool() if err != nil { res.SetError(err, cmds.ErrNormal) return } format, _, err := req.Option("format").String() if err != nil { res.SetError(err, cmds.ErrNormal) return } objs, err := objectsForPaths(n, req.Arguments()) if err != nil { res.SetError(err, cmds.ErrNormal) return } piper, pipew := io.Pipe() eptr := &ErrPassThroughReader{R: piper} go func() { defer pipew.Close() rw := RefWriter{ W: pipew, DAG: n.DAG, Ctx: ctx, Unique: unique, PrintEdge: edges, PrintFmt: format, Recursive: recursive, } for _, o := range objs { if _, err := rw.WriteRefs(o); err != nil { eptr.SetError(err) return } } }() res.SetOutput(eptr) }, }
View Source
var RefsLocalCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Lists all local references", ShortDescription: ` Displays the hashes of all local objects. `, }, Run: func(req cmds.Request, res cmds.Response) { ctx := req.Context().Context n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } allKeys, err := n.Blockstore.AllKeysChan(ctx) if err != nil { res.SetError(err, cmds.ErrNormal) return } piper, pipew := io.Pipe() eptr := &ErrPassThroughReader{R: piper} go func() { defer pipew.Close() for k := range allKeys { s := k.Pretty() + "\n" if _, err := pipew.Write([]byte(s)); err != nil { eptr.SetError(err) return } } }() res.SetOutput(eptr) }, }
View Source
var RepoCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Manipulate the IPFS repo", ShortDescription: ` 'ipfs repo' is a plumbing command used to manipulate the repo. `, }, Subcommands: map[string]*cmds.Command{ "gc": repoGcCmd, }, }
View Source
var Root = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "global p2p merkle-dag filesystem", Synopsis: ` ipfs [<flags>] <command> [<arg>] ... `, ShortDescription: ` BASIC COMMANDS init Initialize ipfs local configuration add <path> Add an object to ipfs cat <ref> Show ipfs object data get <ref> Download ipfs objects ls <ref> List links from an object refs <ref> List hashes of links from an object DATA STRUCTURE COMMANDS block Interact with raw blocks in the datastore object Interact with raw dag nodes ADVANCED COMMANDS daemon Start a long-running daemon process mount Mount an ipfs read-only mountpoint name Publish or resolve IPNS names pin Pin objects to local storage gc Garbage collect unpinned objects NETWORK COMMANDS id Show info about ipfs peers bootstrap Add or remove bootstrap peers swarm Manage connections to the p2p network dht Query the dht for values or peers ping Measure the latency of a connection diag Print diagnostics TOOL COMMANDS config Manage configuration version Show ipfs version information update Download and apply go-ipfs updates commands List all available commands Use 'ipfs <command> --help' to learn more about each command. `, }, Options: []cmds.Option{ cmds.StringOption("config", "c", "Path to the configuration file to use"), cmds.BoolOption("debug", "D", "Operate in debug mode"), cmds.BoolOption("help", "Show the full command help text"), cmds.BoolOption("h", "Show a short version of the command help text"), cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"), }, }
View Source
var SwarmCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "swarm inspection tool", Synopsis: ` ipfs swarm peers - List peers with open connections ipfs swarm addrs - List known addresses. Useful to debug. ipfs swarm connect <address> - Open connection to a given address ipfs swarm disconnect <address> - Close connection to a given address `, ShortDescription: ` ipfs swarm is a tool to manipulate the network swarm. The swarm is the component that opens, listens for, and maintains connections to other ipfs peers in the internet. `, }, Subcommands: map[string]*cmds.Command{ "peers": swarmPeersCmd, "addrs": swarmAddrsCmd, "connect": swarmConnectCmd, "disconnect": swarmDisconnectCmd, }, }
View Source
var UpdateCheckCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Checks if updates are available", ShortDescription: "'ipfs update check' checks if any updates are available for IPFS.\nNothing will be downloaded or installed.", }, Run: func(req cmds.Request, res cmds.Response) { n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } output, err := updateCheck(n) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) }, Type: UpdateOutput{}, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { v := res.Output().(*UpdateOutput) var buf bytes.Buffer if v.NewVersion != v.OldVersion { buf.WriteString(fmt.Sprintf("A new version of IPFS is available ('%s', currently running '%s')\n", v.NewVersion, v.OldVersion)) } else { buf.WriteString(fmt.Sprintf("Already updated to latest version ('%s')\n", v.NewVersion)) } return &buf, nil }, }, }
View Source
var UpdateCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Downloads and installs updates for IPFS", ShortDescription: "ipfs update is a utility command used to check for updates and apply them.", }, Run: func(req cmds.Request, res cmds.Response) { n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } output, err := updateApply(n) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) }, Type: UpdateOutput{}, Subcommands: map[string]*cmds.Command{ "check": UpdateCheckCmd, "log": UpdateLogCmd, }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { v := res.Output().(*UpdateOutput) var buf bytes.Buffer if v.NewVersion != v.OldVersion { buf.WriteString(fmt.Sprintf("Successfully updated to IPFS version '%s' (from '%s')\n", v.NewVersion, v.OldVersion)) } else { buf.WriteString(fmt.Sprintf("Already updated to latest version ('%s')\n", v.NewVersion)) } return &buf, nil }, }, }
View Source
var UpdateLogCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "List the changelog for the latest versions of IPFS", ShortDescription: "This command is not yet implemented.", }, Run: func(req cmds.Request, res cmds.Response) { n, err := req.Context().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) return } output, err := updateLog(n) if err != nil { res.SetError(err, cmds.ErrNormal) return } res.SetOutput(output) }, }
View Source
var VersionCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Shows ipfs version information", ShortDescription: "Returns the current version of ipfs and exits.", }, Options: []cmds.Option{ cmds.BoolOption("number", "n", "Only show the version number"), }, Run: func(req cmds.Request, res cmds.Response) { res.SetOutput(&VersionOutput{ Version: config.CurrentVersionNumber, }) }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { v := res.Output().(*VersionOutput) number, found, err := res.Request().Option("number").Bool() if err != nil { return nil, err } if found && number { return strings.NewReader(fmt.Sprintln(v.Version)), nil } return strings.NewReader(fmt.Sprintf("ipfs version %s\n", v.Version)), nil }, }, Type: VersionOutput{}, }
Functions ¶
func CommandsCmd ¶
CommandsCmd takes in a root command, and returns a command that lists the subcommands in that root
func KeyListTextMarshaler ¶
KeyListTextMarshaler outputs a KeyList as plaintext, one key per line
Types ¶
type AddedObject ¶
type BootstrapOutput ¶
type BootstrapOutput struct {
Peers []string
}
type ConfigField ¶
type ConfigField struct { Key string Value interface{} }
type DiagnosticConnection ¶
type DiagnosticOutput ¶
type DiagnosticOutput struct {
Peers []DiagnosticPeer
}
type DiagnosticPeer ¶
type DiagnosticPeer struct { ID string UptimeSeconds uint64 BandwidthBytesIn uint64 BandwidthBytesOut uint64 Connections []DiagnosticConnection }
type ErrPassThroughReader ¶
type ErrPassThroughReader struct { R io.ReadCloser sync.RWMutex // contains filtered or unexported fields }
ErrPassThroughReader is a reader that may return an externally set error.
func (*ErrPassThroughReader) Close ¶
func (r *ErrPassThroughReader) Close() error
func (*ErrPassThroughReader) Error ¶
func (r *ErrPassThroughReader) Error() error
func (*ErrPassThroughReader) SetError ¶
func (r *ErrPassThroughReader) SetError(err error)
type MessageOutput ¶
type MessageOutput struct {
Message string
}
type RefWriter ¶
type RefWriter struct { W io.Writer DAG dag.DAGService Ctx context.Context Unique bool Recursive bool PrintEdge bool PrintFmt string // contains filtered or unexported fields }
type ResolvedKey ¶
type TestOutput ¶
type UpdateOutput ¶
type VersionOutput ¶
type VersionOutput struct {
Version string
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
incfusever
Package incfusever is only here to prevent go src tools (like godep) from thinking fuseversion is not a required package.
|
Package incfusever is only here to prevent go src tools (like godep) from thinking fuseversion is not a required package. |
Click to show internal directories.
Click to hide internal directories.