Documentation ¶
Index ¶
Constants ¶
const ( DirectDialEvtT = "DirectDial" ProtocolErrorEvtT = "ProtocolError" StartHolePunchEvtT = "StartHolePunch" EndHolePunchEvtT = "EndHolePunch" HolePunchAttemptEvtT = "HolePunchAttempt" )
Event Types
const Protocol protocol.ID = "/libp2p/dcutr"
Protocol is the libp2p protocol for Hole Punching.
const (
ServiceName = "libp2p.holepunch"
)
Variables ¶
var ErrClosed = errors.New("hole punching service closing")
ErrClosed is returned when the hole punching is closed
var ErrHolePunchActive = errors.New("another hole punching attempt to this peer is active")
ErrHolePunchActive is returned from DirectConnect when another hole punching attempt is currently running
var StreamTimeout = 1 * time.Minute
StreamTimeout is the timeout for the hole punch protocol stream.
Functions ¶
This section is empty.
Types ¶
type DirectDialEvt ¶
type DirectDialEvt struct { Success bool EllapsedTime time.Duration Error string `json:",omitempty"` }
Event Objects
type EndHolePunchEvt ¶
type EventTracer ¶
type EventTracer interface {
Trace(evt *Event)
}
type HolePunchAttemptEvt ¶
type HolePunchAttemptEvt struct {
Attempt int
}
type Option ¶
func WithTracer ¶
func WithTracer(tr EventTracer) Option
WithTracer is a Service option that enables hole punching tracing
type ProtocolErrorEvt ¶
type ProtocolErrorEvt struct {
Error string
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
The Service runs on every node that supports the DCUtR protocol.
func NewService ¶
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.