package basichost

Import Path
	github.com/libp2p/go-libp2p/p2p/host/basic (on go.dev)

Dependency Relation
	imports 44 packages, and imported by 2 packages


Package-Level Type Names (total 5)
/* sort by: | */
AddrsFactory functions can be passed to New in order to override addresses returned by Addrs.
BasicHost is the basic implementation of the host.Host interface. This particular host implementation: - uses a protocol muxer to mux per-protocol streams - uses an identity service to send + receive node information - uses a nat service to establish NAT port mappings Addrs returns listening addresses. The output is the same as AllAddrs, but processed by AddrsFactory. When used with AutoRelay, and if the host is not publicly reachable, this will only have host's private, relay, and no public addresses. AllAddrs returns all the addresses the host is listening on except circuit addresses. Close shuts down the Host's services (network, etc). ConfirmedAddrs returns all addresses of the host grouped by their reachability as verified by autonatv2. Experimental: This API may change in the future without deprecation. Requires AutoNATv2 to be enabled. (*BasicHost) ConnManager() connmgr.ConnManager Connect ensures there is a connection between this host and the peer with given peer.ID. If there is not an active connection, Connect will issue a h.Network.Dial, and block until a connection is open, or an error is returned. Connect will absorb the addresses in pi into its internal peerstore. It will also resolve any /dns4, /dns6, and /dnsaddr addresses. (*BasicHost) EventBus() event.Bus GetAutoNat returns the host's AutoNAT service, if AutoNAT is enabled. Deprecated: Use `BasicHost.Reachability` to get the host's reachability. ID returns the (local) peer.ID associated with this Host IDService returns Mux returns the Mux multiplexing incoming streams to protocol handlers Network returns the Network interface of the Host NewStream opens a new stream to given peer p, and writes a p2p/protocol header with given protocol.ID. If there is no connection to p, attempts to create one. If ProtocolID is "", writes no header. (Thread-safe) NormalizeMultiaddr returns a multiaddr suitable for equality checks. If the multiaddr is a webtransport component, it removes the certhashes. Peerstore returns the Host's repository of Peer Addresses and Keys. Reachability returns the host's reachability status. RemoveStreamHandler returns .. SetAutoNat sets the autonat service for the host. SetStreamHandler sets the protocol handler on the Host's Mux. This is equivalent to: host.Mux().SetHandler(proto, handler) (Thread-safe) SetStreamHandlerMatch sets the protocol handler on the Host's Mux using a matching function to do protocol comparisons Start starts background tasks in the host TODO: Return error and handle it in the caller? *BasicHost : github.com/libp2p/go-libp2p/core/host.Host *BasicHost : github.com/prometheus/common/expfmt.Closer *BasicHost : io.Closer func NewHost(n network.Network, opts *HostOpts) (*BasicHost, error)
HostOpts holds options that can be passed to NewHost in order to customize construction of the *BasicHost. AddrsFactory holds a function which can be used to override or filter the result of Addrs. If omitted, there's no override or filtering, and the results of Addrs and AllAddrs are the same. AutoNATv2 *autonatv2.AutoNAT AutoNATv2MetricsTracker tracks AutoNATv2 address reachability metrics ConnManager is a libp2p connection manager DisableIdentifyAddressDiscovery disables address discovery using peer provided observed addresses in identify DisableSignedPeerRecord disables the generation of Signed Peer Records on this host. EnableHolePunching enables the peer to initiate/respond to hole punching attempts for NAT traversal. EnableMetrics enables the metrics subsystems EnablePing indicates whether to instantiate the ping service EnableRelayService enables the circuit v2 relay (if we're publicly reachable). EventBus sets the event bus. Will construct a new event bus if omitted. HolePunchingOptions are options for the hole punching service MultistreamMuxer is essential for the *BasicHost and will use a sensible default value if omitted. NATManager takes care of setting NAT port mappings, and discovering external addresses. If omitted, this will simply be disabled. NegotiationTimeout determines the read and write timeouts when negotiating protocols for streams. If 0 or omitted, it will use DefaultNegotiationTimeout. If below 0, timeouts on streams will be deactivated. PrometheusRegisterer is the PrometheusRegisterer used for metrics ProtocolVersion sets the protocol version for the host. RelayServiceOpts are options for the circuit v2 relay. UserAgent sets the user-agent for the host. func NewHost(n network.Network, opts *HostOpts) (*BasicHost, error)
MetricsTracker tracks autonatv2 reachability metrics ConfirmedAddrsChanged updates metrics with current address reachability status ReachabilityTrackerClosed updated metrics on host close
NATManager is a simple interface to manage NAT devices. It listens Listen and ListenClose notifications from the network.Network, and tries to obtain port mappings for those. ( NATManager) Close() error ( NATManager) GetMapping(ma.Multiaddr) ma.Multiaddr ( NATManager) HasDiscoveredNAT() bool NATManager : github.com/prometheus/common/expfmt.Closer NATManager : io.Closer func NewNATManager(net network.Network) NATManager
Package-Level Functions (total 2)
NewHost constructs a new *BasicHost and activates it by attaching its stream and connection handlers to the given inet.Network.
NewNATManager creates a NAT manager.
Package-Level Variables (total 2)
DefaultAddrsFactory is the default value for HostOpts.AddrsFactory.
DefaultNegotiationTimeout is the default value for HostOpts.NegotiationTimeout.