@openziti/ziti-sdk-nodejs 0.9.0 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ jobs:
30
30
  strategy:
31
31
  matrix:
32
32
  config:
33
- # - { name: "Win", os: windows-latest, cc: "cl", cxx: "cl" }
33
+ # - { os: windows-latest, cc: "cl", cxx: "cl", node: '16' }
34
34
  - { os: ubuntu-18.04, cc: "gcc", cxx: "g++", node: '12' }
35
35
  - { os: ubuntu-18.04, cc: "gcc", cxx: "g++", node: '13' }
36
36
  - { os: ubuntu-18.04, cc: "gcc", cxx: "g++", node: '14' }
@@ -197,19 +197,12 @@ jobs:
197
197
  run: |
198
198
  npm run build:cleanup
199
199
 
200
- - name: Publish Binary to S3 (Mac)
200
+ - name: Publish Binary to S3 (for all OS's, Node versions, and architectures)
201
201
  run: |
202
202
  ./node_modules/.bin/node-pre-gyp package unpublish publish
203
203
  sleep 5
204
204
  if: |
205
- steps.extract_branch.outputs.branch == 'main' && matrix.config.os == 'macOS-latest'
206
-
207
- - name: Publish Binary to S3 (Linux)
208
- run: |
209
- ./node_modules/.bin/node-pre-gyp package unpublish publish
210
- sleep 5
211
- if: |
212
- steps.extract_branch.outputs.branch == 'main' && matrix.config.os == 'ubuntu-18.04' && matrix.config.node != '14'
205
+ steps.extract_branch.outputs.branch == 'main'
213
206
 
214
207
  - name: Install Binary
215
208
  run: |
@@ -228,4 +221,4 @@ jobs:
228
221
  token: ${{ secrets.NPM_TOKEN }}
229
222
  access: public
230
223
  if: |
231
- matrix.config.os == 'ubuntu-18.04' && matrix.config.node == '14' && matrix.architecture == 'x64' && steps.extract_branch.outputs.branch == 'main'
224
+ matrix.config.os == 'ubuntu-18.04' && matrix.config.node == '16' && matrix.architecture == 'x64' && steps.extract_branch.outputs.branch == 'main'
@@ -15,7 +15,7 @@ limitations under the License.
15
15
  */
16
16
 
17
17
  const EventEmitter = require('events');
18
- const stream = require('node:stream');
18
+ const stream = require('stream');
19
19
  const zitiWrite = require('./write').write;
20
20
 
21
21
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openziti/ziti-sdk-nodejs",
3
3
  "description": "A NodeJS-based SDK for delivering secure applications over a Ziti Network",
4
- "version": "0.9.0",
4
+ "version": "0.9.3",
5
5
  "main": "./lib/ziti",
6
6
  "scripts": {
7
7
  "build": "npm run build:init; npm run build:c-sdk; npm install --build-from-source --clang=1",
package/src/ziti-add-on.c CHANGED
@@ -21,9 +21,6 @@ extern void set_signal_handler();
21
21
 
22
22
  napi_value Init(napi_env env, napi_value exports) {
23
23
 
24
- //
25
- thread_loop = NULL;
26
-
27
24
  if (uv_mutex_init(&client_pool_lock))
28
25
  abort();
29
26
 
@@ -65,6 +62,12 @@ napi_value Init(napi_env env, napi_value exports) {
65
62
 
66
63
  #endif
67
64
 
65
+ napi_status status = napi_get_uv_event_loop(env, &thread_loop);
66
+ if (status != napi_ok) {
67
+ ZITI_NODEJS_LOG(ERROR, "napi_get_uv_event_loop failed, status: %d", status);
68
+ abort();
69
+ }
70
+
68
71
  // Expose some Ziti SDK functions to JavaScript
69
72
  expose_ziti_close(env, exports);
70
73
  expose_ziti_dial(env, exports);
package/src/ziti_init.c CHANGED
@@ -17,11 +17,6 @@ limitations under the License.
17
17
  #include "ziti-nodejs.h"
18
18
 
19
19
  ziti_context ztx = NULL;
20
- uv_loop_t *loop = NULL;
21
-
22
- uv_thread_t thread;
23
- uv_async_t async;
24
-
25
20
 
26
21
  typedef struct {
27
22
  napi_async_work work;
@@ -185,16 +180,6 @@ static void on_ziti_event(ziti_context _ztx, const ziti_event_t *event) {
185
180
  }
186
181
 
187
182
 
188
-
189
- static void child_thread(void *data){
190
- uv_loop_t *thread_loop = (uv_loop_t *) data;
191
-
192
- //Start this loop
193
- uv_run(thread_loop, UV_RUN_DEFAULT);
194
- }
195
-
196
- static void consumer_notify(uv_async_t *handle, int status) { }
197
-
198
183
  /**
199
184
  *
200
185
  */
@@ -267,13 +252,6 @@ napi_value _ziti_init(napi_env env, const napi_callback_info info) {
267
252
  napi_throw_error(env, NULL, "Failed to napi_create_threadsafe_function");
268
253
  }
269
254
 
270
- // Create and set up the consumer thread
271
- if (NULL == thread_loop) { // Spawn the loop only once
272
- thread_loop = uv_loop_new();
273
- uv_async_init(thread_loop, &async, (uv_async_cb)consumer_notify);
274
- uv_thread_create(&thread, (uv_thread_cb)child_thread, thread_loop);
275
- }
276
-
277
255
  // Light this candle!
278
256
  ziti_options *opts = calloc(1, sizeof(ziti_options));
279
257
 
package/src/ziti_listen.c CHANGED
@@ -128,7 +128,7 @@ static void CallJs_on_listen_client_data(napi_env env, napi_value js_cb, void* c
128
128
 
129
129
  static ssize_t on_listen_client_data(ziti_connection client, const uint8_t *data, ssize_t len) {
130
130
 
131
- ZITI_NODEJS_LOG(DEBUG, "on_listen_client_data: client: %p, data: %p, len: %zu", client, data, len);
131
+ ZITI_NODEJS_LOG(DEBUG, "on_listen_client_data: client: %p, data: %p, len: %zd", client, data, len);
132
132
 
133
133
  ListenAddonData* addon_data = (ListenAddonData*) ziti_conn_data(client);
134
134
 
@@ -145,7 +145,7 @@ static ssize_t on_listen_client_data(ziti_connection client, const uint8_t *data
145
145
  if (len > 0) {
146
146
  /* NOP */
147
147
  }
148
- else if (len == ZITI_EOF) {
148
+ else if ((len == ZITI_EOF) || (len == ZITI_CONN_CLOSED)) {
149
149
  ZITI_NODEJS_LOG(DEBUG, "on_listen_client_data: client disconnected");
150
150
  ziti_close_write(client);
151
151
  }