p2p/protocol/holepunch library
Package holepunch provides the holepunch service for libp2p.
The holepunch service provides direct connection establishment capabilities for libp2p nodes behind NATs/firewalls. It coordinates hole punching between peers to establish direct connections.
This is a port of the Go implementation from go-libp2p/p2p/protocol/holepunch to Dart, using native Dart idioms.
Classes
- AddrFilter
- Address filter for the holepuncher
- BasicAddrFilter
- Basic address filter implementation for the holepunch protocol
- BasicHolePunchTracer
- Basic tracer implementation for the holepunch protocol
- HolePuncher
- The holepuncher is run on the peer that's behind a NAT / Firewall. It observes new incoming connections via a relay that it has a reservation with, and initiates the DCUtR protocol with them. It then first tries to establish a direct connection, and if that fails, it initiates a hole punch.
- HolePunchOptions
- Options for the holepunch service
- HolePunchResult
- Result of initiating a hole punch
- HolePunchService
- HolePunchService is the interface for the holepunch service.
- HolePunchServiceImpl
- Implementation of the holepunch service
- HolePunchTracer
- Tracer for the holepuncher
- IncomingHolePunchResult
- Result of an incoming hole punch
- MetricsTracer
- Metrics tracer for the holepunch protocol
- NoopAddrFilter
- No-op address filter implementation for the holepunch protocol
Extensions
- HolePunchTracerExt on HolePunchTracer
- Extension for the HolePunchTracer
Constants
- dialTimeout → const Duration
- Dial timeout for hole punching
- maxMsgSize → const int
- Maximum message size for the holepunch protocol
- maxRetries → const int
- Maximum number of retries for hole punching
- protocolId → const String
- Protocol ID for the holepunch protocol
- serviceName → const String
- Service name for the holepunch protocol
- streamTimeout → const Duration
- Stream timeout for the holepunch protocol
Functions
-
addrsFromBytes(
List bytes) → List< MultiAddr> - Converts a list of byte arrays to a list of multiaddrs
-
addrsToBytes(
List< MultiAddr> addrs) → List<Uint8List> - Converts a list of multiaddrs to a list of byte arrays
-
getDirectConnection(
Host host, PeerId peerId) → Conn? - Gets a direct (non-relay) connection to a peer if one exists
-
isRelayAddress(
MultiAddr addr) → bool - Checks if a multiaddr is a relay address
-
newHolePunchService(
Host host, IDService ids, List< MultiAddr> listenAddrs(), {HolePunchOptions? options}) → Future<HolePunchService> - Creates a new holepunch service.
-
removeRelayAddrs(
List< MultiAddr> addrs) → List<MultiAddr> - Removes relay addresses from a list of multiaddrs
Exceptions / Errors
- ClosedError
- Error thrown when the holepunch service is closed
- HolePunchActiveError
- Error thrown when another hole punching attempt is currently running