From 2ae3033cf9ef11deebb01a2e977d310dddc97c0e Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:40:07 +0100 Subject: [PATCH] Pass port opt on to hyperdht (#186) --- index.js | 3 ++- test/swarm.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index cbe2250..ef65fba 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,8 @@ module.exports = class Hyperswarm extends EventEmitter { this.dht = opts.dht || new DHT({ bootstrap: opts.bootstrap, - nodes: opts.nodes + nodes: opts.nodes, + port: opts.port }) this.server = this.dht.createServer({ firewall: this._handleFirewall.bind(this), diff --git a/test/swarm.js b/test/swarm.js index 662e8c8..f80291a 100644 --- a/test/swarm.js +++ b/test/swarm.js @@ -745,4 +745,12 @@ test('topic and peer get unslabbed in PeerInfo', async (t) => { swarm2.join(topic, { client: true, server: false }) }) +test('port opt gets passed on to hyperdht', async (t) => { + const { bootstrap } = await createTestnet(3, t.teardown) + + const swarm1 = new Hyperswarm({ bootstrap, port: [10000, 10100] }) + t.alike(swarm1.dht.io.portRange, [10000, 10100]) + await swarm1.destroy() +}) + function noop () {}