Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a868ebe
deps: update OpenSSL upgrade process
sam-github Mar 1, 2019
c80bff3
deps: upgrade openssl sources to 1.1.1b
sam-github Apr 25, 2019
63aa831
deps: openssl-1.1.1b no longer packages .gitignore
sam-github Feb 26, 2019
1cea121
deps: add ARM64 Windows support in openssl
shigeki Feb 23, 2019
c2310c7
deps: add s390 asm rules for OpenSSL-1.1.1
shigeki Mar 7, 2018
f54db0b
deps: update archs files for OpenSSL-1.1.1b
sam-github Apr 25, 2019
f47e208
tls: support changing credentials dynamically
cjihrig Oct 13, 2018
5f5d3c9
tls: get the local certificate after tls handshake
sam-github Nov 8, 2018
4a82835
tls: fix initRead socket argument name
sam-github Dec 19, 2018
78b42fc
tls: do not confuse session and session ID
sam-github Dec 19, 2018
a6635b2
src: use consistent names for JSStream
sam-github Dec 19, 2018
ae7c74c
tls: remove unused ocsp extension parsing
sam-github Dec 19, 2018
6b327e5
src: in-source comments and minor TLS cleanups
sam-github Jan 16, 2019
2d25b65
tls: introduce client 'session' event
sam-github Jan 30, 2019
8c7406f
tls: do not free cert in `.getCertificate()`
addaleax Jan 14, 2019
38838af
src: remove unused TLWrap::EnableTrace()
sam-github Jan 31, 2019
d3c7020
src: organize TLSWrap declarations by parent
sam-github Jan 31, 2019
1c3c9f3
tls: don't shadow the tls global with a local
sam-github Jan 31, 2019
750b906
src: const_cast is necessary for 1.1.1, not 0.9.7
sam-github Jan 31, 2019
5febe41
src: refactor SSLError case statement
sam-github Jan 31, 2019
1f65f18
tls: support "BEGIN TRUSTED CERTIFICATE" for ca:
sam-github Nov 30, 2018
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
Prev Previous commit
Next Next commit
src: use consistent names for JSStream
Its confusing to call a js class with a handle a "Wrap", usually it's
the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its
derived from Socket, and makes a JS stream look like a Socket, so call
it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated
some time.

PR-URL: #25153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
  • Loading branch information
sam-github committed Apr 29, 2019
commit a6635b2e6fe2ccfd5e4e56f7a32f31f120649fef
2 changes: 1 addition & 1 deletion lib/_stream_wrap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

module.exports = require('internal/wrap_js_stream');
module.exports = require('internal/js_stream_socket');
8 changes: 5 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const net = require('net');
const tls = require('tls');
const util = require('util');
const common = require('_tls_common');
const { StreamWrap } = require('_stream_wrap');
const JSStreamSocket = require('internal/js_stream_socket');
const { Buffer } = require('buffer');
const debug = util.debuglog('tls');
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
Expand Down Expand Up @@ -310,12 +310,14 @@ function TLSSocket(socket, opts) {
this.authorizationError = null;
this[kRes] = null;

// Wrap plain JS Stream into StreamWrap
var wrap;
if ((socket instanceof net.Socket && socket._handle) || !socket) {
wrap = socket;
} else {
wrap = new StreamWrap(socket);
// TLS expects to interact from C++ with a net.Socket that has a C++ stream
// handle, but a JS stream doesn't have one. Wrap it up to make it look like
// a socket.
wrap = new JSStreamSocket(socket);
wrap.once('close', () => this.destroy());
}

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const util = require('util');

const { kIncomingMessage } = require('_http_common');
const { kServerResponse } = require('_http_server');
const { StreamWrap } = require('_stream_wrap');
const JSStreamSocket = require('internal/js_stream_socket');

const {
defaultTriggerAsyncIdScope,
Expand Down Expand Up @@ -934,7 +934,7 @@ class Http2Session extends EventEmitter {
super();

if (!socket._handle || !socket._handle._externalStream) {
socket = new StreamWrap(socket);
socket = new JSStreamSocket(socket);
}

// No validation is performed on the input parameters because this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const util = require('util');
const { Socket } = require('net');
const { JSStream } = internalBinding('js_stream');
const uv = internalBinding('uv');
const debug = util.debuglog('stream_wrap');
const debug = util.debuglog('stream_socket');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { ERR_STREAM_WRAP } = require('internal/errors').codes;

Expand All @@ -29,17 +29,17 @@ function onwrite(req, bufs) { return this[owner_symbol].doWrite(req, bufs); }
* can skip going through the JS layer and let TLS access the raw C++ handle
* of a net.Socket. The flipside of this is that, to maintain composability,
* we need a way to create "fake" net.Socket instances that call back into a
* "real" JavaScript stream. JSStreamWrap is exactly this.
* "real" JavaScript stream. JSStreamSocket is exactly this.
*/
class JSStreamWrap extends Socket {
class JSStreamSocket extends Socket {
constructor(stream) {
const handle = new JSStream();
handle.close = (cb) => {
debug('close');
this.doClose(cb);
};
// Inside of the following functions, `this` refers to the handle
// and `this[owner_symbol]` refers to this JSStreamWrap instance.
// and `this[owner_symbol]` refers to this JSStreamSocket instance.
handle.isClosing = isClosing;
handle.onreadstart = onreadstart;
handle.onreadstop = onreadstop;
Expand Down Expand Up @@ -88,9 +88,10 @@ class JSStreamWrap extends Socket {
this.read(0);
}

// Legacy
// Allow legacy requires in the test suite to keep working:
// const { StreamWrap } = require('internal/js_stream_socket')
static get StreamWrap() {
return JSStreamWrap;
return JSStreamSocket;
}

isClosing() {
Expand Down Expand Up @@ -223,4 +224,4 @@ class JSStreamWrap extends Socket {
}
}

module.exports = JSStreamWrap;
module.exports = JSStreamSocket;
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
'lib/internal/fs/watchers.js',
'lib/internal/http.js',
'lib/internal/inspector_async_hook.js',
'lib/internal/js_stream_socket.js',
'lib/internal/linkedlist.js',
'lib/internal/modules/cjs/helpers.js',
'lib/internal/modules/cjs/loader.js',
Expand Down Expand Up @@ -182,7 +183,6 @@
'lib/internal/streams/state.js',
'lib/internal/streams/pipeline.js',
'lib/internal/streams/end-of-stream.js',
'lib/internal/wrap_js_stream.js',
'deps/v8/tools/splaytree.js',
'deps/v8/tools/codemap.js',
'deps/v8/tools/consarray.js',
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-stream-wrap-drain.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const { StreamWrap } = require('_stream_wrap');
const { StreamWrap } = require('internal/js_stream_socket');
const { Duplex } = require('stream');
const { ShutdownWrap } = process.binding('stream_wrap');

// This test makes sure that when an instance of JSStreamWrap is waiting for
// This test makes sure that when a wrapped stream is waiting for
// a "drain" event to `doShutdown`, the instance will work correctly when a
// "drain" event emitted.
{
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-stream-wrap-encoding.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');

const StreamWrap = require('_stream_wrap');
const StreamWrap = require('internal/js_stream_socket');
const Duplex = require('stream').Duplex;

{
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-stream-wrap.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');

const StreamWrap = require('_stream_wrap');
const Duplex = require('stream').Duplex;
const StreamWrap = require('internal/js_stream_socket');
const { Duplex } = require('stream');
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;

function testShutdown(callback) {
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-wrap-js-stream-destroy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');
const StreamWrap = require('_stream_wrap');
const StreamWrap = require('internal/js_stream_socket');
const net = require('net');

// This test ensures that when we directly call `socket.destroy()` without
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-wrap-js-stream-duplex.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const StreamWrap = require('_stream_wrap');
const StreamWrap = require('internal/js_stream_socket');
const { PassThrough } = require('stream');
const { Socket } = require('net');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-wrap-js-stream-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const JSStreamWrap = require('internal/wrap_js_stream');
const JSStreamWrap = require('internal/js_stream_socket');
const { Duplex } = require('stream');

process.once('uncaughtException', common.mustCall((err) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-wrap-js-stream-read-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require('../common');
const assert = require('assert');
const WrapStream = require('internal/wrap_js_stream');
const WrapStream = require('internal/js_stream_socket');
const Stream = require('stream');

class FakeStream extends Stream {
Expand Down