Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = class Server extends EventEmitter {
this.createHandshake = opts.createHandshake || defaultCreateHandshake
this.createSecretStream = opts.createSecretStream || defaultCreateSecretStream
this.suspended = false
this.handshakeClearWait = opts.handshakeClearWait || HANDSHAKE_CLEAR_WAIT

this._shareLocalAddress = opts.shareLocalAddress !== false
this._reusableSocket = !!opts.reusableSocket
Expand Down Expand Up @@ -423,7 +424,7 @@ module.exports = class Server extends EventEmitter {

_clearLater (hs, id, k) {
if (hs.clearing) return
hs.clearing = setTimeout(() => this._clear(hs, id, k), HANDSHAKE_CLEAR_WAIT)
hs.clearing = setTimeout(() => this._clear(hs, id, k), this.handshakeClearWait)
}

_clear (hs, id, k) {
Expand Down
13 changes: 13 additions & 0 deletions test/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,3 +792,16 @@ test('Populate DHT with options.nodes', async function (t) {
a.destroy()
b.destroy()
})

test('create server with handshakeClearWait opt', async function (t) {
const [a] = await swarm(t)

{
const server = a.createServer({ handshakeClearWait: 123 })
t.is(server.handshakeClearWait, 123)
}
{
const server = a.createServer({})
t.is(server.handshakeClearWait, 10000, 'expected default')
}
})
Loading