Documentation ¶
Overview ¶
Package namesys implements resolvers and publishers for the IPFS naming system (IPNS).
The core of IPFS is an immutable, content-addressable Merkle graph. That works well for many use cases, but doesn't allow you to answer questions like "what is Alice's current homepage?". The mutable name system allows Alice to publish information like:
The current homepage for alice.example.com is /ipfs/Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj
or:
The current homepage for node QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy is /ipfs/Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj
The mutable name system also allows users to resolve those references to find the immutable IPFS object currently referenced by a given mutable name.
For command-line bindings to this functionality, see:
ipfs name ipfs dns ipfs resolve
Index ¶
- Constants
- Variables
- func InitializeKeyspace(ctx context.Context, pub Publisher, pins pin.Pinner, key ci.PrivKey) error
- func IpnsDsKey(id peer.ID) ds.Key
- func PkKeyForID(id peer.ID) string
- func PublishEntry(ctx context.Context, r routing.ValueStore, ipnskey string, rec *pb.IpnsEntry) error
- func PublishPublicKey(ctx context.Context, r routing.ValueStore, k string, pubk ci.PubKey) error
- func PutRecordToRouting(ctx context.Context, r routing.ValueStore, k ci.PubKey, entry *pb.IpnsEntry) error
- type DNSResolver
- type IpnsPublisher
- func (p *IpnsPublisher) GetPublished(ctx context.Context, id peer.ID, checkRouting bool) (*pb.IpnsEntry, error)
- func (p *IpnsPublisher) ListPublished(ctx context.Context) (map[peer.ID]*pb.IpnsEntry, error)
- func (p *IpnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Path) error
- func (p *IpnsPublisher) PublishWithEOL(ctx context.Context, k ci.PrivKey, value path.Path, eol time.Time) error
- type IpnsResolver
- type LookupTXTFunc
- type NameSystem
- type ProquintResolver
- type Publisher
- type Resolver
- type Result
Constants ¶
const DefaultRecordEOL = 24 * time.Hour
const DefaultResolverCacheTTL = time.Minute
DefaultResolverCacheTTL defines max ttl of a record placed in namesys cache.
Variables ¶
var ErrPublishFailed = errors.New("could not publish name")
ErrPublishFailed signals an error when attempting to publish.
var ErrResolveFailed = errors.New("could not resolve name")
ErrResolveFailed signals an error when attempting to resolve.
var ErrResolveRecursion = errors.New(
"could not resolve name (recursion limit exceeded)")
ErrResolveRecursion signals a recursion-depth limit.
Functions ¶
func InitializeKeyspace ¶ added in v0.3.2
InitializeKeyspace sets the ipns record for the given key to point to an empty directory. TODO: this doesnt feel like it belongs here
func PkKeyForID ¶ added in v0.4.16
PkKeyForID returns the public key routing key for the given peer ID.
func PublishEntry ¶ added in v0.3.8
func PublishPublicKey ¶ added in v0.3.8
Types ¶
type DNSResolver ¶
type DNSResolver struct {
// contains filtered or unexported fields
}
DNSResolver implements a Resolver on DNS domains
func NewDNSResolver ¶ added in v0.3.5
func NewDNSResolver() *DNSResolver
NewDNSResolver constructs a name resolver using DNS TXT records.
func (*DNSResolver) Resolve ¶
func (r *DNSResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error)
Resolve implements Resolver.
func (*DNSResolver) ResolveAsync ¶ added in v0.4.18
func (r *DNSResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result
ResolveAsync implements Resolver.
type IpnsPublisher ¶ added in v0.4.16
type IpnsPublisher struct {
// contains filtered or unexported fields
}
IpnsPublisher is capable of publishing and resolving names to the IPFS routing system.
func NewIpnsPublisher ¶ added in v0.4.16
func NewIpnsPublisher(route routing.ValueStore, ds ds.Datastore) *IpnsPublisher
NewIpnsPublisher constructs a publisher for the IPFS Routing name system.
func (*IpnsPublisher) GetPublished ¶ added in v0.4.16
func (p *IpnsPublisher) GetPublished(ctx context.Context, id peer.ID, checkRouting bool) (*pb.IpnsEntry, error)
GetPublished returns the record this node has published corresponding to the given peer ID.
If `checkRouting` is true and we have no existing record, this method will check the routing system for any existing records.
func (*IpnsPublisher) ListPublished ¶ added in v0.4.16
PublishedNames returns the latest IPNS records published by this node and their expiration times.
This method will not search the routing system for records published by other nodes.
func (*IpnsPublisher) Publish ¶ added in v0.4.16
Publish implements Publisher. Accepts a keypair and a value, and publishes it out to the routing system
func (*IpnsPublisher) PublishWithEOL ¶ added in v0.4.16
func (p *IpnsPublisher) PublishWithEOL(ctx context.Context, k ci.PrivKey, value path.Path, eol time.Time) error
PublishWithEOL is a temporary stand in for the ipns records implementation see here for more details: https://github.com/ipfs/specs/tree/master/records
type IpnsResolver ¶ added in v0.4.16
type IpnsResolver struct {
// contains filtered or unexported fields
}
IpnsResolver implements NSResolver for the main IPFS SFS-like naming
func NewIpnsResolver ¶ added in v0.4.16
func NewIpnsResolver(route routing.ValueStore) *IpnsResolver
NewIpnsResolver constructs a name resolver using the IPFS Routing system to implement SFS-like naming on top.
func (*IpnsResolver) Resolve ¶ added in v0.4.16
func (r *IpnsResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error)
Resolve implements Resolver.
func (*IpnsResolver) ResolveAsync ¶ added in v0.4.18
func (r *IpnsResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result
ResolveAsync implements Resolver.
type LookupTXTFunc ¶ added in v0.3.5
type NameSystem ¶
Namesys represents a cohesive name publishing and resolving system.
Publishing a name is the process of establishing a mapping, a key-value pair, according to naming rules and databases.
Resolving a name is the process of looking up the value associated with the key (name).
func NewNameSystem ¶
func NewNameSystem(r routing.ValueStore, ds ds.Datastore, cachesize int) NameSystem
NewNameSystem will construct the IPFS naming system based on Routing
type ProquintResolver ¶
type ProquintResolver struct{}
type Publisher ¶
type Publisher interface { // Publish establishes a name-value mapping. // TODO make this not PrivKey specific. Publish(ctx context.Context, name ci.PrivKey, value path.Path) error // TODO: to be replaced by a more generic 'PublishWithValidity' type // call once the records spec is implemented PublishWithEOL(ctx context.Context, name ci.PrivKey, value path.Path, eol time.Time) error }
Publisher is an object capable of publishing particular names.
type Resolver ¶
type Resolver interface { // Resolve performs a recursive lookup, returning the dereferenced // path. For example, if ipfs.io has a DNS TXT record pointing to // /ipns/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy // and there is a DHT IPNS entry for // QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy // -> /ipfs/Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj // then // Resolve(ctx, "/ipns/ipfs.io") // will resolve both names, returning // /ipfs/Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj // // There is a default depth-limit to avoid infinite recursion. Most // users will be fine with this default limit, but if you need to // adjust the limit you can specify it as an option. Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (value path.Path, err error) // ResolveAsync performs recursive name lookup, like Resolve, but it returns // entries as they are discovered in the DHT. Each returned result is guaranteed // to be "better" (which usually means newer) than the previous one. ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result }
Resolver is an object capable of resolving names.