Documentation
¶
Overview ¶
Package transport builds a libp2p Host configured with the wire concerns agenthive needs: TCP + QUIC-v1, Noise (with TLS as a fallback ciphersuite configured by libp2p's DefaultSecurity), yamux muxers (DefaultMuxers), NAT traversal (NATPortMap + EnableNATService + EnableHolePunching), and circuit-relay v2 (EnableRelayService + EnableAutoRelayWithPeerSource).
The discovery package owns mDNS — Config.EnableMDNS is informational only and the host itself is built independent of discovery so it can be tested without spinning up the LAN service.
Callers are responsible for closing the returned Host.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MultiaddrsFor ¶
MultiaddrsFor returns the list of /ip*/.../p2p/<peerid> strings advertising the host. Returns nil for a nil host.
Each returned string is a fully-qualified multiaddr including the host's PeerID, suitable for pasting into `agenthive peers add`. The list is the host's current listen addresses (post-listener-binding so the ephemeral ports are concrete) joined with `/p2p/<peerid>`.
func New ¶
New constructs a libp2p Host wired with the agenthive transport options. Callers must invoke host.Close on the returned Host.
The returned Host listens on cfg.ListenAddrs (or the package default if empty), advertises Noise as the primary security ciphersuite (with libp2p's default TLS fallback enabled via DefaultSecurity option chain through the explicit Security override), uses the TCP and QUIC-v1 transports, the default yamux muxer, and the full NAT traversal + circuit-relay stack.
Types ¶
type Config ¶
type Config struct {
// Identity is the libp2p private key. Required.
Identity crypto.PrivKey
// ListenAddrs is the list of multiaddr strings the host listens on.
// Defaults to TCP+QUIC on all v4 and v6 interfaces, ephemeral ports.
ListenAddrs []string
// EnableMDNS is informational only; the discovery package owns mDNS.
EnableMDNS bool
// PeerSource is the AutoRelay peer-source closure. If nil, the host
// uses an internal no-op closure that returns an empty closed channel
// (relays must be dialled directly). The daemon supplies a closure
// that surfaces the CRDT peer set so AutoRelay can request reservations
// from peers the mesh already knows about.
PeerSource func(ctx context.Context, num int) <-chan peer.AddrInfo
}
Config controls the libp2p Host that New constructs.