tls: do not wrap net.Socket with StreamWrap
Fixes: https://github.com/nodejs/node/issues/3655 PR-URL: https://github.com/nodejs/node/pull/12799 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
parent
ef16319eff
commit
b23d414c7e
@ -31,7 +31,6 @@ const util = require('util');
|
|||||||
const common = require('_tls_common');
|
const common = require('_tls_common');
|
||||||
const StreamWrap = require('_stream_wrap').StreamWrap;
|
const StreamWrap = require('_stream_wrap').StreamWrap;
|
||||||
const Buffer = require('buffer').Buffer;
|
const Buffer = require('buffer').Buffer;
|
||||||
const Duplex = require('stream').Duplex;
|
|
||||||
const debug = util.debuglog('tls');
|
const debug = util.debuglog('tls');
|
||||||
const Timer = process.binding('timer_wrap').Timer;
|
const Timer = process.binding('timer_wrap').Timer;
|
||||||
const tls_wrap = process.binding('tls_wrap');
|
const tls_wrap = process.binding('tls_wrap');
|
||||||
@ -275,12 +274,10 @@ function TLSSocket(socket, options) {
|
|||||||
|
|
||||||
// Wrap plain JS Stream into StreamWrap
|
// Wrap plain JS Stream into StreamWrap
|
||||||
var wrap;
|
var wrap;
|
||||||
if (!(socket instanceof net.Socket) && socket instanceof Duplex)
|
if ((socket instanceof net.Socket && socket._handle) || !socket)
|
||||||
wrap = new StreamWrap(socket);
|
|
||||||
else if ((socket instanceof net.Socket) && !socket._handle)
|
|
||||||
wrap = new StreamWrap(socket);
|
|
||||||
else
|
|
||||||
wrap = socket;
|
wrap = socket;
|
||||||
|
else
|
||||||
|
wrap = new StreamWrap(socket);
|
||||||
|
|
||||||
// Just a documented property to make secure sockets
|
// Just a documented property to make secure sockets
|
||||||
// distinguishable from regular ones.
|
// distinguishable from regular ones.
|
||||||
|
16
test/parallel/test-tls-wrap-event-emmiter.js
Normal file
16
test/parallel/test-tls-wrap-event-emmiter.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Issue: https://github.com/nodejs/node/issues/3655
|
||||||
|
* Test checks if we get exception instead of runtime error
|
||||||
|
*/
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const TlsSocket = require('tls').TLSSocket;
|
||||||
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
assert.throws(
|
||||||
|
() => { new TlsSocket(new EventEmitter()); },
|
||||||
|
/^TypeError: this\.stream\.pause is not a function/
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user