@ngrok/ngrok 0.5.1 → 0.5.2
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/.gitattributes +3 -0
- package/CHANGELOG.md +4 -0
- package/Cargo.toml +2 -2
- package/docs/classes/NgrokHttpTunnelBuilder.html +28 -28
- package/docs/classes/NgrokLabeledTunnelBuilder.html +5 -5
- package/docs/classes/NgrokSession.html +7 -7
- package/docs/classes/NgrokSessionBuilder.html +17 -17
- package/docs/classes/NgrokTcpTunnelBuilder.html +9 -9
- package/docs/classes/NgrokTlsTunnelBuilder.html +11 -11
- package/docs/classes/NgrokTunnel.html +14 -14
- package/docs/classes/UpdateRequest.html +3 -3
- package/docs/functions/authtoken.html +1 -1
- package/docs/functions/connect.html +1 -1
- package/docs/functions/consoleLog.html +1 -1
- package/docs/functions/disconnect.html +2 -2
- package/docs/functions/kill.html +1 -1
- package/docs/functions/listen.html +1 -1
- package/docs/functions/listenable.html +1 -1
- package/docs/functions/loggingCallback.html +1 -1
- package/docs/interfaces/Config.html +53 -53
- package/examples/ngrok-labeled.js +10 -0
- package/package.json +15 -15
- package/src/connect.rs +1 -1
- package/src/session.rs +1 -1
- package/src/tunnel.rs +32 -10
- package/tsconfig.json +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrok/ngrok",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"docs": "mv trailer.d.ts trailer.d.hidden; mv examples .examples; npx typedoc index.d.ts --navigation.includeGroups; mv .examples examples; mv trailer.d.hidden trailer.d.ts",
|
|
48
48
|
"prepublishOnly": "napi prepublish -t npm",
|
|
49
49
|
"prettier": "prettier --write .",
|
|
50
|
-
"test": "ava",
|
|
50
|
+
"test": "tsc --strict index.d.ts && ava",
|
|
51
51
|
"universal": "napi universal",
|
|
52
52
|
"version": "napi version"
|
|
53
53
|
},
|
|
@@ -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.5.
|
|
59
|
-
"@ngrok/ngrok-darwin-x64": "0.5.
|
|
60
|
-
"@ngrok/ngrok-linux-x64-gnu": "0.5.
|
|
61
|
-
"@ngrok/ngrok-darwin-arm64": "0.5.
|
|
62
|
-
"@ngrok/ngrok-android-arm64": "0.5.
|
|
63
|
-
"@ngrok/ngrok-linux-arm64-gnu": "0.5.
|
|
64
|
-
"@ngrok/ngrok-linux-arm64-musl": "0.5.
|
|
65
|
-
"@ngrok/ngrok-linux-arm-gnueabihf": "0.5.
|
|
66
|
-
"@ngrok/ngrok-linux-x64-musl": "0.5.
|
|
67
|
-
"@ngrok/ngrok-freebsd-x64": "0.5.
|
|
68
|
-
"@ngrok/ngrok-win32-ia32-msvc": "0.5.
|
|
69
|
-
"@ngrok/ngrok-android-arm-eabi": "0.5.
|
|
70
|
-
"@ngrok/ngrok-darwin-universal": "0.5.
|
|
58
|
+
"@ngrok/ngrok-win32-x64-msvc": "0.5.2",
|
|
59
|
+
"@ngrok/ngrok-darwin-x64": "0.5.2",
|
|
60
|
+
"@ngrok/ngrok-linux-x64-gnu": "0.5.2",
|
|
61
|
+
"@ngrok/ngrok-darwin-arm64": "0.5.2",
|
|
62
|
+
"@ngrok/ngrok-android-arm64": "0.5.2",
|
|
63
|
+
"@ngrok/ngrok-linux-arm64-gnu": "0.5.2",
|
|
64
|
+
"@ngrok/ngrok-linux-arm64-musl": "0.5.2",
|
|
65
|
+
"@ngrok/ngrok-linux-arm-gnueabihf": "0.5.2",
|
|
66
|
+
"@ngrok/ngrok-linux-x64-musl": "0.5.2",
|
|
67
|
+
"@ngrok/ngrok-freebsd-x64": "0.5.2",
|
|
68
|
+
"@ngrok/ngrok-win32-ia32-msvc": "0.5.2",
|
|
69
|
+
"@ngrok/ngrok-android-arm-eabi": "0.5.2",
|
|
70
|
+
"@ngrok/ngrok-darwin-universal": "0.5.2"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/connect.rs
CHANGED
|
@@ -146,7 +146,7 @@ async fn async_connect(s_builder: NgrokSessionBuilder, config: Config) -> Result
|
|
|
146
146
|
_ => return Err(napi_err(format!("unhandled protocol {proto}"))),
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
let url = tunnel::get_url(&id).await.
|
|
149
|
+
let url = tunnel::get_url(&id).await.unwrap_or(id.clone());
|
|
150
150
|
|
|
151
151
|
// move forwarding to another task
|
|
152
152
|
if let Some(addr) = config.addr {
|
package/src/session.rs
CHANGED
package/src/tunnel.rs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
use core::result::Result as CoreResult;
|
|
1
2
|
use std::{
|
|
2
3
|
collections::HashMap,
|
|
4
|
+
error::Error,
|
|
3
5
|
io,
|
|
4
6
|
sync::Arc,
|
|
5
7
|
};
|
|
@@ -10,6 +12,7 @@ use napi::bindgen_prelude::*;
|
|
|
10
12
|
use napi_derive::napi;
|
|
11
13
|
use ngrok::{
|
|
12
14
|
prelude::*,
|
|
15
|
+
session::ConnectError,
|
|
13
16
|
tunnel::{
|
|
14
17
|
HttpTunnel,
|
|
15
18
|
LabeledTunnel,
|
|
@@ -46,8 +49,8 @@ struct Storage {
|
|
|
46
49
|
/// a proxy trait without generics which can be the dyn type stored in the global map.
|
|
47
50
|
#[async_trait]
|
|
48
51
|
pub trait ExtendedTunnel: Tunnel {
|
|
49
|
-
async fn fwd_tcp(&mut self, addr: String) ->
|
|
50
|
-
async fn fwd_pipe(&mut self, addr: String) ->
|
|
52
|
+
async fn fwd_tcp(&mut self, addr: String) -> CoreResult<(), io::Error>;
|
|
53
|
+
async fn fwd_pipe(&mut self, addr: String) -> CoreResult<(), io::Error>;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
/// An ngrok tunnel.
|
|
@@ -147,10 +150,10 @@ macro_rules! make_tunnel_type {
|
|
|
147
150
|
($wrapper:ident, $tunnel:tt) => {
|
|
148
151
|
#[async_trait]
|
|
149
152
|
impl ExtendedTunnel for $tunnel {
|
|
150
|
-
async fn fwd_tcp(&mut self, addr: String) ->
|
|
153
|
+
async fn fwd_tcp(&mut self, addr: String) -> CoreResult<(), io::Error> {
|
|
151
154
|
self.forward_tcp(addr).await
|
|
152
155
|
}
|
|
153
|
-
async fn fwd_pipe(&mut self, addr: String) ->
|
|
156
|
+
async fn fwd_pipe(&mut self, addr: String) -> CoreResult<(), io::Error> {
|
|
154
157
|
self.forward_pipe(addr).await
|
|
155
158
|
}
|
|
156
159
|
}
|
|
@@ -278,10 +281,10 @@ pub async fn forward_tcp(id: &String, addr: String) -> Result<()> {
|
|
|
278
281
|
.lock()
|
|
279
282
|
.await
|
|
280
283
|
.fwd_tcp(addr)
|
|
281
|
-
.await
|
|
282
|
-
|
|
284
|
+
.await;
|
|
285
|
+
|
|
283
286
|
debug!("forward_tcp returning");
|
|
284
|
-
res
|
|
287
|
+
canceled_is_ok(res)
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
pub async fn forward_pipe(id: &String, addr: String) -> Result<()> {
|
|
@@ -292,10 +295,29 @@ pub async fn forward_pipe(id: &String, addr: String) -> Result<()> {
|
|
|
292
295
|
.lock()
|
|
293
296
|
.await
|
|
294
297
|
.fwd_pipe(addr)
|
|
295
|
-
.await
|
|
296
|
-
|
|
298
|
+
.await;
|
|
299
|
+
|
|
297
300
|
debug!("forward_pipe returning");
|
|
298
|
-
res
|
|
301
|
+
canceled_is_ok(res)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
fn canceled_is_ok(input: CoreResult<(), io::Error>) -> Result<()> {
|
|
305
|
+
match input {
|
|
306
|
+
Ok(_) => Ok(()),
|
|
307
|
+
Err(e) => {
|
|
308
|
+
if let Some(source) = e
|
|
309
|
+
.source()
|
|
310
|
+
.and_then(|s| s.downcast_ref::<Arc<ConnectError>>())
|
|
311
|
+
{
|
|
312
|
+
if let ConnectError::Canceled = **source {
|
|
313
|
+
debug!("Reconnect was canceled, session is closing, returning Ok");
|
|
314
|
+
return Ok(());
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
Err(napi_err(format!("error forwarding: {e:?}")))
|
|
319
|
+
}
|
|
320
|
+
}
|
|
299
321
|
}
|
|
300
322
|
|
|
301
323
|
/// Get url using the tunnel id
|