ipnisync

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0, MIT Imports: 33 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// IPNIPath is the path that the Publisher expects as the last port of the
	// HTTP request URL path. The sync client automatically adds this to the
	// request path.
	IPNIPath = "/ipni/v1/ad"
	// ProtocolID is the libp2p protocol ID used to identify the ipni-sync
	// protocol. With libp2phttp this protocol ID maps directly to a single
	// HTTP path, so the value of the protocol ID is the same as the IPNI path
	// for the ipni-sync protocol.
	ProtocolID = protocol.ID(IPNIPath)
)

Variables

View Source
var ErrNoHTTPServer = errors.New("publisher has libp2p server without HTTP")

Functions

This section is empty.

Types

type ClientOption added in v0.5.0

type ClientOption func(*clientConfig)

Option is a function that sets a value in a config.

func ClientAuthServerPeerID added in v0.5.0

func ClientAuthServerPeerID(require bool) ClientOption

ClientAuthServerPeerID tells the sync client that it must authenticate the server's peer ID.

func ClientHTTPRetry added in v0.5.0

func ClientHTTPRetry(retryMax int, waitMin, waitMax time.Duration) ClientOption

ClientHTTPRetry configures a retriable HTTP client. Setting retryMax to zero, the default, disables the retriable client.

func ClientHTTPTimeout added in v0.5.0

func ClientHTTPTimeout(to time.Duration) ClientOption

ClientHTTPTimeout specifies a time limit for HTTP requests made by the sync client. A value of zero means no timeout.

func ClientStreamHost added in v0.5.0

func ClientStreamHost(h host.Host) ClientOption

ClientStreamHost specifies an optional stream based libp2p host used by the sync client to do HTTP over libp2p streams.

type Option

type Option func(*config) error

Option is a function that sets a value in a config.

func WithHTTPListenAddrs added in v0.5.0

func WithHTTPListenAddrs(addrs ...string) Option

WithHTTPListenAddrs sets the HTTP addresses to listen on. These are in addresses:port format and may be prefixed with "https://" or "http://" or to specify whether or not TLS is required. If there is no prefix, then one is assumed based on the value specified by WithRequireTLS.

Setting HTTP listen addresses is optional when a stream host is provided by the WithStreamHost option.

func WithHandlerPath

func WithHandlerPath(urlPath string) Option

WithHandlerPath sets the path used to handle requests to this publisher. This specifies the portion of the path before the implicit /ipni/v1/ad/ part of the path. Calling WithHandlerPath("/foo/bar") configures the publisher to handle HTTP requests on the path "/foo/bar/ipni/v1/ad/".

func WithHeadTopic

func WithHeadTopic(topic string) Option

WithHeadTopic sets the optional topic returned in a head query response. This is the topic on which advertisement are announced.

func WithRequireTLS added in v0.5.0

func WithRequireTLS(require bool) Option

WithRequireTLS tells whether to allow the publisher to require https (true) or to serve non-secure http (false). Default is false, allowing non-secure HTTP.

func WithStartServer added in v0.5.0

func WithStartServer(start bool) Option

WithStartServer, if true, starts an http server listening on the given address. an HTTP server. If this option is not specified, then no server is started and this will need to be done by the caller.

func WithStreamHost added in v0.5.0

func WithStreamHost(h host.Host) Option

WithStreamHost specifies an optional stream based libp2p host used to do HTTP over libp2p streams.

func WithTLSConfig added in v0.5.1

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig sets the TLS config for the HTTP server.

type Publisher

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

Publisher serves an advertisement chain over HTTP.

func NewPublisher

func NewPublisher(lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisher creates a new ipni-sync publisher. Optionally, a libp2p stream host can be provided to serve HTTP over libp2p.

func (*Publisher) Addrs

func (p *Publisher) Addrs() []multiaddr.Multiaddr

Addrs returns the slice of multiaddr addresses that the Publisher is listening on.

If the server is not started, WithStartServer(false), then this returns the multiaddr versions of the list of addresses given by WithHTTPListenAddrs and may not actually be a listening address.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the Publisher.

func (*Publisher) ID

func (p *Publisher) ID() peer.ID

ID returns the p2p peer ID of the Publisher.

func (*Publisher) Protocol

func (p *Publisher) Protocol() int

Protocol returns the multiaddr protocol ID of the transport used by the publisher.

func (*Publisher) ServeHTTP

func (p *Publisher) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

func (*Publisher) SetRoot

func (p *Publisher) SetRoot(c cid.Cid)

SetRoot sets the head of the advertisement chain.

type Sync

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

Sync provides sync functionality for use with all http syncs.

func NewSync

func NewSync(lsys ipld.LinkSystem, blockHook func(peer.ID, cid.Cid), options ...ClientOption) *Sync

NewSync creates a new Sync.

func (*Sync) Close

func (s *Sync) Close()

func (*Sync) NewSyncer

func (s *Sync) NewSyncer(peerInfo peer.AddrInfo) (*Syncer, error)

NewSyncer creates a new Syncer to use for a single sync operation against a peer. A value for peerInfo.ID is optional for the HTTP transport.

type Syncer

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

Syncer provides sync functionality for a single sync with a peer.

func (*Syncer) GetHead

func (s *Syncer) GetHead(ctx context.Context) (cid.Cid, error)

GetHead fetches the head of the peer's advertisement chain.

func (*Syncer) SameAddrs added in v0.5.14

func (s *Syncer) SameAddrs(maddrs []multiaddr.Multiaddr) bool

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context, nextCid cid.Cid, sel ipld.Node) error

Sync syncs the peer's advertisement chain or entries chain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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