namesys

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 32 Imported by: 17

README

go-namesys

go-namesys provides publish and resolution support for the /ipns/ namespace

Go Reference Travis CI

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/namesys. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

Summary

Package namesys defines Resolver and Publisher interfaces for IPNS paths, that is, paths in the form of /ipns/<name_to_be_resolved>. A "resolved" IPNS path becomes an /ipfs/<cid> path.

Traditionally, these paths would be in the form of /ipns/{libp2p-key}, which references an IPNS record in a distributed ValueStore (usually the IPFS DHT).

Additionally, the /ipns/ namespace can also be used with domain names that use DNSLink (/ipns/en.wikipedia-on-ipfs.org, see https://docs.ipfs.io/concepts/dnslink/).

The package provides implementations for all three resolvers.

Table of Contents

Install

go-namesys works like a regular Go module:

> go get github.com/ipfs/go-namesys

Usage

import "github.com/ipfs/go-namesys"

See the Pkg.go.dev documentation

License

This project is dual-licensed under Apache 2.0 and MIT terms:

Documentation

Overview

Package namesys defines Resolver and Publisher interfaces for IPNS paths, that is, IPFS paths in the form of /ipns/<name_to_be_resolved>. A "resolved" IPNS path becomes an /ipfs/<cid> path.

Traditionally, these paths would be in the form of /ipns/peer_id, which references an IPNS record in a distributed ValueStore (usually the IPFS DHT).

Additionally, the /ipns/ namespace can also be used with domain names that use DNSLink (/ipns/<dnslink_name>, https://docs.ipfs.io/concepts/dnslink/)

The package provides implementations for all three resolvers.

Index

Constants

View Source
const DefaultResolverCacheTTL = time.Minute

DefaultResolverCacheTTL defines max ttl of a record placed in namesys cache.

Deprecated: use github.com/ipfs/boxo/namesys.DefaultResolverCacheTTL

Variables

View Source
var ErrPublishFailed = errors.New("could not publish name")

ErrPublishFailed signals an error when attempting to publish.

Deprecated: use github.com/ipfs/boxo/namesys.ErrPublishFailed

View Source
var ErrResolveFailed = errors.New("could not resolve name")

ErrResolveFailed signals an error when attempting to resolve.

Deprecated: use github.com/ipfs/boxo/namesys.ErrResolveFailed

View Source
var ErrResolveRecursion = errors.New(
	"could not resolve name (recursion limit exceeded)")

ErrResolveRecursion signals a recursion-depth limit.

Deprecated: use github.com/ipfs/boxo/namesys.ErrResolveRecursion

Functions

func IpnsDsKey deprecated

func IpnsDsKey(id peer.ID) ds.Key

IpnsDsKey returns a datastore key given an IPNS identifier (peer ID). Defines the storage key for IPNS records in the local datastore.

Deprecated: use github.com/ipfs/boxo/namesys.IpnsDsKey

func PkKeyForID deprecated

func PkKeyForID(id peer.ID) string

PkKeyForID returns the public key routing key for the given peer ID.

Deprecated: use github.com/ipfs/boxo/namesys.PkKeyForID

func PublishEntry deprecated

func PublishEntry(ctx context.Context, r routing.ValueStore, ipnskey string, rec *pb.IpnsEntry) error

PublishEntry stores the given IpnsEntry in the ValueStore with the given ipnskey.

Deprecated: use github.com/ipfs/boxo/namesys.PublishEntry

func PublishPublicKey deprecated

func PublishPublicKey(ctx context.Context, r routing.ValueStore, k string, pubk crypto.PubKey) error

PublishPublicKey stores the given public key in the ValueStore with the given key.

Deprecated: use github.com/ipfs/boxo/namesys.PublishPublicKey

func PutRecordToRouting deprecated

func PutRecordToRouting(ctx context.Context, r routing.ValueStore, k crypto.PubKey, entry *pb.IpnsEntry) error

PutRecordToRouting publishes the given entry using the provided ValueStore, keyed on the ID associated with the provided public key. The public key is also made available to the routing system so that entries can be verified.

Deprecated: use github.com/ipfs/boxo/namesys.PutRecordToRouting

func StartSpan deprecated added in v0.5.0

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Deprecated: use github.com/ipfs/boxo/namesys.StartSpan

Types

type DNSResolver deprecated

type DNSResolver struct {
	// contains filtered or unexported fields
}

DNSResolver implements a Resolver on DNS domains

Deprecated: use github.com/ipfs/boxo/namesys.DNSResolver

func NewDNSResolver deprecated

func NewDNSResolver(lookup LookupTXTFunc) *DNSResolver

NewDNSResolver constructs a name resolver using DNS TXT records.

Deprecated: use github.com/ipfs/boxo/namesys.NewDNSResolver

func (*DNSResolver) Resolve

func (r *DNSResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error)

Resolve implements Resolver.

func (*DNSResolver) ResolveAsync

func (r *DNSResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result

ResolveAsync implements Resolver.

type IpnsPublisher deprecated

type IpnsPublisher struct {
	// contains filtered or unexported fields
}

IpnsPublisher is capable of publishing and resolving names to the IPFS routing system.

Deprecated: use github.com/ipfs/boxo/namesys.IpnsPublisher

func NewIpnsPublisher deprecated

func NewIpnsPublisher(route routing.ValueStore, ds ds.Datastore) *IpnsPublisher

NewIpnsPublisher constructs a publisher for the IPFS Routing name system.

Deprecated: use github.com/ipfs/boxo/namesys.NewIpnsPublisher

func (*IpnsPublisher) GetPublished

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

func (p *IpnsPublisher) ListPublished(ctx context.Context) (map[peer.ID]*pb.IpnsEntry, error)

ListPublished 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

func (p *IpnsPublisher) Publish(ctx context.Context, k crypto.PrivKey, value path.Path, options ...opts.PublishOption) error

Publish implements Publisher. Accepts a keypair and a value, and publishes it out to the routing system

type IpnsResolver deprecated

type IpnsResolver struct {
	// contains filtered or unexported fields
}

IpnsResolver implements NSResolver for the main IPFS SFS-like naming

Deprecated: use github.com/ipfs/boxo/namesys.IpnsResolver

func NewIpnsResolver deprecated

func NewIpnsResolver(route routing.ValueStore) *IpnsResolver

NewIpnsResolver constructs a name resolver using the IPFS Routing system to implement SFS-like naming on top.

Deprecated: use github.com/ipfs/boxo/namesys.NewIpnsResolver

func (*IpnsResolver) Resolve

func (r *IpnsResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error)

Resolve implements Resolver.

func (*IpnsResolver) ResolveAsync

func (r *IpnsResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result

ResolveAsync implements Resolver.

type LookupTXTFunc deprecated

type LookupTXTFunc func(ctx context.Context, name string) (txt []string, err error)

LookupTXTFunc is a function that lookups TXT record values.

Deprecated: use github.com/ipfs/boxo/namesys.LookupTXTFunc

type NameSystem deprecated

type NameSystem interface {
	Resolver
	Publisher
}

NameSystem 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).

Deprecated: use github.com/ipfs/boxo/namesys.NameSystem

func NewNameSystem deprecated

func NewNameSystem(r routing.ValueStore, opts ...Option) (NameSystem, error)

NewNameSystem will construct the IPFS naming system based on Routing

Deprecated: use github.com/ipfs/boxo/namesys.NewNameSystem

type Option deprecated added in v0.2.0

type Option func(*mpns) error

Deprecated: use github.com/ipfs/boxo/namesys.Option

func WithCache deprecated added in v0.2.0

func WithCache(size int) Option

WithCache is an option that instructs the name system to use a (LRU) cache of the given size.

Deprecated: use github.com/ipfs/boxo/namesys.WithCache

func WithDNSResolver deprecated added in v0.2.0

func WithDNSResolver(rslv madns.BasicResolver) Option

WithDNSResolver is an option that supplies a custom DNS resolver to use instead of the system default.

Deprecated: use github.com/ipfs/boxo/namesys.WithDNSResolver

func WithDatastore deprecated added in v0.2.0

func WithDatastore(ds ds.Datastore) Option

WithDatastore is an option that supplies a datastore to use instead of an in-memory map datastore. The datastore is used to store published IPNS records and make them available for querying.

Deprecated: use github.com/ipfs/boxo/namesys.WithDatastore

type Publisher deprecated

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, options ...opts.PublishOption) error
}

Publisher is an object capable of publishing particular names.

Deprecated: use github.com/ipfs/boxo/namesys.Publisher

type Resolver deprecated

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.

Deprecated: use github.com/ipfs/boxo/namesys.Resolver

type Result deprecated

type Result struct {
	Path path.Path
	Err  error
}

Result is the return type for Resolver.ResolveAsync.

Deprecated: use github.com/ipfs/boxo/namesys.Result

Directories

Path Synopsis
Package republisher provides a utility to automatically re-publish IPNS records related to the keys in a Keystore.
Package republisher provides a utility to automatically re-publish IPNS records related to the keys in a Keystore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL