Skip to content

Commit 2ae3033

Browse files
authored
Pass port opt on to hyperdht (#186)
1 parent 200e6f2 commit 2ae3033

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ module.exports = class Hyperswarm extends EventEmitter {
3535

3636
this.dht = opts.dht || new DHT({
3737
bootstrap: opts.bootstrap,
38-
nodes: opts.nodes
38+
nodes: opts.nodes,
39+
port: opts.port
3940
})
4041
this.server = this.dht.createServer({
4142
firewall: this._handleFirewall.bind(this),

test/swarm.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,4 +745,12 @@ test('topic and peer get unslabbed in PeerInfo', async (t) => {
745745
swarm2.join(topic, { client: true, server: false })
746746
})
747747

748+
test('port opt gets passed on to hyperdht', async (t) => {
749+
const { bootstrap } = await createTestnet(3, t.teardown)
750+
751+
const swarm1 = new Hyperswarm({ bootstrap, port: [10000, 10100] })
752+
t.alike(swarm1.dht.io.portRange, [10000, 10100])
753+
await swarm1.destroy()
754+
})
755+
748756
function noop () {}

0 commit comments

Comments
 (0)