namesys

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2015 License: MIT Imports: 21 Imported by: 0

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

View Source
const (
	// DefaultDepthLimit is the default depth limit used by Resolve.
	DefaultDepthLimit = 32

	// UnlimitedDepth allows infinite recursion in ResolveN.  You
	// probably don't want to use this, but it's here if you absolutely
	// trust resolution to eventually complete and can't put an upper
	// limit on how many steps it will take.
	UnlimitedDepth = 0
)

Variables

View Source
var ErrExpiredRecord = errors.New("expired record")

ErrExpiredRecord should be returned when an ipns record is invalid due to being too old

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

ErrPublishFailed signals an error when attempting to publish.

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

ErrResolveFailed signals an error when attempting to resolve.

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

ErrResolveRecursion signals a recursion-depth limit.

View Source
var ErrUnrecognizedValidity = errors.New("unrecognized validity type")

ErrUnrecognizedValidity is returned when an IpnsRecord has an unknown validity type.

View Source
var IpnsRecordValidator = &record.ValidChecker{
	Func: ValidateIpnsRecord,
	Sign: true,
}

Functions

func InitializeKeyspace added in v0.3.2

func InitializeKeyspace(ctx context.Context, ds dag.DAGService, pub Publisher, pins pin.Pinner, key ci.PrivKey) error

InitializeKeyspace sets the ipns record for the given key to point to an empty directory. TODO: this doesnt feel like it belongs here

func ValidateIpnsRecord

func ValidateIpnsRecord(k key.Key, val []byte) error

ValidateIpnsRecord implements ValidatorFunc and verifies that the given 'val' is an IpnsEntry and that that entry is valid.

Types

type DNSResolver

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

DNSResolver implements a Resolver on DNS domains

func (*DNSResolver) Resolve

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

Resolve implements Resolver.

func (*DNSResolver) ResolveN added in v0.3.5

func (r *DNSResolver) ResolveN(ctx context.Context, name string, depth int) (path.Path, error)

ResolveN implements Resolver.

type LookupTXTFunc added in v0.3.5

type LookupTXTFunc func(name string) (txt []string, err error)

type NameSystem

type NameSystem interface {
	Resolver
	Publisher
}

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

NewNameSystem will construct the IPFS naming system based on Routing

type ProquintResolver

type ProquintResolver struct{}

func (*ProquintResolver) Resolve

func (r *ProquintResolver) Resolve(ctx context.Context, name string) (path.Path, error)

Resolve implements Resolver.

func (*ProquintResolver) ResolveN added in v0.3.5

func (r *ProquintResolver) ResolveN(ctx context.Context, name string, depth int) (path.Path, error)

ResolveN implements Resolver.

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
}

Publisher is an object capable of publishing particular names.

func NewRoutingPublisher

func NewRoutingPublisher(route routing.IpfsRouting) Publisher

NewRoutingPublisher constructs a publisher for the IPFS Routing name system.

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 use ResolveN.
	Resolve(ctx context.Context, name string) (value path.Path, err error)

	// ResolveN performs a recursive lookup, returning the dereferenced
	// path.  The only difference from Resolve is that the depth limit
	// is configurable.  You can use DefaultDepthLimit, UnlimitedDepth,
	// or a depth limit of your own choosing.
	//
	// Most users should use Resolve, since the default limit works well
	// in most real-world situations.
	ResolveN(ctx context.Context, name string, depth int) (value path.Path, err error)
}

Resolver is an object capable of resolving names.

func NewDNSResolver added in v0.3.5

func NewDNSResolver() Resolver

NewDNSResolver constructs a name resolver using DNS TXT records.

func NewRoutingResolver

func NewRoutingResolver(route routing.IpfsRouting) Resolver

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

Directories

Path Synopsis
Package namesys_pb is a generated protocol buffer package.
Package namesys_pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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