package holepunch
Import Path
github.com/libp2p/go-libp2p/p2p/protocol/holepunch (on go.dev)
Dependency Relation
imports 18 packages, and imported by 3 packages
Package-Level Type Names (total 12)
AddrFilter defines the interface for the multi address filtering.
FilterLocal filters the multi addresses that are sent to the remote peer.
FilterRemote filters the multi addresses received from the remote peer.
func WithAddrFilter(f AddrFilter) Option
// the actual event
// local peer ID
// remote peer ID
// UNIX nanos
// event type
func EventTracer.Trace(evt *Event)
( EventTracer) Trace(evt *Event)
func WithMetricsAndEventTracer(mt MetricsTracer, et EventTracer) Option
func WithTracer(et EventTracer) Option
( MetricsTracer) DirectDialFinished(success bool)
( MetricsTracer) HolePunchFinished(side string, attemptNum int, theirAddrs []ma.Multiaddr, ourAddr []ma.Multiaddr, directConn network.ConnMultiaddrs)
func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer
func WithMetricsAndEventTracer(mt MetricsTracer, et EventTracer) Option
func WithMetricsTracer(mt MetricsTracer) Option
func WithRegisterer(reg prometheus.Registerer) MetricsTracerOption
func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer
func DirectDialTimeout(timeout time.Duration) Option
func WithAddrFilter(f AddrFilter) Option
func WithMetricsAndEventTracer(mt MetricsTracer, et EventTracer) Option
func WithMetricsTracer(mt MetricsTracer) Option
func WithTracer(et EventTracer) Option
func NewService(h host.Host, ids identify.IDService, listenAddrs func() []ma.Multiaddr, opts ...Option) (*Service, error)
func github.com/libp2p/go-libp2p.EnableHolePunching(opts ...Option) libp2p.Option
The Service runs on every node that supports the DCUtR protocol.
Close closes the Hole Punch Service.
DirectConnect is only exposed for testing purposes.
TODO: find a solution for this.
SetLegacyBehavior is only exposed for testing purposes.
Do not set this unless you know what you are doing.
*Service : github.com/prometheus/common/expfmt.Closer
*Service : io.Closer
func NewService(h host.Host, ids identify.IDService, listenAddrs func() []ma.Multiaddr, opts ...Option) (*Service, error)
Package-Level Functions (total 8)
func DirectDialTimeout(timeout time.Duration) Option func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer
NewService creates a new service that can be used for hole punching
The Service runs on all hosts that support the DCUtR protocol,
no matter if they are behind a NAT / firewall or not.
The Service handles DCUtR streams (which are initiated from the node behind
a NAT / Firewall once we establish a connection to them through a relay.
listenAddrs MUST only return public addresses.
WithAddrFilter is a Service option that enables multiaddress filtering.
It allows to only send a subset of observed addresses to the remote
peer. E.g., only announce TCP or QUIC multi addresses instead of both.
It also allows to only consider a subset of received multi addresses
that remote peers announced to us.
Theoretically, this API also allows to add multi addresses in both cases.
WithMetricsAndEventTracer enables holepunch tracking with MetricsTracer and EventTracer
WithMetricsTracer enables holepunch Tracing with MetricsTracer mt
WithTracer enables holepunch tracing with EventTracer et
Package-Level Variables (total 3)
ErrClosed is returned when the hole punching is closed
ErrHolePunchActive is returned from DirectConnect when another hole punching attempt is currently running
StreamTimeout is the timeout for the hole punch protocol stream.
Package-Level Constants (total 7)
Event Types
Event Types
Event Types
Protocol is the libp2p protocol for Hole Punching.
Event Types
const ServiceName = "libp2p.holepunch"
Event Types
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |