Skip to content

Commit

Permalink
tls: honor pauseOnConnect option
Browse files Browse the repository at this point in the history
`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: #29620
Refs: #27665

PR-URL: #29635
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
r1b authored and BridgeAR committed Oct 9, 2019
1 parent ea9bf4a commit a7b56a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-tls-server-parent-constructor-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down

0 comments on commit a7b56a5

Please sign in to comment.