From 1e1285926f35558f8ad1dad5fad2040ce576f46e Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Fri, 20 Sep 2019 14:15:16 -0400 Subject: [PATCH] tls: honor pauseOnConnect option `pauseOnConnect` is now passed along to the net.Socket constructor from the tls.Socket constructor. The `readable` flag must match the value of `pauseOnConnect`. Tests were added to cover all available net.Server options when used in the tls.Server constructor. Fixes: https://github.com/nodejs/node/issues/29620 Refs: https://github.com/nodejs/node/pull/27665 PR-URL: https://github.com/nodejs/node/pull/29635 Reviewed-By: Luigi Pinca --- lib/_tls_wrap.js | 7 +++++-- .../parallel/test-tls-server-parent-constructor-options.js | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index d29182d585779b..db6f6b5e765f0b 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -411,7 +411,9 @@ function TLSSocket(socket, opts) { net.Socket.call(this, { handle: this._wrapHandle(wrap), allowHalfOpen: socket ? socket.allowHalfOpen : tlsOptions.allowHalfOpen, - readable: false, + pauseOnCreate: tlsOptions.pauseOnConnect, + // The readable flag is only needed if pauseOnCreate will be handled. + readable: tlsOptions.pauseOnConnect, writable: false }); @@ -926,7 +928,8 @@ function tlsConnectionListener(rawSocket) { handshakeTimeout: this[kHandshakeTimeout], ALPNProtocols: this.ALPNProtocols, SNICallback: this[kSNICallback] || SNICallback, - enableTrace: this[kEnableTrace] + enableTrace: this[kEnableTrace], + pauseOnConnect: this.pauseOnConnect, }); socket.on('secure', onServerSocketSecure); diff --git a/test/parallel/test-tls-server-parent-constructor-options.js b/test/parallel/test-tls-server-parent-constructor-options.js index 17484c29bae930..f8b34e8b0cab62 100644 --- a/test/parallel/test-tls-server-parent-constructor-options.js +++ b/test/parallel/test-tls-server-parent-constructor-options.js @@ -19,9 +19,11 @@ const options = { { const server = tls.createServer(options, common.mustCall((socket) => { assert.strictEqual(socket.allowHalfOpen, false); + assert.strictEqual(socket.isPaused(), false); })); assert.strictEqual(server.allowHalfOpen, false); + assert.strictEqual(server.pauseOnConnect, false); server.listen(0, common.mustCall(() => { const socket = tls.connect({ @@ -40,13 +42,16 @@ const options = { { const server = tls.createServer({ allowHalfOpen: true, + pauseOnConnect: true, ...options }, common.mustCall((socket) => { assert.strictEqual(socket.allowHalfOpen, true); + assert.strictEqual(socket.isPaused(), true); socket.on('end', socket.end); })); assert.strictEqual(server.allowHalfOpen, true); + assert.strictEqual(server.pauseOnConnect, true); server.listen(0, common.mustCall(() => { const socket = tls.connect({