Simple UTP holepunch helper
See /examples/
Creates new instance, takes an existing, bound socket.
const opts = {
handshakes: cacheOpts,
min: 2,
max: 5,
delay: 50,
control: 'ÿ'
}
return new Holepuncher(socket, opts).register()
Options:
control
: character send to filter out holepunche packetshandshakes
: cache options for handshake target tabledelay
: delay between sending UTP packets to target in case of handshakemin
: min packets to receive for successful handshakemax
: max packets to send for a handshake with a target
Needed to use the boxgloves instance. Wraps the socket with additional event/message handling.
Sends a UTP packet to target. Target is an object containing port and address.
The content of the packet is a control character. Default: ÿ
Example:
hp.punch({ address: '127.0.0.1', port: 12345 })
Returns address and port as an object from current socket
Emitted on receiving a control character. Emits the senders ip/port as object.
Enable handshake functionality
Will send a pre-defined number of maximum packets to a target (default: 5
).
Additionally listens for 30secs for any received packets.
If the minimum value of received packets is reached (default: 2
), a handshake
event is emitted.
Emitted after a successful handshake.