Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with upstream fork #2

Closed
wants to merge 7 commits into from
Closed
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

Version 1.0.31
--------------
*Released 2019-12-06*

* Fix [infinite loop in error handling](https://github.com/theturtle32/WebSocket-Node/issues/329) (Thanks, [@apirila](https://github.com/apirila))
* Fix [memory leak with multiple WebSocket servers on the same HTTP server](https://github.com/theturtle32/WebSocket-Node/pull/339) (Thanks, [@nazar-pc](https://github.com/nazar-pc))
* [Use es5-ext/global as a more robust way to resolve browser's window object](https://github.com/theturtle32/WebSocket-Node/pull/362) (Thanks, [@michaelsbradleyjr](https://github.com/michaelsbradleyjr))
* [adding compatibility with V8 release greater than v7.6 (node and electron engines)](https://github.com/theturtle32/WebSocket-Node/pull/376) (Thanks, [@artynet](https://github.com/artynet))

Version 1.0.30
--------------
*Released 2019-09-12*

* Moved gulp back to devDependencies

Version 1.0.29
--------------
*Released 2019-07-03*
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ WebSocket Client & Server Implementation for Node

[![NPM Downloads](https://img.shields.io/npm/dm/websocket.svg)](https://www.npmjs.com/package/websocket)

[![NPM](https://nodei.co/npm/websocket.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/websocket/)

[![NPM](https://nodei.co/npm-dl/websocket.png?height=3)](https://nodei.co/npm/websocket/)

[ ![Codeship Status for theturtle32/WebSocket-Node](https://codeship.com/projects/70458270-8ee7-0132-7756-0a0cf4fe8e66/status?branch=master)](https://codeship.com/projects/61106)

Overview
Expand All @@ -27,9 +23,12 @@ Documentation
Changelog
---------

***Current Version: 1.0.29*** — Released 2019-07-03
***Current Version: 1.0.31*** — Released 2019-12-06

* Updated some dependencies and updated the .gitignore and .npmignore files
* Fix [infinite loop in error handling](https://github.com/theturtle32/WebSocket-Node/issues/329) (Thanks, [@apirila](https://github.com/apirila))
* Fix [memory leak with multiple WebSocket servers on the same HTTP server](https://github.com/theturtle32/WebSocket-Node/pull/339) (Thanks, [@nazar-pc](https://github.com/nazar-pc))
* [Use es5-ext/global as a more robust way to resolve browser's window object](https://github.com/theturtle32/WebSocket-Node/pull/362) (Thanks, [@michaelsbradleyjr](https://github.com/michaelsbradleyjr))
* [Adding compatibility with V8 release greater than v7.6 (node and electron engines)](https://github.com/theturtle32/WebSocket-Node/pull/376) (Thanks, [@artynet](https://github.com/artynet))

[View the full changelog](CHANGELOG.md)

Expand Down
2 changes: 1 addition & 1 deletion lib/WebSocketConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ WebSocketConnection.prototype.handleSocketError = function(error) {
if (utils.eventEmitterListenerCount(this, 'error') > 0) {
this.emit('error', error);
}
this.socket.destroy(error);
this.socket.destroy();
this._debug.printOutput();
};

Expand Down
4 changes: 4 additions & 0 deletions lib/WebSocketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ WebSocketServer.prototype.shutDown = function() {
};

WebSocketServer.prototype.handleUpgrade = function(request, socket) {
var self = this;
var wsRequest = new WebSocketRequest(socket, request, this.config);
try {
wsRequest.readHandshake();
Expand All @@ -208,6 +209,9 @@ WebSocketServer.prototype.handleUpgrade = function(request, socket) {

wsRequest.once('requestAccepted', this._handlers.requestAccepted);
wsRequest.once('requestResolved', this._handlers.requestResolved);
socket.once('close', function () {
self._handlers.requestResolved(wsRequest);
});

if (!this.config.autoAcceptConnections && utils.eventEmitterListenerCount(this, 'request') > 0) {
this.emit('request', wsRequest);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"contributors": [
"Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"
],
"version": "1.0.29",
"version": "1.0.31",
"repository": {
"type": "git",
"url": "https://github.com/theturtle32/WebSocket-Node.git"
Expand Down
20 changes: 10 additions & 10 deletions src/bufferutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BufferUtil : public ObjectWrap
Nan::SetMethod(t, "unmask", BufferUtil::Unmask);
Nan::SetMethod(t, "mask", BufferUtil::Mask);
Nan::SetMethod(t, "merge", BufferUtil::Merge);
Nan::Set(target, Nan::New<String>("BufferUtil").ToLocalChecked(), t->GetFunction());
Nan::Set(target, Nan::New<String>("BufferUtil").ToLocalChecked(), Nan::GetFunction(t).ToLocalChecked());
}

protected:
Expand All @@ -47,14 +47,14 @@ class BufferUtil : public ObjectWrap
static NAN_METHOD(Merge)
{
Nan::HandleScope scope;
Local<Object> bufferObj = info[0]->ToObject();
Local<Object> bufferObj = Nan::To<v8::Object>(info[0]).ToLocalChecked();
char* buffer = Buffer::Data(bufferObj);
Local<Array> array = Local<Array>::Cast(info[1]);
unsigned int arrayLength = array->Length();
size_t offset = 0;
unsigned int i;
for (i = 0; i < arrayLength; ++i) {
Local<Object> src = array->Get(i)->ToObject();
Local<Object> src = Nan::To<v8::Object>(Nan::Get(array, Nan::New(i)).ToLocalChecked()).ToLocalChecked();
size_t length = Buffer::Length(src);
memcpy(buffer + offset, Buffer::Data(src), length);
offset += length;
Expand All @@ -65,9 +65,9 @@ class BufferUtil : public ObjectWrap
static NAN_METHOD(Unmask)
{
Nan::HandleScope scope;
Local<Object> buffer_obj = info[0]->ToObject();
Local<Object> buffer_obj = Nan::To<v8::Object>(info[0]).ToLocalChecked();
size_t length = Buffer::Length(buffer_obj);
Local<Object> mask_obj = info[1]->ToObject();
Local<Object> mask_obj = Nan::To<v8::Object>(info[1]).ToLocalChecked();
unsigned int *mask = (unsigned int*)Buffer::Data(mask_obj);
unsigned int* from = (unsigned int*)Buffer::Data(buffer_obj);
size_t len32 = length / 4;
Expand All @@ -86,12 +86,12 @@ class BufferUtil : public ObjectWrap
static NAN_METHOD(Mask)
{
Nan::HandleScope scope;
Local<Object> buffer_obj = info[0]->ToObject();
Local<Object> mask_obj = info[1]->ToObject();
Local<Object> buffer_obj = Nan::To<v8::Object>(info[0]).ToLocalChecked();
Local<Object> mask_obj = Nan::To<v8::Object>(info[1]).ToLocalChecked();
unsigned int *mask = (unsigned int*)Buffer::Data(mask_obj);
Local<Object> output_obj = info[2]->ToObject();
unsigned int dataOffset = info[3]->Int32Value();
unsigned int length = info[4]->Int32Value();
Local<Object> output_obj = Nan::To<v8::Object>(info[2]).ToLocalChecked();
unsigned int dataOffset = Nan::To<v8::Int32>(info[3]).ToLocalChecked()->Value();
unsigned int length = Nan::To<v8::Int32>(info[4]).ToLocalChecked()->Value();
unsigned int* to = (unsigned int*)(Buffer::Data(output_obj) + dataOffset);
unsigned int* from = (unsigned int*)Buffer::Data(buffer_obj);
unsigned int len32 = length / 4;
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Validation : public ObjectWrap
Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
t->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetMethod(t, "isValidUTF8", Validation::IsValidUTF8);
Nan::Set(target, Nan::New<String>("Validation").ToLocalChecked(), t->GetFunction());
Nan::Set(target, Nan::New<String>("Validation").ToLocalChecked(), Nan::GetFunction(t).ToLocalChecked());
}

protected:
Expand All @@ -130,7 +130,7 @@ class Validation : public ObjectWrap
if (!Buffer::HasInstance(info[0])) {
return Nan::ThrowTypeError("First argument needs to be a buffer");
}
Local<Object> buffer_obj = info[0]->ToObject();
Local<Object> buffer_obj = Nan::To<v8::Object>(info[0]).ToLocalChecked();
char *buffer_data = Buffer::Data(buffer_obj);
size_t buffer_length = Buffer::Length(buffer_obj);
info.GetReturnValue().Set(is_valid_utf8(buffer_length, buffer_data) == 1 ? Nan::True() : Nan::False());
Expand Down