@ngrok/ngrok 0.7.1 → 0.8.0
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.
- package/CHANGELOG.md +15 -10
- package/Cargo.toml +2 -2
- package/README.md +37 -21
- package/docs/assets/highlight.css +10 -10
- package/docs/assets/search.js +1 -1
- package/docs/classes/HttpListenerBuilder.html +594 -0
- package/docs/classes/LabeledListenerBuilder.html +206 -0
- package/docs/classes/Listener.html +241 -0
- package/docs/classes/Session.html +207 -0
- package/docs/classes/SessionBuilder.html +465 -0
- package/docs/classes/TcpListenerBuilder.html +281 -0
- package/docs/classes/TlsListenerBuilder.html +322 -0
- package/docs/classes/UpdateRequest.html +46 -43
- package/docs/functions/authtoken.html +30 -29
- package/docs/functions/connect.html +31 -30
- package/docs/functions/consoleLog.html +30 -29
- package/docs/functions/disconnect.html +31 -30
- package/docs/functions/getListener.html +89 -0
- package/docs/functions/getListenerByUrl.html +89 -0
- package/docs/functions/kill.html +31 -30
- package/docs/functions/listen.html +33 -32
- package/docs/functions/listenable.html +31 -30
- package/docs/functions/listeners.html +84 -0
- package/docs/functions/loggingCallback.html +30 -29
- package/docs/index.html +66 -58
- package/docs/interfaces/Config.html +445 -319
- package/docs/modules.html +48 -48
- package/examples/express/ngrok-express-quickstart.js +1 -1
- package/examples/express/ngrok-express.js +6 -6
- package/examples/fastify/ngrok-fastify.js +4 -4
- package/examples/hapi/ngrok-hapi.js +4 -4
- package/examples/koa/ngrok-koa.js +1 -1
- package/examples/nestjs/src/main.ts +5 -5
- package/examples/nextjs/README.md +3 -0
- package/examples/nextjs/ngrok.config.js +7 -7
- package/examples/ngrok-connect-full.js +6 -2
- package/examples/ngrok-http-full.js +9 -6
- package/examples/ngrok-http-minimum.js +6 -6
- package/examples/ngrok-labeled.js +6 -6
- package/examples/ngrok-listen.js +1 -1
- package/examples/ngrok-tcp.js +5 -5
- package/examples/ngrok-tls.js +5 -5
- package/examples/ngrok-typescript.ts +12 -12
- package/examples/ngrok-windows-pipe.js +4 -4
- package/examples/ngrok-winston.js +2 -2
- package/examples/remix/ngrok.config.js +4 -4
- package/examples/svelte/ngrok.config.cjs +4 -4
- package/examples/vue/ngrok.config.ts +4 -4
- package/index.d.ts +510 -265
- package/index.js +75 -73
- package/package.json +14 -14
- package/scripts/gc-node-drop.js +7 -7
- package/scripts/gc-rust-drop.js +9 -9
- package/src/config.rs +113 -10
- package/src/connect.rs +32 -28
- package/src/http.rs +89 -23
- package/src/lib.rs +2 -2
- package/src/{tunnel.rs → listener.rs} +134 -134
- package/src/{tunnel_builder.rs → listener_builder.rs} +63 -54
- package/src/session.rs +57 -49
- package/src/tcp.rs +6 -3
- package/src/tls.rs +17 -7
- package/trailer.d.ts +5 -5
- package/trailer.js +64 -62
- package/typedoc.json +1 -1
- package/docs/classes/NgrokHttpTunnelBuilder.html +0 -510
- package/docs/classes/NgrokLabeledTunnelBuilder.html +0 -199
- package/docs/classes/NgrokSession.html +0 -199
- package/docs/classes/NgrokSessionBuilder.html +0 -449
- package/docs/classes/NgrokTcpTunnelBuilder.html +0 -268
- package/docs/classes/NgrokTlsTunnelBuilder.html +0 -304
- package/docs/classes/NgrokTunnel.html +0 -231
- package/docs/functions/getTunnel.html +0 -88
- package/docs/functions/getTunnelByUrl.html +0 -88
- package/docs/functions/tunnels.html +0 -83
package/index.js
CHANGED
|
@@ -252,24 +252,24 @@ if (!nativeBinding) {
|
|
|
252
252
|
throw new Error(`Failed to load native binding`)
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
const { connect, disconnect, kill,
|
|
255
|
+
const { connect, disconnect, kill, Listener, listeners, getListener, getListenerByUrl, HttpListenerBuilder, TcpListenerBuilder, TlsListenerBuilder, LabeledListenerBuilder, loggingCallback, authtoken, SessionBuilder, Session, UpdateRequest } = nativeBinding
|
|
256
256
|
|
|
257
257
|
module.exports.connect = connect
|
|
258
258
|
module.exports.disconnect = disconnect
|
|
259
259
|
module.exports.kill = kill
|
|
260
|
+
module.exports.Listener = Listener
|
|
261
|
+
module.exports.listeners = listeners
|
|
262
|
+
module.exports.getListener = getListener
|
|
263
|
+
module.exports.getListenerByUrl = getListenerByUrl
|
|
264
|
+
module.exports.HttpListenerBuilder = HttpListenerBuilder
|
|
265
|
+
module.exports.TcpListenerBuilder = TcpListenerBuilder
|
|
266
|
+
module.exports.TlsListenerBuilder = TlsListenerBuilder
|
|
267
|
+
module.exports.LabeledListenerBuilder = LabeledListenerBuilder
|
|
260
268
|
module.exports.loggingCallback = loggingCallback
|
|
261
269
|
module.exports.authtoken = authtoken
|
|
262
|
-
module.exports.
|
|
263
|
-
module.exports.
|
|
270
|
+
module.exports.SessionBuilder = SessionBuilder
|
|
271
|
+
module.exports.Session = Session
|
|
264
272
|
module.exports.UpdateRequest = UpdateRequest
|
|
265
|
-
module.exports.NgrokTunnel = NgrokTunnel
|
|
266
|
-
module.exports.tunnels = tunnels
|
|
267
|
-
module.exports.getTunnel = getTunnel
|
|
268
|
-
module.exports.getTunnelByUrl = getTunnelByUrl
|
|
269
|
-
module.exports.NgrokHttpTunnelBuilder = NgrokHttpTunnelBuilder
|
|
270
|
-
module.exports.NgrokTcpTunnelBuilder = NgrokTcpTunnelBuilder
|
|
271
|
-
module.exports.NgrokTlsTunnelBuilder = NgrokTlsTunnelBuilder
|
|
272
|
-
module.exports.NgrokLabeledTunnelBuilder = NgrokLabeledTunnelBuilder
|
|
273
273
|
//
|
|
274
274
|
// javascript trailer
|
|
275
275
|
//
|
|
@@ -280,24 +280,24 @@ const os = require("os");
|
|
|
280
280
|
const path = require("path");
|
|
281
281
|
|
|
282
282
|
// wrap connect with the code for extending exception with error code
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
SessionBuilder.prototype._connect = SessionBuilder.prototype.connect;
|
|
284
|
+
SessionBuilder.prototype.connect = ngrokSessionConnect;
|
|
285
285
|
|
|
286
286
|
// wrap listen with the bind code for passing to net.Server.listen()
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
HttpListenerBuilder.prototype._listen = HttpListenerBuilder.prototype.listen;
|
|
288
|
+
TcpListenerBuilder.prototype._listen = TcpListenerBuilder.prototype.listen;
|
|
289
|
+
TlsListenerBuilder.prototype._listen = TlsListenerBuilder.prototype.listen;
|
|
290
|
+
LabeledListenerBuilder.prototype._listen = LabeledListenerBuilder.prototype.listen;
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
HttpListenerBuilder.prototype.listen = ngrokBind;
|
|
293
|
+
TcpListenerBuilder.prototype.listen = ngrokBind;
|
|
294
|
+
TlsListenerBuilder.prototype.listen = ngrokBind;
|
|
295
|
+
LabeledListenerBuilder.prototype.listen = ngrokBind;
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
HttpListenerBuilder.prototype.listenAndServe = listenAndServe;
|
|
298
|
+
TcpListenerBuilder.prototype.listenAndServe = listenAndServe;
|
|
299
|
+
TlsListenerBuilder.prototype.listenAndServe = listenAndServe;
|
|
300
|
+
LabeledListenerBuilder.prototype.listenAndServe = listenAndServe;
|
|
301
301
|
|
|
302
302
|
// Wrap session connect to fill in exception's errorCode
|
|
303
303
|
async function ngrokSessionConnect() {
|
|
@@ -309,29 +309,29 @@ async function ngrokSessionConnect() {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
// Begin listening for new connections on this
|
|
313
|
-
// and bind to a local socket so this
|
|
312
|
+
// Begin listening for new connections on this listener,
|
|
313
|
+
// and bind to a local socket so this listener can be
|
|
314
314
|
// passed into net.Server.listen().
|
|
315
315
|
async function ngrokBind(bind) {
|
|
316
316
|
try {
|
|
317
|
-
const
|
|
317
|
+
const listener = await this._listen();
|
|
318
318
|
if (bind !== false) {
|
|
319
319
|
const socket = await randomTcpSocket();
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
listener.socket = socket;
|
|
321
|
+
defineListenerHandle(listener, socket);
|
|
322
322
|
}
|
|
323
|
-
return
|
|
323
|
+
return listener;
|
|
324
324
|
} catch (err) {
|
|
325
325
|
populateErrorCode(err);
|
|
326
326
|
throw err;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
/// Begin listening for new connections on this
|
|
330
|
+
/// Begin listening for new connections on this listener and forwarding them to the given server.
|
|
331
331
|
async function listenAndServe(server) {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
return
|
|
332
|
+
const listener = await this._listen();
|
|
333
|
+
listener.socket = await ngrokListen(server, listener);
|
|
334
|
+
return listener;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
function populateErrorCode(err) {
|
|
@@ -344,15 +344,15 @@ function populateErrorCode(err) {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
// add a 'handle' getter to the
|
|
347
|
+
// add a 'handle' getter to the listener so it can be
|
|
348
348
|
// passed into net.Server.listen().
|
|
349
|
-
function
|
|
349
|
+
function defineListenerHandle(listener, socket) {
|
|
350
350
|
// NodeJS net.Server asks passed-in object for 'handle',
|
|
351
351
|
// Return the native TCP object so the pre-existing socket is used.
|
|
352
|
-
Object.defineProperty(
|
|
352
|
+
Object.defineProperty(listener, "handle", {
|
|
353
353
|
get: function () {
|
|
354
354
|
// turn on forwarding now that it has been requested
|
|
355
|
-
|
|
355
|
+
listener.forward("localhost:" + socket.address().port);
|
|
356
356
|
return socket._handle;
|
|
357
357
|
},
|
|
358
358
|
});
|
|
@@ -378,61 +378,61 @@ function asyncListen(server, options) {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// Make a session using NGROK_AUTHTOKEN from the environment,
|
|
381
|
-
// and then return a listening HTTP
|
|
382
|
-
async function
|
|
383
|
-
// set up a default session and
|
|
384
|
-
var builder = new
|
|
381
|
+
// and then return a listening HTTP listener.
|
|
382
|
+
async function defaultListener(bind) {
|
|
383
|
+
// set up a default session and listener
|
|
384
|
+
var builder = new SessionBuilder();
|
|
385
385
|
builder.authtokenFromEnv();
|
|
386
386
|
var session = await builder.connect();
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
return
|
|
387
|
+
var listener = await session.httpEndpoint().listen(bind);
|
|
388
|
+
listener.session = session; // surface to caller
|
|
389
|
+
return listener;
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
// Get a listenable ngrok
|
|
392
|
+
// Get a listenable ngrok listener, suitable for passing to net.Server.listen().
|
|
393
393
|
// Uses the NGROK_AUTHTOKEN environment variable to authenticate.
|
|
394
394
|
async function listenable() {
|
|
395
|
-
return await
|
|
395
|
+
return await defaultListener();
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
// Bind a server to a new ngrok
|
|
399
|
-
// Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new
|
|
400
|
-
async function ngrokListen(server,
|
|
401
|
-
if (
|
|
398
|
+
// Bind a server to a new ngrok listener, optionally passing in a pre-existing listener instead.
|
|
399
|
+
// Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new listener is created.
|
|
400
|
+
async function ngrokListen(server, listener) {
|
|
401
|
+
if (listener && listener.socket) {
|
|
402
402
|
// close the default bound port
|
|
403
|
-
|
|
403
|
+
listener.socket.close();
|
|
404
404
|
}
|
|
405
|
-
if (!
|
|
405
|
+
if (!listener) {
|
|
406
406
|
// turn off automatic bind
|
|
407
|
-
|
|
407
|
+
listener = await defaultListener(false);
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
// attempt pipe socket
|
|
411
411
|
try {
|
|
412
|
-
socket = await ngrokLinkPipe(
|
|
412
|
+
socket = await ngrokLinkPipe(listener, server);
|
|
413
413
|
} catch (err) {
|
|
414
414
|
console.debug("Using TCP socket. " + err);
|
|
415
415
|
// fallback to tcp socket
|
|
416
|
-
socket = await ngrokLinkTcp(
|
|
416
|
+
socket = await ngrokLinkTcp(listener, server);
|
|
417
417
|
}
|
|
418
|
-
registerCleanup(
|
|
418
|
+
registerCleanup(listener, socket);
|
|
419
419
|
|
|
420
|
-
server.
|
|
421
|
-
socket.
|
|
420
|
+
server.listener = listener; // surface to caller
|
|
421
|
+
socket.listener = listener; // surface to caller
|
|
422
422
|
// return the newly created net.Server, which will be different in the express case
|
|
423
423
|
return socket;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
async function ngrokLinkTcp(
|
|
426
|
+
async function ngrokLinkTcp(listener, server) {
|
|
427
427
|
// random local port
|
|
428
428
|
const socket = await asyncListen(server, { host: "localhost", port: 0 });
|
|
429
429
|
// forward to socket
|
|
430
|
-
|
|
430
|
+
listener.forward("localhost:" + socket.address().port);
|
|
431
431
|
return socket;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
function generatePipeFilename(
|
|
435
|
-
var proposed = "tun-" +
|
|
434
|
+
function generatePipeFilename(listener, server) {
|
|
435
|
+
var proposed = "tun-" + listener.id() + ".sock";
|
|
436
436
|
|
|
437
437
|
// windows leaves little choice
|
|
438
438
|
if (platform == "win32") {
|
|
@@ -475,8 +475,8 @@ function generatePipeFilename(tunnel, server) {
|
|
|
475
475
|
return proposed;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
async function ngrokLinkPipe(
|
|
479
|
-
var filename = generatePipeFilename(
|
|
478
|
+
async function ngrokLinkPipe(listener, server) {
|
|
479
|
+
var filename = generatePipeFilename(listener);
|
|
480
480
|
// begin listening
|
|
481
481
|
const socket = await asyncListen(server, { path: filename });
|
|
482
482
|
// tighten permissions
|
|
@@ -487,13 +487,13 @@ async function ngrokLinkPipe(tunnel, server) {
|
|
|
487
487
|
} catch (err) {
|
|
488
488
|
console.debug("Cannot change permissions of file: " + filename);
|
|
489
489
|
}
|
|
490
|
-
// forward
|
|
490
|
+
// forward listener
|
|
491
491
|
var addr = "unix:" + filename;
|
|
492
492
|
if (platform == "win32") {
|
|
493
493
|
// convert pipe path to url
|
|
494
494
|
addr = "pipe:" + filename.replace("\\\\.\\pipe\\", "//./");
|
|
495
495
|
}
|
|
496
|
-
|
|
496
|
+
listener.forward(addr);
|
|
497
497
|
socket.path = filename; // surface to caller
|
|
498
498
|
|
|
499
499
|
return socket;
|
|
@@ -502,7 +502,7 @@ async function ngrokLinkPipe(tunnel, server) {
|
|
|
502
502
|
// protect against multiple calls, for instance from npm
|
|
503
503
|
var sigintRan = false;
|
|
504
504
|
|
|
505
|
-
function registerCleanup(
|
|
505
|
+
function registerCleanup(listener, socket) {
|
|
506
506
|
process.on("SIGINT", function () {
|
|
507
507
|
if (sigintRan) return;
|
|
508
508
|
sigintRan = true;
|
|
@@ -511,10 +511,10 @@ function registerCleanup(tunnel, socket) {
|
|
|
511
511
|
// user has registered a handler, abort this one
|
|
512
512
|
return;
|
|
513
513
|
}
|
|
514
|
-
// close
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
console.error(`Error closing
|
|
514
|
+
// close listener
|
|
515
|
+
if (listener) {
|
|
516
|
+
listener.close().catch((err) => {
|
|
517
|
+
console.error(`Error closing listener: ${err}`);
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
520
|
// close webserver's socket
|
|
@@ -546,8 +546,10 @@ async function ngrokConnect(config) {
|
|
|
546
546
|
if (Number.isInteger(addr)) config["addr"] = "localhost:" + String(config["addr"]);
|
|
547
547
|
// convert scalar values to arrays to meet what napi-rs expects
|
|
548
548
|
[
|
|
549
|
+
"allow_user_agent",
|
|
549
550
|
"auth",
|
|
550
551
|
"basic_auth",
|
|
552
|
+
"deny_user_agent",
|
|
551
553
|
"ip_restriction.allow_cidrs",
|
|
552
554
|
"ip_restriction.deny_cidrs",
|
|
553
555
|
"labels",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrok/ngrok",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -55,18 +55,18 @@
|
|
|
55
55
|
"description": "The ngrok agent in library form, suitable for integrating directly into your NodeJS application.",
|
|
56
56
|
"repository": "https://github.com/ngrok/ngrok-nodejs",
|
|
57
57
|
"optionalDependencies": {
|
|
58
|
-
"@ngrok/ngrok-win32-x64-msvc": "0.
|
|
59
|
-
"@ngrok/ngrok-darwin-x64": "0.
|
|
60
|
-
"@ngrok/ngrok-linux-x64-gnu": "0.
|
|
61
|
-
"@ngrok/ngrok-darwin-arm64": "0.
|
|
62
|
-
"@ngrok/ngrok-android-arm64": "0.
|
|
63
|
-
"@ngrok/ngrok-linux-arm64-gnu": "0.
|
|
64
|
-
"@ngrok/ngrok-linux-arm64-musl": "0.
|
|
65
|
-
"@ngrok/ngrok-linux-arm-gnueabihf": "0.
|
|
66
|
-
"@ngrok/ngrok-linux-x64-musl": "0.
|
|
67
|
-
"@ngrok/ngrok-freebsd-x64": "0.
|
|
68
|
-
"@ngrok/ngrok-win32-ia32-msvc": "0.
|
|
69
|
-
"@ngrok/ngrok-android-arm-eabi": "0.
|
|
70
|
-
"@ngrok/ngrok-darwin-universal": "0.
|
|
58
|
+
"@ngrok/ngrok-win32-x64-msvc": "0.8.0",
|
|
59
|
+
"@ngrok/ngrok-darwin-x64": "0.8.0",
|
|
60
|
+
"@ngrok/ngrok-linux-x64-gnu": "0.8.0",
|
|
61
|
+
"@ngrok/ngrok-darwin-arm64": "0.8.0",
|
|
62
|
+
"@ngrok/ngrok-android-arm64": "0.8.0",
|
|
63
|
+
"@ngrok/ngrok-linux-arm64-gnu": "0.8.0",
|
|
64
|
+
"@ngrok/ngrok-linux-arm64-musl": "0.8.0",
|
|
65
|
+
"@ngrok/ngrok-linux-arm-gnueabihf": "0.8.0",
|
|
66
|
+
"@ngrok/ngrok-linux-x64-musl": "0.8.0",
|
|
67
|
+
"@ngrok/ngrok-freebsd-x64": "0.8.0",
|
|
68
|
+
"@ngrok/ngrok-win32-ia32-msvc": "0.8.0",
|
|
69
|
+
"@ngrok/ngrok-android-arm-eabi": "0.8.0",
|
|
70
|
+
"@ngrok/ngrok-darwin-universal": "0.8.0"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/scripts/gc-node-drop.js
CHANGED
|
@@ -20,25 +20,25 @@ var ngrok = require("..");
|
|
|
20
20
|
// turn on debug
|
|
21
21
|
ngrok.consoleLog();
|
|
22
22
|
|
|
23
|
-
new ngrok.
|
|
23
|
+
new ngrok.SessionBuilder()
|
|
24
24
|
.authtokenFromEnv()
|
|
25
25
|
.connect()
|
|
26
26
|
.then((session) => {
|
|
27
27
|
session
|
|
28
28
|
.httpEndpoint()
|
|
29
29
|
.listen()
|
|
30
|
-
.then((
|
|
31
|
-
|
|
32
|
-
console.log("
|
|
30
|
+
.then((listener) => {
|
|
31
|
+
listener.forward("localhost:8081").await;
|
|
32
|
+
console.log("listener: " + listener.url() + " id: " + listener.id());
|
|
33
33
|
setTimeout(function () {
|
|
34
34
|
console.log("\n\n=====> running gc");
|
|
35
35
|
global.gc();
|
|
36
36
|
}, 2000);
|
|
37
37
|
|
|
38
38
|
setTimeout(function () {
|
|
39
|
-
console.log("\n\n=====> closing and nulling
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
console.log("\n\n=====> closing and nulling listener");
|
|
40
|
+
listener.close().await;
|
|
41
|
+
listener = null;
|
|
42
42
|
}, 4000);
|
|
43
43
|
|
|
44
44
|
setTimeout(function () {
|
package/scripts/gc-rust-drop.js
CHANGED
|
@@ -20,19 +20,19 @@ var ngrok = require("..");
|
|
|
20
20
|
// turn on debug
|
|
21
21
|
ngrok.consoleLog();
|
|
22
22
|
|
|
23
|
-
new ngrok.
|
|
23
|
+
new ngrok.SessionBuilder()
|
|
24
24
|
.authtokenFromEnv()
|
|
25
25
|
.connect()
|
|
26
26
|
.then((session) => {
|
|
27
27
|
session
|
|
28
28
|
.httpEndpoint()
|
|
29
29
|
.listen()
|
|
30
|
-
.then((
|
|
31
|
-
|
|
32
|
-
const tun_id =
|
|
33
|
-
console.log("
|
|
34
|
-
console.log("\n\n=====> nulling
|
|
35
|
-
|
|
30
|
+
.then((listener) => {
|
|
31
|
+
listener.forward("localhost:8081").await;
|
|
32
|
+
const tun_id = listener.id();
|
|
33
|
+
console.log("listener: " + listener.url() + " id: " + tun_id);
|
|
34
|
+
console.log("\n\n=====> nulling listener");
|
|
35
|
+
listener = null; // nodejs can gc
|
|
36
36
|
|
|
37
37
|
setTimeout(function () {
|
|
38
38
|
console.log("\n\n=====> running gc");
|
|
@@ -40,8 +40,8 @@ new ngrok.NgrokSessionBuilder()
|
|
|
40
40
|
}, 2000);
|
|
41
41
|
|
|
42
42
|
setTimeout(function () {
|
|
43
|
-
console.log("\n\n=====> closing
|
|
44
|
-
session.
|
|
43
|
+
console.log("\n\n=====> closing listener");
|
|
44
|
+
session.closeListener(tun_id).await;
|
|
45
45
|
}, 4000);
|
|
46
46
|
|
|
47
47
|
setTimeout(function () {
|
package/src/config.rs
CHANGED
|
@@ -34,25 +34,38 @@ pub struct Config {
|
|
|
34
34
|
pub bin_path: Option<String>,
|
|
35
35
|
/// Reject requests when 5XX responses exceed this ratio.
|
|
36
36
|
/// Disabled when 0.
|
|
37
|
+
/// See [Circuit Breaker] in the ngrok docs for additional details.
|
|
38
|
+
///
|
|
39
|
+
/// [Circuit Breaker]: https://ngrok.com/docs/cloud-edge/modules/circuit-breaker/
|
|
37
40
|
#[napi(js_name = "circuit_breaker")]
|
|
38
41
|
pub circuit_breaker: Option<f64>,
|
|
39
42
|
/// Enable gzip compression for HTTP responses.
|
|
43
|
+
/// See [Compression] in the ngrok docs for additional details.
|
|
44
|
+
///
|
|
45
|
+
/// [Compression]: https://ngrok.com/docs/cloud-edge/modules/compression/
|
|
40
46
|
pub compression: Option<bool>,
|
|
41
47
|
/// Unused, will warn and be ignored
|
|
42
48
|
pub config_path: Option<String>,
|
|
43
49
|
/// The certificate to use for TLS termination at the ngrok edge in PEM format.
|
|
44
50
|
/// Only used if "proto" is "tls".
|
|
51
|
+
/// See [TLS Termination] in the ngrok docs for additional details.
|
|
52
|
+
///
|
|
53
|
+
/// [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
|
|
45
54
|
pub crt: Option<String>,
|
|
46
|
-
/// The domain to request for this edge
|
|
55
|
+
/// The domain to request for this edge, any valid domain or hostname that you have
|
|
56
|
+
/// previously registered with ngrok. If using a custom domain, this requires
|
|
57
|
+
/// registering in the [ngrok dashboard] and setting a DNS CNAME value.
|
|
58
|
+
///
|
|
59
|
+
/// [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
|
|
47
60
|
pub domain: Option<String>,
|
|
48
61
|
/// Returns a human-readable string presented in the ngrok dashboard
|
|
49
|
-
/// and the
|
|
62
|
+
/// and the API.
|
|
50
63
|
#[napi(js_name = "forwards_to")]
|
|
51
64
|
pub forwards_to: Option<String>,
|
|
52
65
|
/// Unused, will warn and be ignored
|
|
53
66
|
#[napi(js_name = "host_header")]
|
|
54
67
|
pub host_header: Option<String>,
|
|
55
|
-
/// The hostname for the
|
|
68
|
+
/// The hostname for the listener to forward to.
|
|
56
69
|
/// Only used if addr is not defined.
|
|
57
70
|
pub host: Option<String>,
|
|
58
71
|
/// Synonym for domain
|
|
@@ -71,84 +84,168 @@ pub struct Config {
|
|
|
71
84
|
ts_type = "string|Array<string>"
|
|
72
85
|
)]
|
|
73
86
|
pub deny_cidr: Option<Vec<String>>,
|
|
87
|
+
|
|
88
|
+
/// A set of regular expressions used to match User-Agents that will be allowed.
|
|
89
|
+
/// On request, the User Agent Filter module will check the incoming User-Agent header value
|
|
90
|
+
/// against the list of defined allow and deny regular expression rules.
|
|
91
|
+
/// See `User Agent Filter`_ in the ngrok docs for additional details.
|
|
92
|
+
///
|
|
93
|
+
/// .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
|
|
94
|
+
#[napi(js_name = "allow_user_agent", ts_type = "string|Array<string>")]
|
|
95
|
+
pub allow_user_agent: Option<Vec<String>>,
|
|
96
|
+
/// A set of regular expressions used to match User-Agents that will be denied.
|
|
97
|
+
/// On request, the User Agent Filter module will check the incoming User-Agent header value
|
|
98
|
+
/// against the list of defined allow and deny regular expression rules.
|
|
99
|
+
/// See `User Agent Filter`_ in the ngrok docs for additional details.
|
|
100
|
+
///
|
|
101
|
+
/// .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
|
|
102
|
+
#[napi(js_name = "deny_user_agent", ts_type = "string|Array<string>")]
|
|
103
|
+
pub deny_user_agent: Option<Vec<String>>,
|
|
104
|
+
|
|
74
105
|
/// The certificate to use for TLS termination at the ngrok edge in PEM format.
|
|
75
106
|
/// Only used if "proto" is "tls".
|
|
107
|
+
/// See [TLS Termination] in the ngrok docs for additional details.
|
|
108
|
+
///
|
|
109
|
+
/// [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
|
|
76
110
|
pub key: Option<String>,
|
|
77
|
-
/// Add label, value pairs for this
|
|
111
|
+
/// Add label, value pairs for this listener, colon separated.
|
|
78
112
|
#[napi(ts_type = "string|Array<string>")]
|
|
79
113
|
pub labels: Option<Vec<String>>,
|
|
80
|
-
///
|
|
114
|
+
/// Listener-specific opaque metadata. Viewable via the API.
|
|
81
115
|
pub metadata: Option<String>,
|
|
82
116
|
/// Certificates to use for client authentication at the ngrok edge.
|
|
83
117
|
/// Only used if "proto" is "tls" or "http".
|
|
118
|
+
/// See [Mutual TLS] in the ngrok docs for additional details.
|
|
119
|
+
///
|
|
120
|
+
/// [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
|
|
84
121
|
#[napi(js_name = "mutual_tls_cas", ts_type = "string|Array<string>")]
|
|
85
122
|
pub mutual_tls_cas: Option<Vec<String>>,
|
|
86
123
|
/// Unused, will warn and be ignored
|
|
87
124
|
pub name: Option<String>,
|
|
125
|
+
|
|
88
126
|
/// OAuth configuration of domains to allow.
|
|
127
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
128
|
+
///
|
|
129
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
89
130
|
#[napi(js_name = "oauth_allow_domains", ts_type = "string|Array<string>")]
|
|
90
131
|
pub oauth_allow_domains: Option<Vec<String>>,
|
|
91
132
|
/// OAuth configuration of email addresses to allow.
|
|
133
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
134
|
+
///
|
|
135
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
92
136
|
#[napi(js_name = "oauth_allow_emails", ts_type = "string|Array<string>")]
|
|
93
137
|
pub oauth_allow_emails: Option<Vec<String>>,
|
|
94
138
|
/// OAuth configuration of scopes.
|
|
139
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
140
|
+
///
|
|
141
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
95
142
|
#[napi(js_name = "oauth_scopes", ts_type = "string|Array<string>")]
|
|
96
143
|
pub oauth_scopes: Option<Vec<String>>,
|
|
97
144
|
/// OAuth configuration of the provider, e.g. "google".
|
|
98
|
-
///
|
|
145
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
146
|
+
///
|
|
147
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
99
148
|
#[napi(js_name = "oauth_provider")]
|
|
100
149
|
pub oauth_provider: Option<String>,
|
|
150
|
+
/// OAuth configuration of client ID. Required for scopes.
|
|
151
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
152
|
+
///
|
|
153
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
154
|
+
#[napi(js_name = "oauth_client_id")]
|
|
155
|
+
pub oauth_client_id: Option<String>,
|
|
156
|
+
/// OAuth configuration of client secret. Required for scopes.
|
|
157
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
158
|
+
///
|
|
159
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
160
|
+
#[napi(js_name = "oauth_client_secret")]
|
|
161
|
+
pub oauth_client_secret: Option<String>,
|
|
162
|
+
|
|
101
163
|
/// OIDC configuration of client ID.
|
|
164
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
165
|
+
///
|
|
166
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
102
167
|
#[napi(js_name = "oidc_client_id")]
|
|
103
168
|
pub oidc_client_id: Option<String>,
|
|
104
169
|
/// OIDC configuration of client secret.
|
|
170
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
171
|
+
///
|
|
172
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
105
173
|
#[napi(js_name = "oidc_client_secret")]
|
|
106
174
|
pub oidc_client_secret: Option<String>,
|
|
107
175
|
/// OIDC configuration of scopes.
|
|
176
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
177
|
+
///
|
|
178
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
108
179
|
#[napi(js_name = "oidc_scopes", ts_type = "string|Array<string>")]
|
|
109
180
|
pub oidc_scopes: Option<Vec<String>>,
|
|
110
181
|
/// OIDC configuration of the issuer URL.
|
|
182
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
183
|
+
///
|
|
184
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
111
185
|
#[napi(js_name = "oidc_issuer_url")]
|
|
112
186
|
pub oidc_issuer_url: Option<String>,
|
|
113
187
|
/// OIDC configuration of domains to allow.
|
|
188
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
189
|
+
///
|
|
190
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
114
191
|
#[napi(js_name = "oidc_allow_domains", ts_type = "string|Array<string>")]
|
|
115
192
|
pub oidc_allow_domains: Option<Vec<String>>,
|
|
116
193
|
/// OIDC configuration of email addresses to allow.
|
|
194
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
195
|
+
///
|
|
196
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
117
197
|
#[napi(js_name = "oidc_allow_emails", ts_type = "string|Array<string>")]
|
|
118
198
|
pub oidc_allow_emails: Option<Vec<String>>,
|
|
199
|
+
|
|
119
200
|
/// Returns log messages from the ngrok library.
|
|
120
201
|
#[napi(ts_type = "(data: string) => void")]
|
|
121
202
|
pub on_log_event: Option<bool>,
|
|
122
203
|
/// 'closed' - connection is lost, 'connected' - reconnected
|
|
123
204
|
#[napi(ts_type = "(status: string) => void")]
|
|
124
205
|
pub on_status_change: Option<bool>,
|
|
125
|
-
/// The port for the
|
|
206
|
+
/// The port for the listener to forward to.
|
|
126
207
|
/// Only used if addr is not defined.
|
|
127
208
|
pub port: Option<u32>,
|
|
128
|
-
/// The type of
|
|
209
|
+
/// The type of listener to use, one of http|tcp|tls|labeled, defaults to http.
|
|
129
210
|
pub proto: Option<String>,
|
|
130
|
-
/// The version of PROXY protocol to use with this
|
|
211
|
+
/// The version of PROXY protocol to use with this listener "1", "2", or "" if not using.
|
|
131
212
|
#[napi(js_name = "proxy_proto")]
|
|
132
213
|
pub proxy_proto: Option<String>,
|
|
133
214
|
/// Adds a header to all requests to this edge.
|
|
215
|
+
/// See [Request Headers] in the ngrok docs for additional details.
|
|
216
|
+
///
|
|
217
|
+
/// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
|
|
134
218
|
#[napi(js_name = "request_header_add", ts_type = "string|Array<string>")]
|
|
135
219
|
pub request_header_add: Option<Vec<String>>,
|
|
136
220
|
/// Removes a header from requests to this edge.
|
|
221
|
+
/// See [Request Headers] in the ngrok docs for additional details.
|
|
222
|
+
///
|
|
223
|
+
/// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
|
|
137
224
|
#[napi(js_name = "request_header_remove", ts_type = "string|Array<string>")]
|
|
138
225
|
pub request_header_remove: Option<Vec<String>>,
|
|
139
226
|
/// Adds a header to all responses coming from this edge.
|
|
227
|
+
/// See [Response Headers] in the ngrok docs for additional details.
|
|
228
|
+
///
|
|
229
|
+
/// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
|
|
140
230
|
#[napi(js_name = "response_header_add", ts_type = "string|Array<string>")]
|
|
141
231
|
pub response_header_add: Option<Vec<String>>,
|
|
142
232
|
/// Removes a header from responses from this edge.
|
|
233
|
+
/// See [Response Headers] in the ngrok docs for additional details.
|
|
234
|
+
///
|
|
235
|
+
/// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
|
|
143
236
|
#[napi(js_name = "response_header_remove", ts_type = "string|Array<string>")]
|
|
144
237
|
pub response_header_remove: Option<Vec<String>>,
|
|
145
238
|
/// Unused, will warn and be ignored
|
|
146
239
|
pub region: Option<String>,
|
|
147
240
|
/// The TCP address to request for this edge.
|
|
241
|
+
/// These addresses can be reserved in the [ngrok dashboard] to use across sessions. For example: remote_addr("2.tcp.ngrok.io:21746")
|
|
148
242
|
/// Only used if proto is "tcp".
|
|
243
|
+
///
|
|
244
|
+
/// [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/tcp-addresses
|
|
149
245
|
#[napi(js_name = "remote_addr")]
|
|
150
246
|
pub remote_addr: Option<String>,
|
|
151
|
-
/// The scheme that this edge should use
|
|
247
|
+
/// The scheme that this edge should use.
|
|
248
|
+
/// "HTTPS" or "HTTP", defaults to "HTTPS".
|
|
152
249
|
/// If multiple are given only the last one is used.
|
|
153
250
|
#[napi(ts_type = "string|Array<string>")]
|
|
154
251
|
pub schemes: Option<Vec<String>>,
|
|
@@ -168,9 +265,15 @@ pub struct Config {
|
|
|
168
265
|
#[napi(js_name = "terminate_at")]
|
|
169
266
|
pub terminate_at: Option<String>,
|
|
170
267
|
/// WebhookVerification configuration, the provider to use.
|
|
268
|
+
/// See [Webhook Verification] in the ngrok docs for additional details.
|
|
269
|
+
///
|
|
270
|
+
/// [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
|
|
171
271
|
#[napi(js_name = "verify_webhook_provider")]
|
|
172
272
|
pub verify_webhook_provider: Option<String>,
|
|
173
273
|
/// WebhookVerification configuration, the secret to use.
|
|
274
|
+
/// See [Webhook Verification] in the ngrok docs for additional details.
|
|
275
|
+
///
|
|
276
|
+
/// [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
|
|
174
277
|
#[napi(js_name = "verify_webhook_secret")]
|
|
175
278
|
pub verify_webhook_secret: Option<String>,
|
|
176
279
|
/// Unused, will warn and be ignored
|