From 73864e832e52d6cde4d270504ed2558e57911bde Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Thu, 28 May 2020 14:50:08 +0200 Subject: [PATCH] always set punch.to --- index.js | 3 ++- lib/io.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index bcb75c6..a4cfb65 100644 --- a/index.js +++ b/index.js @@ -115,6 +115,7 @@ class DHT extends EventEmitter { if (!to || samePeer(to, peer)) return message.version = IO.VERSION message.id = this._io.id + message.to = peers.encode([to]) message.value = Holepunch.encode({ from: peers.encode([peer]) }) this.emit('holepunch', peer, to) this._io.send(Message.encode(message), to) @@ -248,7 +249,7 @@ class DHT extends EventEmitter { node.host = peer.host if (token) node.roundtripToken = token node.tick = this._tick - node.to = to + if (to) node.to = to if (!fresh) this.nodes.remove(node) this.bucket.add(node) diff --git a/lib/io.js b/lib/io.js index 41b1e64..bf32217 100644 --- a/lib/io.js +++ b/lib/io.js @@ -80,7 +80,9 @@ class IO { const punch = { version: VERSION, - type: req.message.type, + type: TYPE.QUERY, + to: encodeIP(req.peer.referrer), + id: req.message.id, rid, command: '_holepunch', value: Holepunch.encode({