holepunch

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HolePunch

type HolePunch struct {
	// contains filtered or unexported fields
}

HolePunch is one of way of nat traversal hole punch only success when udp and some nat type situation func HolePunchAvailable() can judge the situation if punch success

func NewHolePunch

func NewHolePunch(log api.Logger) (*HolePunch, error)

NewHolePunch .

@Description:  new a HolePunch
@param log:
@return *HolePunch:
@return error:

func (*HolePunch) DirectConnect

func (d *HolePunch) DirectConnect(otherPeerAddr ma.Multiaddr) (network.Conn, error)

DirectConnect .

@Description: try punch,if hole punch success return a networkConn and err is nil
@receiver d
@param otherPeerAddr:
@return network.Conn:
@return error:

func (*HolePunch) HandlePeerDisconnect

func (d *HolePunch) HandlePeerDisconnect(_ peer.ID, msgPayload []byte)

HandlePeerDisconnect .

@Description:
 handle notify peer offline
 when get this msg,should stop holePunch to the peer immediately
@receiver d
@param _:
@param msgPayload:

func (*HolePunch) HolePunchAvailable

func (d *HolePunch) HolePunchAvailable(type1, type2 stun.NATDeviceType) bool

HolePunchAvailable .

@Description:  provide a func to calculate a result if punch is available between two nat type
@receiver d
@param type1:
@param type2:
@return bool:

func (*HolePunch) ListenForNat

func (d *HolePunch) ListenForNat(listenAddr []ma.Multiaddr, already []ma.Multiaddr) error

ListenForNat .

@Description: called when nat change port
@receiver d
@param listenAddr:
@param already:
@return error:

func (*HolePunch) SetHost

func (d *HolePunch) SetHost(host host.Host) error

SetHost .

@Description: set host for HolePunch
@receiver d
@param host: need host.listen and dial
@return error:

func (*HolePunch) SetTimeSpace

func (d *HolePunch) SetTimeSpace(time int)

SetTimeSpace .

@Description: TimeSpace is wait time between two dial
@receiver d
@param time: default == const timeSpace

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL