Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Make it compatible with Node 10.0 - 10.7 #6

Merged
merged 4 commits into from
May 10, 2019
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_js:
- 12
- 11
- 10
- 10.0

os:
- linux
Expand Down
3 changes: 3 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
# Backport of https://github.com/nodejs/node-gyp/pull/1055
"<(node_root_dir)/deps/openssl/config",
"<(node_root_dir)/deps/openssl/openssl/include",
],
"dependencies": [
"<!(node -p \"require('node-addon-api').gyp\")"
Expand Down
10 changes: 8 additions & 2 deletions src/unwrap_ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ using v8::Object;
using v8::Isolate;

class TLSWrap2 : public node::TLSWrap {
public: SSL* get_ssl(){ return ssl_.get(); }
public: SSL* get_ssl(){
#if NODE_VERSION_AT_LEAST(10,8,0)
return ssl_.get();
#else
return ssl_;
#endif
}
};

static std::string v8_local_obj_ctor(Local<Object> obj) {
Expand All @@ -32,5 +38,5 @@ SSL* unwrap_ssl(napi_env env, Napi::Object socket) {
Local<Object> wrap_v8 = v8_local_obj_from_napi_value(wrap_js);
if (v8_local_obj_ctor(wrap_v8)!="TLSWrap")
throw Napi::TypeError::New(env, "'_handle' property is not TLSWrap");
return TLSWrap2::FromJSObject<TLSWrap2>(wrap_v8)->get_ssl();
return node::Unwrap<TLSWrap2>(wrap_v8)->get_ssl();
}