Skip to content

Commit

Permalink
Pass port opt on to hyperdht (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
HDegroote authored Nov 27, 2024
1 parent 200e6f2 commit 2ae3033
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions test/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {}

0 comments on commit 2ae3033

Please sign in to comment.