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

Commit

Permalink
Merge pull request #6 from jmendeth/compatibility-fixes
Browse files Browse the repository at this point in the history
Make it compatible with Node 10.0 - 10.7
  • Loading branch information
kolontsov authored May 10, 2019
2 parents 5186824 + 94ca7d4 commit f0a8fc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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();
}

0 comments on commit f0a8fc0

Please sign in to comment.