Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var IpnsCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Resolve IPNS names.", 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 name used is the node's own PeerID, which is the hash of its 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 name used is the node's own PeerID, which is the hash of its public key. You can use the 'ipfs key' commands to list and generate more names and their respective keys. Examples: Resolve the value of your name: > ipfs name resolve /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Resolve the value of another name: > ipfs name resolve QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ /ipfs/QmSiTko9JZyabH56y2fussEt1A5oDqsFXB3CkvAqraFryz Resolve the value of a dnslink: > ipfs name resolve ipfs.io /ipfs/QmaBvfZooxWkrv7D3r8LS9moNjzD2o525XMZze69hhoxf5 `, }, Arguments: []cmds.Argument{ cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."), }, Options: []cmds.Option{ cmds.BoolOption(recursiveOptionName, "r", "Resolve until the result is not an IPNS name.").WithDefault(true), cmds.BoolOption(nocacheOptionName, "n", "Do not use cached entries."), cmds.UintOption(dhtRecordCountOptionName, "dhtrc", "Number of records to request for DHT resolution.").WithDefault(uint(namesys.DefaultResolverDhtRecordCount)), cmds.StringOption(dhtTimeoutOptionName, "dhtt", "Max time to collect values during DHT resolution e.g. \"30s\". Pass 0 for no timeout.").WithDefault(namesys.DefaultResolverDhtTimeout.String()), cmds.BoolOption(streamOptionName, "s", "Stream entries as they are found."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env, req) if err != nil { return err } nocache, _ := req.Options["nocache"].(bool) var name string if len(req.Arguments) == 0 { self, err := api.Key().Self(req.Context) if err != nil { return err } name = self.ID().String() } else { name = req.Arguments[0] } recursive, _ := req.Options[recursiveOptionName].(bool) rc, rcok := req.Options[dhtRecordCountOptionName].(uint) dhtt, dhttok := req.Options[dhtTimeoutOptionName].(string) stream, _ := req.Options[streamOptionName].(bool) opts := []options.NameResolveOption{ options.Name.Cache(!nocache), } if !recursive { opts = append(opts, options.Name.ResolveOption(namesys.ResolveWithDepth(1))) } if rcok { opts = append(opts, options.Name.ResolveOption(namesys.ResolveWithDhtRecordCount(rc))) } if dhttok { d, err := time.ParseDuration(dhtt) if err != nil { return err } if d < 0 { return errors.New("DHT timeout value must be >= 0") } opts = append(opts, options.Name.ResolveOption(namesys.ResolveWithDhtTimeout(d))) } if !strings.HasPrefix(name, "/ipns/") { name = "/ipns/" + name } if !stream { output, err := api.Name().Resolve(req.Context, name, opts...) if err != nil && (recursive || err != namesys.ErrResolveRecursion) { return err } pth, err := path.NewPath(output.String()) if err != nil { return err } return cmds.EmitOnce(res, &ResolvedPath{pth.String()}) } output, err := api.Name().Search(req.Context, name, opts...) if err != nil { return err } for v := range output { if v.Err != nil && (recursive || v.Err != namesys.ErrResolveRecursion) { return v.Err } if err := res.Emit(&ResolvedPath{v.Path.String()}); err != nil { return err } } return nil }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, rp *ResolvedPath) error { _, err := fmt.Fprintln(w, rp.Path) return err }), }, Type: ResolvedPath{}, }
View Source
var IpnsGetCmd = &cmds.Command{ Status: cmds.Experimental, Helptext: cmds.HelpText{ Tagline: "Retrieve a signed IPNS record.", ShortDescription: ` Retrieves the signed IPNS record for a given name from the routing system. The output is the raw IPNS record (protobuf) as defined in the IPNS spec: https://specs.ipfs.tech/ipns/ipns-record/ The record can be inspected with 'ipfs name inspect': ipfs name get <name> | ipfs name inspect This is equivalent to 'ipfs routing get /ipns/<name>' but only accepts IPNS names (not arbitrary routing keys). Note: The routing system returns the "best" IPNS record it knows about. For IPNS, "best" means the record with the highest sequence number. If multiple records exist (e.g., after using 'ipfs name put'), this command returns the one the routing system considers most current. `, HTTP: &cmds.HTTPHelpText{ ResponseContentType: "application/vnd.ipfs.ipns-record", }, }, Arguments: []cmds.Argument{ cmds.StringArg("name", true, false, "The IPNS name to look up."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env, req) if err != nil { return err } name := req.Arguments[0] if !strings.HasPrefix(name, "/ipns/") { name = "/ipns/" + name } data, err := api.Routing().Get(req.Context, name) if err != nil { return err } res.SetEncodingType(cmds.OctetStream) res.SetContentType("application/vnd.ipfs.ipns-record") return res.Emit(bytes.NewReader(data)) }, }
View Source
var IpnsInspectCmd = &cmds.Command{ Status: cmds.Experimental, Helptext: cmds.HelpText{ Tagline: "Inspects an IPNS Record", ShortDescription: ` Prints values inside of IPNS Record protobuf and its DAG-CBOR Data field. Passing --verify will verify signature against provided public key. `, LongDescription: ` Prints values inside of IPNS Record protobuf and its DAG-CBOR Data field. The input can be a file or STDIN, the output can be JSON: $ ipfs routing get "/ipns/$PEERID" > ipns_record $ ipfs name inspect --enc=json < ipns_record Values in PublicKey, SignatureV1 and SignatureV2 fields are raw bytes encoded in Multibase. The Data field is DAG-CBOR represented as DAG-JSON. Passing --verify will verify signature against provided public key. `, HTTP: &cmds.HTTPHelpText{ Description: "Request body should be `multipart/form-data` with the IPNS record bytes.", }, }, Arguments: []cmds.Argument{ cmds.FileArg("record", true, false, "The IPNS record payload to be verified.").EnableStdin(), }, Options: []cmds.Option{ cmds.StringOption("verify", "CID of the public IPNS key to validate against."), cmds.BoolOption("dump", "Include a full hex dump of the raw Protobuf record.").WithDefault(true), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { file, err := cmdenv.GetFileArg(req.Files.Entries()) if err != nil { return err } defer file.Close() var b bytes.Buffer _, err = io.Copy(&b, file) if err != nil { return err } rec, err := ipns.UnmarshalRecord(b.Bytes()) if err != nil { return err } result := &IpnsInspectResult{ Entry: IpnsInspectEntry{}, } if v, err := rec.Value(); err == nil { result.Entry.Value = v.String() } if v, err := rec.ValidityType(); err == nil { result.Entry.ValidityType = &v } if v, err := rec.Validity(); err == nil { result.Entry.Validity = &v } if v, err := rec.Sequence(); err == nil { result.Entry.Sequence = &v } if v, err := rec.TTL(); err == nil { result.Entry.TTL = &v } // Here we need the raw protobuf just to decide the version. var pbRecord ipns_pb.IpnsRecord err = proto.Unmarshal(b.Bytes(), &pbRecord) if err != nil { return err } if len(pbRecord.SignatureV1) != 0 || len(pbRecord.Value) != 0 { result.SignatureType = "V1+V2" } else if pbRecord.Data != nil { result.SignatureType = "V2" } else { result.SignatureType = "Unknown" } result.PbSize = proto.Size(&pbRecord) if verify, ok := req.Options["verify"].(string); ok { name, err := ipns.NameFromString(verify) if err != nil { return err } result.Validation = &IpnsInspectValidation{ Name: name.String(), } err = ipns.ValidateWithName(rec, name) if err == nil { result.Validation.Valid = true } else { result.Validation.Reason = err.Error() } } if dump, ok := req.Options["dump"].(bool); ok && dump { result.HexDump = hex.Dump(b.Bytes()) } return cmds.EmitOnce(res, result) }, Type: IpnsInspectResult{}, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *IpnsInspectResult) error { tw := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0) defer tw.Flush() if out.Entry.Value != "" { fmt.Fprintf(tw, "Value:\t%q\n", out.Entry.Value) } if out.Entry.ValidityType != nil { fmt.Fprintf(tw, "Validity Type:\t%d\n", *out.Entry.ValidityType) } if out.Entry.Validity != nil { fmt.Fprintf(tw, "Validity:\t%q\n", out.Entry.Validity.Format(time.RFC3339Nano)) } if out.Entry.Sequence != nil { fmt.Fprintf(tw, "Sequence:\t%d\n", *out.Entry.Sequence) } if out.Entry.TTL != nil { fmt.Fprintf(tw, "TTL:\t%s\n", out.Entry.TTL.String()) } fmt.Fprintf(tw, "Protobuf Size:\t%d\n", out.PbSize) fmt.Fprintf(tw, "Signature Type:\t%s\n", out.SignatureType) if out.Validation == nil { tw.Flush() fmt.Fprintf(w, "\nThis record was not verified. Pass '--verify k51...' to verify.\n") } else { tw.Flush() fmt.Fprintf(w, "\nValidation results:\n") fmt.Fprintf(tw, "\tValid:\t%v\n", out.Validation.Valid) if out.Validation.Reason != "" { fmt.Fprintf(tw, "\tReason:\t%s\n", out.Validation.Reason) } fmt.Fprintf(tw, "\tName:\t%s\n", out.Validation.Name) } if out.HexDump != "" { tw.Flush() fmt.Fprintf(w, "\nHex Dump:\n%s", out.HexDump) } return nil }), }, }
View Source
var IpnsPubsubCmd = &cmds.Command{ Status: cmds.Experimental, Helptext: cmds.HelpText{ Tagline: "IPNS pubsub management", ShortDescription: ` Manage and inspect the state of the IPNS pubsub resolver. Note: this command is experimental and subject to change as the system is refined `, }, Subcommands: map[string]*cmds.Command{ "state": ipnspsStateCmd, "subs": ipnspsSubsCmd, "cancel": ipnspsCancelCmd, }, }
IpnsPubsubCmd is the subcommand that allows us to manage the IPNS pubsub system
View Source
var IpnsPutCmd = &cmds.Command{ Status: cmds.Experimental, Helptext: cmds.HelpText{ Tagline: "Store a pre-signed IPNS record in the routing system.", ShortDescription: ` Stores a pre-signed IPNS record in the routing system. This command accepts a raw IPNS record (protobuf) as defined in the IPNS spec: https://specs.ipfs.tech/ipns/ipns-record/ The record must be signed by the private key corresponding to the IPNS name. Use 'ipfs name get' to retrieve records and 'ipfs name inspect' to examine. `, LongDescription: ` Stores a pre-signed IPNS record in the routing system. This command accepts a raw IPNS record (protobuf) as defined in the IPNS spec: https://specs.ipfs.tech/ipns/ipns-record/ The record must be signed by the private key corresponding to the IPNS name. Use 'ipfs name get' to retrieve records and 'ipfs name inspect' to examine. Use Cases: - Re-publishing third-party records: store someone else's signed record - Cross-node sync: import records exported from another node - Backup/restore: export with 'name get', restore with 'name put' Validation: By default, the command validates that: - The record is a valid IPNS record (protobuf) - The record size is within 10 KiB limit - The signature matches the provided IPNS name - The record's sequence number is higher than any existing record (identical records are allowed for republishing) The --force flag skips this command's validation and passes the record directly to the routing system. Note that --force only affects this command; it does not control how the routing system handles the record. The routing system may still reject invalid records or prefer records with higher sequence numbers. Use --force primarily for testing (e.g., to observe how the routing system reacts to incorrectly signed or malformed records). Important: Even after a successful 'name put', a subsequent 'name get' may return a different record if one with a higher sequence number exists. This is expected IPNS behavior, not a bug. Publishing Modes: By default, IPNS records are published to both the DHT and any configured HTTP delegated publishers. You can control this behavior with: --allow-offline Store locally without requiring network connectivity --allow-delegated Publish via HTTP delegated publishers only (no DHT) Examples: Export and re-import a record: > ipfs name get k51... > record.bin > ipfs name put k51... record.bin Store a record received from someone else: > ipfs name put k51... third-party-record.bin Force store a record to test routing validation: > ipfs name put --force k51... possibly-invalid-record.bin `, HTTP: &cmds.HTTPHelpText{ Description: "Request body should be `multipart/form-data` with the IPNS record bytes.", }, }, Arguments: []cmds.Argument{ cmds.StringArg("name", true, false, "The IPNS name to store the record for (e.g., k51... or /ipns/k51...)."), cmds.FileArg("record", true, false, "Path to file containing the signed IPNS record.").EnableStdin(), }, Options: []cmds.Option{ cmds.BoolOption(forceOptionName, "f", "Skip validation (signature, sequence, size)."), cmds.BoolOption(putAllowOfflineOption, "Store locally without broadcasting to the network."), cmds.BoolOption(allowDelegatedOption, "Publish via HTTP delegated publishers only (no DHT)."), cmds.BoolOption(putQuietOptionName, "q", "Write no output."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { nd, err := cmdenv.GetNode(env) if err != nil { return err } api, err := cmdenv.GetApi(env, req) if err != nil { return err } force, _ := req.Options[forceOptionName].(bool) allowOffline, _ := req.Options[putAllowOfflineOption].(bool) allowDelegated, _ := req.Options[allowDelegatedOption].(bool) if allowOffline && allowDelegated { return errors.New("cannot use both --allow-offline and --allow-delegated flags") } if allowDelegated { cfg, err := nd.Repo.Config() if err != nil { return fmt.Errorf("failed to read config: %w", err) } delegatedPublishers := cfg.DelegatedPublishersWithAutoConf() if len(delegatedPublishers) == 0 { return errors.New("no delegated publishers configured: add Ipns.DelegatedPublishers or use --allow-offline for local-only publishing") } } nameArg := req.Arguments[0] if !strings.HasPrefix(nameArg, "/ipns/") { nameArg = "/ipns/" + nameArg } namePart := strings.TrimPrefix(nameArg, "/ipns/") name, err := ipns.NameFromString(namePart) if err != nil { return fmt.Errorf("invalid IPNS name: %w", err) } file, err := cmdenv.GetFileArg(req.Files.Entries()) if err != nil { return err } defer file.Close() data, err := io.ReadAll(io.LimitReader(file, 1<<20)) if err != nil { return fmt.Errorf("failed to read record: %w", err) } if len(data) == 0 { return errors.New("record is empty") } if !force { if len(data) > maxIPNSRecordSize { return fmt.Errorf("record exceeds maximum size of %d bytes, use --force to skip size check", maxIPNSRecordSize) } rec, err := ipns.UnmarshalRecord(data) if err != nil { return fmt.Errorf("invalid IPNS record: %w", err) } err = ipns.ValidateWithName(rec, name) if err != nil { return fmt.Errorf("record validation failed: %w", err) } existingData, err := api.Routing().Get(req.Context, nameArg) if err == nil { if !bytes.Equal(existingData, data) { existingRec, parseErr := ipns.UnmarshalRecord(existingData) if parseErr == nil { existingSeq, seqErr := existingRec.Sequence() newSeq, newSeqErr := rec.Sequence() if seqErr == nil && newSeqErr == nil && existingSeq >= newSeq { return fmt.Errorf("existing IPNS record has sequence %d >= new record sequence %d, use 'ipfs name put --force' to skip this check", existingSeq, newSeq) } } } } } opts := []options.RoutingPutOption{ options.Routing.AllowOffline(allowOffline || allowDelegated), } err = api.Routing().Put(req.Context, nameArg, data, opts...) if err != nil { if err.Error() == "can't put while offline" { return errPutAllowOffline } return err } value := "" if rec, err := ipns.UnmarshalRecord(data); err == nil { if v, err := rec.Value(); err == nil { value = v.String() } } return cmds.EmitOnce(res, &IpnsEntry{ Name: name.String(), Value: value, }) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, ie *IpnsEntry) error { quiet, _ := req.Options[putQuietOptionName].(bool) if quiet { return nil } _, err := fmt.Fprintln(w, cmdenv.EscNonPrint(ie.Name)) return err }), }, Type: IpnsEntry{}, }
View Source
var NameCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Publish and resolve IPNS names.", 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 name used is the node's own PeerID, which is the hash of its 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 name used is the node's own PeerID, which is the hash of its public key. You can use the 'ipfs key' commands to list and generate more names and their respective keys. Examples: Publish an <ipfs-path> with your default name: > ipfs name publish /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4 Published to k51qzi5uqu5dgklc20hksmmzhoy5lfrn5xcnryq6xp4r50b5yc0vnivpywfu9p: /ipfs/bafk... Publish an <ipfs-path> with another name, added by an 'ipfs key' command: > ipfs key gen --type=ed25519 mykey k51qzi5uqu5dlz49qkb657myg6f1buu6rauv8c6b489a9i1e4dkt7a3yo9j2wr > ipfs name publish --key=mykey /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4 Published to k51qzi5uqu5dlz49qkb657myg6f1buu6rauv8c6b489a9i1e4dkt7a3yo9j2wr: /ipfs/bafk... Resolve the value of your name: > ipfs name resolve /ipfs/bafk... Resolve the value of another name: > ipfs name resolve k51qzi5uqu5dlz49qkb657myg6f1buu6rauv8c6b489a9i1e4dkt7a3yo9j2wr /ipfs/bafk... Resolve the value of a dnslink: > ipfs name resolve specs.ipfs.tech /ipfs/bafy... `, }, Subcommands: map[string]*cmds.Command{ "publish": PublishCmd, "resolve": IpnsCmd, "pubsub": IpnsPubsubCmd, "inspect": IpnsInspectCmd, "get": IpnsGetCmd, "put": IpnsPutCmd, }, }
View Source
var PublishCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Publish IPNS names.", 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 name used is the node's own PeerID, which is the hash of its 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 name used is the node's own PeerID, which is the hash of its public key. You can use the 'ipfs key' commands to list and generate more names and their respective keys. Publishing Modes: By default, IPNS records are published to both the DHT and any configured HTTP delegated publishers. You can control this behavior with the following flags: --allow-offline Allow publishing when offline (publishes to local datastore, network operations are optional) --allow-delegated Allow publishing without DHT connectivity (local + HTTP delegated publishers only) Examples: Publish an <ipfs-path> with your default name: > ipfs name publish /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Publish without DHT (HTTP delegated publishers only): > ipfs name publish --allow-delegated /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Publish when offline (local publish, network optional): > ipfs name publish --allow-offline /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy Notes: The --ttl option specifies the time duration for caching IPNS records. Lower values like '1m' enable faster updates but increase network load, while the default of 1 hour reduces traffic but may delay propagation. Gateway operators may override this with Ipns.MaxCacheTTL configuration. The --sequence option sets a custom sequence number for the IPNS record. The sequence number must be monotonically increasing (greater than the current record's sequence). This is useful for manually coordinating updates across multiple writers. If not specified, the sequence number increments automatically. For faster IPNS updates, consider: - Using a lower --ttl value (e.g., '1m' for quick updates) - Enabling PubSub via Ipns.UsePubsub in the config `, }, Arguments: []cmds.Argument{ cmds.StringArg(ipfsPathOptionName, true, false, "ipfs path of the object to be published.").EnableStdin(), }, Options: []cmds.Option{ cmds.StringOption(keyOptionName, "k", "Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'.").WithDefault("self"), cmds.BoolOption(resolveOptionName, "Check if the given path can be resolved before publishing.").WithDefault(true), cmds.StringOption(lifeTimeOptionName, "t", `Time duration the signed record will be valid for. Accepts durations such as "300s", "1.5h" or "7d2h45m"`).WithDefault(ipns.DefaultRecordLifetime.String()), cmds.StringOption(ttlOptionName, "Time duration hint, akin to --lifetime, indicating how long to cache this record before checking for updates.").WithDefault(ipns.DefaultRecordTTL.String()), cmds.BoolOption(quieterOptionName, "Q", "Write only final IPNS Name encoded as CIDv1 (for use in /ipns content paths)."), cmds.BoolOption(v1compatOptionName, "Produce a backward-compatible IPNS Record by including fields for both V1 and V2 signatures.").WithDefault(true), cmds.BoolOption(allowOfflineOptionName, "Allow publishing when offline - publishes to local datastore without requiring network connectivity."), cmds.BoolOption(allowDelegatedOptionName, "Allow publishing without DHT connectivity - uses local datastore and HTTP delegated publishers only."), cmds.Uint64Option(sequenceOptionName, "Set a custom sequence number for the IPNS record (must be higher than current)."), ke.OptionIPNSBase, }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env, req) if err != nil { return err } allowOffline, _ := req.Options[allowOfflineOptionName].(bool) allowDelegated, _ := req.Options[allowDelegatedOptionName].(bool) compatibleWithV1, _ := req.Options[v1compatOptionName].(bool) kname, _ := req.Options[keyOptionName].(string) if allowOffline && allowDelegated { return errors.New("cannot use both --allow-offline and --allow-delegated flags") } validTimeOpt, _ := req.Options[lifeTimeOptionName].(string) validTime, err := time.ParseDuration(validTimeOpt) if err != nil { return fmt.Errorf("error parsing lifetime option: %s", err) } opts := []options.NamePublishOption{ options.Name.AllowOffline(allowOffline), options.Name.AllowDelegated(allowDelegated), options.Name.Key(kname), options.Name.ValidTime(validTime), options.Name.CompatibleWithV1(compatibleWithV1), } if ttl, found := req.Options[ttlOptionName].(string); found { d, err := time.ParseDuration(ttl) if err != nil { return err } opts = append(opts, options.Name.TTL(d)) } if sequence, found := req.Options[sequenceOptionName].(uint64); found { opts = append(opts, options.Name.Sequence(sequence)) } p, err := cmdutils.PathOrCidPath(req.Arguments[0]) if err != nil { return err } if verifyExists, _ := req.Options[resolveOptionName].(bool); verifyExists { _, err := api.ResolveNode(req.Context, p) if err != nil { return err } } name, err := api.Name().Publish(req.Context, p, opts...) if err != nil { if err == iface.ErrOffline { err = errAllowOffline } return err } return cmds.EmitOnce(res, &IpnsEntry{ Name: name.String(), Value: p.String(), }) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, ie *IpnsEntry) error { var err error quieter, _ := req.Options[quieterOptionName].(bool) if quieter { _, err = fmt.Fprintln(w, cmdenv.EscNonPrint(ie.Name)) } else { _, err = fmt.Fprintf(w, "Published to %s: %s\n", cmdenv.EscNonPrint(ie.Name), cmdenv.EscNonPrint(ie.Value)) } return err }), }, Type: IpnsEntry{}, }
Functions ¶
This section is empty.
Types ¶
type IpnsInspectEntry ¶ added in v0.19.0
type IpnsInspectEntry struct {
Value string
ValidityType *ipns.ValidityType
Validity *time.Time
Sequence *uint64
TTL *time.Duration
}
IpnsInspectEntry contains the deserialized values from an IPNS Entry: https://github.com/ipfs/specs/blob/main/ipns/IPNS.md#record-serialization-format
type IpnsInspectResult ¶ added in v0.19.0
type IpnsInspectResult struct {
Entry IpnsInspectEntry
PbSize int
SignatureType string
HexDump string
Validation *IpnsInspectValidation
}
type IpnsInspectValidation ¶ added in v0.19.0
type ResolvedPath ¶
type ResolvedPath struct {
Path string
}
Click to show internal directories.
Click to hide internal directories.