Browse Source

always set punch.to

v4
Mathias Buus 5 years ago
parent
commit
73864e832e
  1. 3
      index.js
  2. 4
      lib/io.js

3
index.js

@ -115,6 +115,7 @@ class DHT extends EventEmitter {
if (!to || samePeer(to, peer)) return if (!to || samePeer(to, peer)) return
message.version = IO.VERSION message.version = IO.VERSION
message.id = this._io.id message.id = this._io.id
message.to = peers.encode([to])
message.value = Holepunch.encode({ from: peers.encode([peer]) }) message.value = Holepunch.encode({ from: peers.encode([peer]) })
this.emit('holepunch', peer, to) this.emit('holepunch', peer, to)
this._io.send(Message.encode(message), to) this._io.send(Message.encode(message), to)
@ -248,7 +249,7 @@ class DHT extends EventEmitter {
node.host = peer.host node.host = peer.host
if (token) node.roundtripToken = token if (token) node.roundtripToken = token
node.tick = this._tick node.tick = this._tick
node.to = to if (to) node.to = to
if (!fresh) this.nodes.remove(node) if (!fresh) this.nodes.remove(node)
this.bucket.add(node) this.bucket.add(node)

4
lib/io.js

@ -80,7 +80,9 @@ class IO {
const punch = { const punch = {
version: VERSION, version: VERSION,
type: req.message.type, type: TYPE.QUERY,
to: encodeIP(req.peer.referrer),
id: req.message.id,
rid, rid,
command: '_holepunch', command: '_holepunch',
value: Holepunch.encode({ value: Holepunch.encode({

Loading…
Cancel
Save