config

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrsFactory

type AddrsFactory = bhost.AddrsFactory

AddrsFactory is a function that takes a set of multiaddrs we're listening on and returns the set of multiaddrs we should advertise to the network.

type AutoNATConfig

type AutoNATConfig struct {
	ForceReachability   *network.Reachability
	EnableService       bool
	ThrottleGlobalLimit int
	ThrottlePeerLimit   int
	ThrottleInterval    time.Duration
}

AutoNATConfig defines the AutoNAT behavior for the libp2p host.

type Config

type Config struct {
	// UserAgent is the identifier this node will send to other peers when
	// identifying itself, e.g. via the identify protocol.
	//
	// Set it via the UserAgent option function.
	UserAgent string

	// ProtocolVersion is the protocol version that identifies the family
	// of protocols used by the peer in the Identify protocol. It is set
	// using the [ProtocolVersion] option.
	ProtocolVersion string

	PeerKey crypto.PrivKey

	Transports         []TptC
	Muxers             []MsMuxC
	SecurityTransports []MsSecC
	Insecure           bool
	PSK                pnet.PSK

	DialTimeout time.Duration

	RelayCustom bool
	Relay       bool // should the relay transport be used

	EnableRelayService bool // should we run a circuitv2 relay (if publicly reachable)
	RelayServiceOpts   []relayv2.Option

	ListenAddrs     []ma.Multiaddr
	AddrsFactory    bhost.AddrsFactory
	ConnectionGater connmgr.ConnectionGater

	ConnManager     connmgr.ConnManager
	ResourceManager network.ResourceManager

	NATManager NATManagerC
	Peerstore  peerstore.Peerstore
	Reporter   metrics.Reporter

	MultiaddrResolver *madns.Resolver

	DisablePing bool

	Routing RoutingC

	EnableAutoRelay bool
	AutoRelayOpts   []autorelay.Option
	AutoNATConfig

	EnableHolePunching  bool
	HolePunchingOptions []holepunch.Option
}

Config describes a set of settings for a libp2p node

This is *not* a stable interface. Use the options defined in the root package.

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

Apply applies the given options to the config, returning the first error encountered (if any).

func (*Config) NewNode

func (cfg *Config) NewNode() (host.Host, error)

NewNode constructs a new libp2p Host from the Config.

This function consumes the config. Do not reuse it (really!).

type MsMuxC

type MsMuxC struct {
	MuxC
	ID string
}

MsMuxC is a tuple containing a multiplex transport constructor and a protocol ID.

type MsSecC

type MsSecC struct {
	SecC
	ID string
}

MsSecC is a tuple containing a security transport constructor and a protocol ID.

type MuxC

type MuxC func(h host.Host) (network.Multiplexer, error)

MuxC is a stream multiplex transport constructor.

func MuxerConstructor

func MuxerConstructor(m interface{}) (MuxC, error)

MuxerConstructor creates a multiplex constructor from the passed parameter using reflection.

type NATManagerC

type NATManagerC func(network.Network) bhost.NATManager

NATManagerC is a NATManager constructor.

type Option

type Option func(cfg *Config) error

Option is a libp2p config option that can be given to the libp2p constructor (`libp2p.New`).

type RoutingC

type RoutingC func(host.Host) (routing.PeerRouting, error)

type SecC

type SecC func(h host.Host) (sec.SecureTransport, error)

SecC is a security transport constructor.

func SecurityConstructor

func SecurityConstructor(security interface{}) (SecC, error)

SecurityConstructor creates a security constructor from the passed parameter using reflection.

type TptC

TptC is the type for libp2p transport constructors. You probably won't ever implement this function interface directly. Instead, pass your transport constructor to TransportConstructor.

func TransportConstructor

func TransportConstructor(tpt interface{}, opts ...interface{}) (TptC, error)

TransportConstructor uses reflection to turn a function that constructs a transport into a TptC.

You can pass either a constructed transport (something that implements `transport.Transport`) or a function that takes any of:

* The local peer ID. * A transport connection upgrader. * A private key. * A public key. * A Host. * A Network. * A Peerstore. * An address filter. * A security transport. * A stream multiplexer transport. * A private network protection key. * A connection gater.

And returns a type implementing transport.Transport and, optionally, an error (as the second argument).

Jump to

Keyboard shortcuts

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