@ngrok/ngrok 0.0.6 → 0.0.8
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 +16 -0
- package/CONTRIBUTING.md +4 -4
- package/Cargo.toml +5 -2
- package/README.md +11 -11
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +71 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1280 -0
- package/docs/classes/NgrokHttpTunnel.html +189 -0
- package/docs/classes/NgrokHttpTunnelBuilder.html +440 -0
- package/docs/classes/NgrokLabeledTunnel.html +177 -0
- package/docs/classes/NgrokLabeledTunnelBuilder.html +130 -0
- package/docs/classes/NgrokSession.html +142 -0
- package/docs/classes/NgrokSessionBuilder.html +303 -0
- package/docs/classes/NgrokTcpTunnel.html +189 -0
- package/docs/classes/NgrokTcpTunnelBuilder.html +199 -0
- package/docs/classes/NgrokTlsTunnel.html +189 -0
- package/docs/classes/NgrokTlsTunnelBuilder.html +235 -0
- package/docs/classes/UpdateRequest.html +92 -0
- package/docs/functions/consoleLog.html +73 -0
- package/docs/functions/listen.html +74 -0
- package/docs/functions/listenable.html +72 -0
- package/docs/functions/loggingCallback.html +91 -0
- package/docs/index.html +129 -0
- package/docs/modules.html +79 -0
- package/examples/ngrok-http-full.js +18 -8
- package/examples/ngrok-http-minimum.js +1 -3
- package/examples/ngrok-labeled.js +2 -4
- package/examples/ngrok-tcp.js +4 -6
- package/examples/ngrok-tls.js +6 -8
- package/examples/ngrok-typescript.ts +64 -0
- package/examples/ngrok-winston.js +24 -0
- package/index.d.ts +193 -41
- package/index.js +114 -27
- package/package.json +25 -17
- package/post-build.js +23 -16
- package/scripts/gc-node-drop.js +42 -0
- package/scripts/gc-rust-drop.js +47 -0
- package/src/http.rs +64 -42
- package/src/lib.rs +10 -0
- package/src/logging.rs +134 -0
- package/src/session.rs +239 -63
- package/src/tcp.rs +2 -1
- package/src/tls.rs +10 -18
- package/src/tunnel.rs +146 -22
- package/src/tunnel_builder.rs +46 -28
- package/trailer.d.ts +9 -0
- package/trailer.js +111 -25
- package/tsconfig.json +6 -0
- package/examples/ngrok-get-socket.js +0 -13
package/docs/index.html
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@ngrok/ngrok</title><meta name="description" content="Documentation for @ngrok/ngrok"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base=".">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<div class="field">
|
|
6
|
+
<div id="tsd-toolbar-links"></div></div>
|
|
7
|
+
<ul class="results">
|
|
8
|
+
<li class="state loading">Preparing search index...</li>
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@ngrok/ngrok</a></div>
|
|
10
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
|
+
<div class="container container-main">
|
|
12
|
+
<div class="col-8 col-content">
|
|
13
|
+
<div class="tsd-page-title">
|
|
14
|
+
<h2>@ngrok/ngrok</h2></div>
|
|
15
|
+
<div class="tsd-panel tsd-typography">
|
|
16
|
+
<a href="#the-ngrok-agent-sdk-for-nodejs" id="the-ngrok-agent-sdk-for-nodejs" style="color: inherit; text-decoration: none;">
|
|
17
|
+
<h1>The ngrok Agent SDK for NodeJS</h1>
|
|
18
|
+
</a>
|
|
19
|
+
<p><a href="https://www.npmjs.com/package/@ngrok/ngrok"><img src="https://img.shields.io/npm/v/@ngrok/ngrok.svg" alt="npm.rs"></a>
|
|
20
|
+
<a href="https://github.com/ngrok/ngrok-rs/blob/main/LICENSE-MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT licensed"></a>
|
|
21
|
+
<a href="https://github.com/ngrok/ngrok-rs/blob/main/LICENSE-APACHE"><img src="https://img.shields.io/badge/license-Apache_2.0-blue.svg" alt="Apache-2.0 licensed"></a>
|
|
22
|
+
<a href="https://github.com/ngrok/ngrok-js/actions/workflows/ci.yml"><img src="https://github.com/ngrok/ngrok-js/actions/workflows/ci.yml/badge.svg" alt="Continuous integration"></a></p>
|
|
23
|
+
<p><a href="https://ngrok.com">Website</a></p>
|
|
24
|
+
<p><strong>Note: This is alpha-quality software. Interfaces are subject to change without warning.</strong></p>
|
|
25
|
+
<p>ngrok is a globally distributed reverse proxy commonly used for quickly getting a public URL to a
|
|
26
|
+
service running inside a private network, such as on your local laptop. The ngrok agent is usually
|
|
27
|
+
deployed inside a private network and is used to communicate with the ngrok cloud service.</p>
|
|
28
|
+
<p>This is the ngrok agent in library form, suitable for integrating directly into NodeJS
|
|
29
|
+
applications. This allows you to quickly build ngrok into your application with no separate process
|
|
30
|
+
to manage.</p>
|
|
31
|
+
|
|
32
|
+
<a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
|
|
33
|
+
<h1>Installation</h1>
|
|
34
|
+
</a>
|
|
35
|
+
<p>The published library is available on
|
|
36
|
+
<a href="https://www.npmjs.com/package/@ngrok/ngrok">npm</a>.</p>
|
|
37
|
+
<pre><code class="language-shell"><span class="hl-0">npm </span><span class="hl-1">install</span><span class="hl-0"> </span><span class="hl-1">@ngrok/ngrok</span>
|
|
38
|
+
</code></pre>
|
|
39
|
+
|
|
40
|
+
<a href="#quickstart" id="quickstart" style="color: inherit; text-decoration: none;">
|
|
41
|
+
<h1>Quickstart</h1>
|
|
42
|
+
</a>
|
|
43
|
+
<p>After you've installed the package, you'll need an Auth Token. Retrieve one on the
|
|
44
|
+
<a href="https://dashboard.ngrok.com/get-started/your-authtoken">Auth Token page of your ngrok dashboard</a></p>
|
|
45
|
+
<p>There are multiple examples in <a href="https://github.com/ngrok/ngrok-js/tree/main/examples">the /examples directory</a>.
|
|
46
|
+
A minimal use-case looks like the following:</p>
|
|
47
|
+
<pre><code class="language-jsx"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">server</span><span class="hl-0"> = </span><span class="hl-4">require</span><span class="hl-0">(</span><span class="hl-1">'http'</span><span class="hl-0">).</span><span class="hl-4">createServer</span><span class="hl-0">(</span><br/><span class="hl-0"> </span><span class="hl-2">function</span><span class="hl-0">(</span><span class="hl-5">req</span><span class="hl-0">,</span><span class="hl-5">res</span><span class="hl-0">){</span><span class="hl-5">res</span><span class="hl-0">.</span><span class="hl-4">writeHead</span><span class="hl-0">(</span><span class="hl-6">200</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-5">res</span><span class="hl-0">.</span><span class="hl-4">write</span><span class="hl-0">(</span><span class="hl-1">'Hello'</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-5">res</span><span class="hl-0">.</span><span class="hl-4">end</span><span class="hl-0">();</span><br/><span class="hl-0">} );</span><br/><br/><span class="hl-2">var</span><span class="hl-0"> </span><span class="hl-5">ngrok</span><span class="hl-0"> = </span><span class="hl-4">require</span><span class="hl-0">(</span><span class="hl-1">'@ngrok/ngrok'</span><span class="hl-0">);</span><br/><br/><span class="hl-5">ngrok</span><span class="hl-0">.</span><span class="hl-4">listen</span><span class="hl-0">(</span><span class="hl-5">server</span><span class="hl-0">).</span><span class="hl-4">then</span><span class="hl-0">(() </span><span class="hl-2">=></span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-5">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-1">"url: "</span><span class="hl-0"> + </span><span class="hl-5">server</span><span class="hl-0">.</span><span class="hl-5">tunnel</span><span class="hl-0">.</span><span class="hl-4">url</span><span class="hl-0">());</span><br/><span class="hl-0">});</span>
|
|
48
|
+
</code></pre>
|
|
49
|
+
|
|
50
|
+
<a href="#async-programming" id="async-programming" style="color: inherit; text-decoration: none;">
|
|
51
|
+
<h3>Async Programming</h3>
|
|
52
|
+
</a>
|
|
53
|
+
<p>All methods return a <code>Promise</code> and are suitable for use in asynchronous
|
|
54
|
+
programming. You can use callback chaining with <code>.then()</code> and <code>.catch()</code> syntax
|
|
55
|
+
or the <code>await</code> keyword to wait for completion of an API call.</p>
|
|
56
|
+
|
|
57
|
+
<a href="#error-handling" id="error-handling" style="color: inherit; text-decoration: none;">
|
|
58
|
+
<h3>Error Handling</h3>
|
|
59
|
+
</a>
|
|
60
|
+
<p>The asynchronous functions will throw an error on failure to set up a session or tunnel,
|
|
61
|
+
which can be caught and dealt with using standard then/catch semantics.</p>
|
|
62
|
+
<pre><code class="language-jsx"><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-5">ngrok</span><span class="hl-0">.</span><span class="hl-4">NgrokSessionBuilder</span><span class="hl-0">().</span><span class="hl-4">authtokenFromEnv</span><span class="hl-0">().</span><span class="hl-4">connect</span><span class="hl-0">()</span><br/><span class="hl-0"> .</span><span class="hl-4">then</span><span class="hl-0">((</span><span class="hl-5">session</span><span class="hl-0">) </span><span class="hl-2">=></span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-5">session</span><span class="hl-0">.</span><span class="hl-4">httpEndpoint</span><span class="hl-0">().</span><span class="hl-4">listen</span><span class="hl-0">()</span><br/><span class="hl-0"> .</span><span class="hl-4">then</span><span class="hl-0">((</span><span class="hl-5">tun</span><span class="hl-0">) </span><span class="hl-2">=></span><span class="hl-0"> {})</span><br/><span class="hl-0"> .</span><span class="hl-4">catch</span><span class="hl-0">(</span><span class="hl-5">err</span><span class="hl-0"> </span><span class="hl-2">=></span><span class="hl-0"> </span><span class="hl-5">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-1">'tunnel setup error: '</span><span class="hl-0"> + </span><span class="hl-5">err</span><span class="hl-0">))</span><br/><span class="hl-0"> })</span><br/><span class="hl-0"> .</span><span class="hl-4">catch</span><span class="hl-0">(</span><span class="hl-5">err</span><span class="hl-0"> </span><span class="hl-2">=></span><span class="hl-0"> </span><span class="hl-5">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-1">'session setup error: '</span><span class="hl-0"> + </span><span class="hl-5">err</span><span class="hl-0">))</span><br/><span class="hl-0"> .</span><span class="hl-5">await</span><span class="hl-0">;</span>
|
|
63
|
+
</code></pre>
|
|
64
|
+
|
|
65
|
+
<a href="#dependencies" id="dependencies" style="color: inherit; text-decoration: none;">
|
|
66
|
+
<h1>Dependencies</h1>
|
|
67
|
+
</a>
|
|
68
|
+
<p>This project relies on <a href="https://napi.rs/">NAPI-RS</a>, an excellent system to ease development and building of Rust plugins for NodeJS.</p>
|
|
69
|
+
|
|
70
|
+
<a href="#license" id="license" style="color: inherit; text-decoration: none;">
|
|
71
|
+
<h1>License</h1>
|
|
72
|
+
</a>
|
|
73
|
+
<p>This project is licensed under either of</p>
|
|
74
|
+
<ul>
|
|
75
|
+
<li>Apache License, Version 2.0, (<a href="LICENSE-APACHE">LICENSE-APACHE</a> or
|
|
76
|
+
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
|
|
77
|
+
<li>MIT license (<a href="LICENSE-MIT">LICENSE-MIT</a> or
|
|
78
|
+
<a href="http://opensource.org/licenses/MIT">http://opensource.org/licenses/MIT</a>)</li>
|
|
79
|
+
</ul>
|
|
80
|
+
<p>at your option.</p>
|
|
81
|
+
|
|
82
|
+
<a href="#contribution" id="contribution" style="color: inherit; text-decoration: none;">
|
|
83
|
+
<h3>Contribution</h3>
|
|
84
|
+
</a>
|
|
85
|
+
<p>Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
86
|
+
for inclusion in tokio-core by you, as defined in the Apache-2.0 license, shall be
|
|
87
|
+
dual licensed as above, without any additional terms or conditions.</p>
|
|
88
|
+
</div></div>
|
|
89
|
+
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
90
|
+
<div class="tsd-navigation settings">
|
|
91
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
92
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
|
|
93
|
+
<div class="tsd-accordion-details">
|
|
94
|
+
<div class="tsd-filter-visibility">
|
|
95
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
96
|
+
<ul id="tsd-filter-options">
|
|
97
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
98
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
|
|
99
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
100
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
|
|
101
|
+
<div class="tsd-theme-toggle">
|
|
102
|
+
<h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
103
|
+
<nav class="tsd-navigation primary">
|
|
104
|
+
<details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
|
|
105
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
|
|
106
|
+
<div class="tsd-accordion-details">
|
|
107
|
+
<ul>
|
|
108
|
+
<li class="current selected"><a href="modules.html">@ngrok/ngrok</a>
|
|
109
|
+
<ul></ul></li></ul></div></details></nav>
|
|
110
|
+
<nav class="tsd-navigation secondary menu-sticky">
|
|
111
|
+
<ul>
|
|
112
|
+
<li class="tsd-kind-class"><a href="classes/NgrokHttpTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg>Ngrok<wbr/>Http<wbr/>Tunnel</a></li>
|
|
113
|
+
<li class="tsd-kind-class"><a href="classes/NgrokHttpTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Http<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
114
|
+
<li class="tsd-kind-class"><a href="classes/NgrokLabeledTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Labeled<wbr/>Tunnel</a></li>
|
|
115
|
+
<li class="tsd-kind-class"><a href="classes/NgrokLabeledTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Labeled<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
116
|
+
<li class="tsd-kind-class"><a href="classes/NgrokSession.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Session</a></li>
|
|
117
|
+
<li class="tsd-kind-class"><a href="classes/NgrokSessionBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Session<wbr/>Builder</a></li>
|
|
118
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTcpTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tcp<wbr/>Tunnel</a></li>
|
|
119
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTcpTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tcp<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
120
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTlsTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tls<wbr/>Tunnel</a></li>
|
|
121
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTlsTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tls<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
122
|
+
<li class="tsd-kind-class"><a href="classes/UpdateRequest.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Update<wbr/>Request</a></li>
|
|
123
|
+
<li class="tsd-kind-function"><a href="functions/consoleLog.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-64-path"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)" id="icon-64-text"></path></svg>console<wbr/>Log</a></li>
|
|
124
|
+
<li class="tsd-kind-function"><a href="functions/listen.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>listen</a></li>
|
|
125
|
+
<li class="tsd-kind-function"><a href="functions/listenable.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>listenable</a></li>
|
|
126
|
+
<li class="tsd-kind-function"><a href="functions/loggingCallback.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>logging<wbr/>Callback</a></li></ul></nav></div></div>
|
|
127
|
+
<div class="container tsd-generator">
|
|
128
|
+
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
|
|
129
|
+
<div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@ngrok/ngrok</title><meta name="description" content="Documentation for @ngrok/ngrok"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base=".">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<div class="field">
|
|
6
|
+
<div id="tsd-toolbar-links"></div></div>
|
|
7
|
+
<ul class="results">
|
|
8
|
+
<li class="state loading">Preparing search index...</li>
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@ngrok/ngrok</a></div>
|
|
10
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
|
+
<div class="container container-main">
|
|
12
|
+
<div class="col-8 col-content">
|
|
13
|
+
<div class="tsd-page-title">
|
|
14
|
+
<h2>@ngrok/ngrok</h2></div>
|
|
15
|
+
<section class="tsd-panel-group tsd-index-group">
|
|
16
|
+
<section class="tsd-panel tsd-index-panel">
|
|
17
|
+
<h3 class="tsd-index-heading uppercase">Index</h3>
|
|
18
|
+
<section class="tsd-index-section">
|
|
19
|
+
<h3 class="tsd-index-heading">Classes</h3>
|
|
20
|
+
<div class="tsd-index-list"><a href="classes/NgrokHttpTunnel.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg><span>Ngrok<wbr/>Http<wbr/>Tunnel</span></a>
|
|
21
|
+
<a href="classes/NgrokHttpTunnelBuilder.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Http<wbr/>Tunnel<wbr/>Builder</span></a>
|
|
22
|
+
<a href="classes/NgrokLabeledTunnel.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Labeled<wbr/>Tunnel</span></a>
|
|
23
|
+
<a href="classes/NgrokLabeledTunnelBuilder.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Labeled<wbr/>Tunnel<wbr/>Builder</span></a>
|
|
24
|
+
<a href="classes/NgrokSession.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Session</span></a>
|
|
25
|
+
<a href="classes/NgrokSessionBuilder.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Session<wbr/>Builder</span></a>
|
|
26
|
+
<a href="classes/NgrokTcpTunnel.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Tcp<wbr/>Tunnel</span></a>
|
|
27
|
+
<a href="classes/NgrokTcpTunnelBuilder.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Tcp<wbr/>Tunnel<wbr/>Builder</span></a>
|
|
28
|
+
<a href="classes/NgrokTlsTunnel.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Tls<wbr/>Tunnel</span></a>
|
|
29
|
+
<a href="classes/NgrokTlsTunnelBuilder.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Ngrok<wbr/>Tls<wbr/>Tunnel<wbr/>Builder</span></a>
|
|
30
|
+
<a href="classes/UpdateRequest.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Update<wbr/>Request</span></a>
|
|
31
|
+
</div></section>
|
|
32
|
+
<section class="tsd-index-section">
|
|
33
|
+
<h3 class="tsd-index-heading">Functions</h3>
|
|
34
|
+
<div class="tsd-index-list"><a href="functions/consoleLog.html" class="tsd-index-link tsd-kind-function"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-64-path"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)" id="icon-64-text"></path></svg><span>console<wbr/>Log</span></a>
|
|
35
|
+
<a href="functions/listen.html" class="tsd-index-link tsd-kind-function"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg><span>listen</span></a>
|
|
36
|
+
<a href="functions/listenable.html" class="tsd-index-link tsd-kind-function"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg><span>listenable</span></a>
|
|
37
|
+
<a href="functions/loggingCallback.html" class="tsd-index-link tsd-kind-function"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg><span>logging<wbr/>Callback</span></a>
|
|
38
|
+
</div></section></section></section></div>
|
|
39
|
+
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
40
|
+
<div class="tsd-navigation settings">
|
|
41
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
42
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
|
|
43
|
+
<div class="tsd-accordion-details">
|
|
44
|
+
<div class="tsd-filter-visibility">
|
|
45
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
46
|
+
<ul id="tsd-filter-options">
|
|
47
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
48
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
|
|
49
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
50
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
|
|
51
|
+
<div class="tsd-theme-toggle">
|
|
52
|
+
<h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
53
|
+
<nav class="tsd-navigation primary">
|
|
54
|
+
<details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
|
|
55
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
|
|
56
|
+
<div class="tsd-accordion-details">
|
|
57
|
+
<ul>
|
|
58
|
+
<li class="current selected"><a href="modules.html">@ngrok/ngrok</a>
|
|
59
|
+
<ul></ul></li></ul></div></details></nav>
|
|
60
|
+
<nav class="tsd-navigation secondary menu-sticky">
|
|
61
|
+
<ul>
|
|
62
|
+
<li class="tsd-kind-class"><a href="classes/NgrokHttpTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Http<wbr/>Tunnel</a></li>
|
|
63
|
+
<li class="tsd-kind-class"><a href="classes/NgrokHttpTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Http<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
64
|
+
<li class="tsd-kind-class"><a href="classes/NgrokLabeledTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Labeled<wbr/>Tunnel</a></li>
|
|
65
|
+
<li class="tsd-kind-class"><a href="classes/NgrokLabeledTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Labeled<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
66
|
+
<li class="tsd-kind-class"><a href="classes/NgrokSession.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Session</a></li>
|
|
67
|
+
<li class="tsd-kind-class"><a href="classes/NgrokSessionBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Session<wbr/>Builder</a></li>
|
|
68
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTcpTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tcp<wbr/>Tunnel</a></li>
|
|
69
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTcpTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tcp<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
70
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTlsTunnel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tls<wbr/>Tunnel</a></li>
|
|
71
|
+
<li class="tsd-kind-class"><a href="classes/NgrokTlsTunnelBuilder.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ngrok<wbr/>Tls<wbr/>Tunnel<wbr/>Builder</a></li>
|
|
72
|
+
<li class="tsd-kind-class"><a href="classes/UpdateRequest.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Update<wbr/>Request</a></li>
|
|
73
|
+
<li class="tsd-kind-function"><a href="functions/consoleLog.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>console<wbr/>Log</a></li>
|
|
74
|
+
<li class="tsd-kind-function"><a href="functions/listen.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>listen</a></li>
|
|
75
|
+
<li class="tsd-kind-function"><a href="functions/listenable.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>listenable</a></li>
|
|
76
|
+
<li class="tsd-kind-function"><a href="functions/loggingCallback.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>logging<wbr/>Callback</a></li></ul></nav></div></div>
|
|
77
|
+
<div class="container tsd-generator">
|
|
78
|
+
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
|
|
79
|
+
<div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var UNIX_SOCKET = "/tmp/http.socket";
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
fs.unlinkSync(UNIX_SOCKET)
|
|
3
|
+
try{fs.unlinkSync(UNIX_SOCKET)} catch {}
|
|
4
4
|
|
|
5
5
|
// make webserver
|
|
6
6
|
var http = require('http');
|
|
@@ -14,20 +14,31 @@ console.log('Node.js web server at ' + UNIX_SOCKET + ' is running..');
|
|
|
14
14
|
|
|
15
15
|
// setup ngrok
|
|
16
16
|
var ngrok = require('@ngrok/ngrok');
|
|
17
|
+
// import ngrok from '@ngrok/ngrok' // if inside a module
|
|
18
|
+
ngrok.consoleLog(); // turn on debug logging
|
|
17
19
|
builder = new ngrok.NgrokSessionBuilder();
|
|
18
20
|
builder
|
|
19
21
|
// .authtoken("<authtoken>")
|
|
20
22
|
.authtokenFromEnv()
|
|
21
|
-
.metadata("Online in One Line")
|
|
23
|
+
.metadata("Online in One Line")
|
|
24
|
+
.handleStopCommand(() => {
|
|
25
|
+
console.log("stop command");
|
|
26
|
+
})
|
|
27
|
+
.handleRestartCommand(() => {
|
|
28
|
+
console.log("restart command");
|
|
29
|
+
})
|
|
30
|
+
.handleUpdateCommand((update) => {
|
|
31
|
+
console.log("update command, version: " + update.version
|
|
32
|
+
+ " permitMajorVersion: " + update.permitMajorVersion);
|
|
33
|
+
});
|
|
22
34
|
|
|
23
35
|
builder.connect().then((session) => {
|
|
24
|
-
http.ngrok_session = session; // prevent garbage collection
|
|
25
36
|
session.httpEndpoint()
|
|
26
|
-
// .
|
|
37
|
+
// .allowCidr("0.0.0.0/0")
|
|
27
38
|
// .basicAuth("ngrok", "online1line")
|
|
28
39
|
// .circuitBreaker(0.5)
|
|
29
40
|
// .compression()
|
|
30
|
-
// .
|
|
41
|
+
// .denyCidr("10.1.1.1/32")
|
|
31
42
|
// .domain("<somedomain>.ngrok.io")
|
|
32
43
|
// .mutualTlsca(fs.readFileSync('domain.crt'))
|
|
33
44
|
// .oauth("google", ["<user>@<domain>"], ["<domain>"], ["<scope>"])
|
|
@@ -39,11 +50,10 @@ builder.connect().then((session) => {
|
|
|
39
50
|
// .responseHeader("X-Res-Yup", "true")
|
|
40
51
|
// .scheme("HTTPS")
|
|
41
52
|
// .websocketTcpConversion()
|
|
42
|
-
// .webhookVerification("twilio", "asdf")
|
|
53
|
+
// .webhookVerification("twilio", "asdf")
|
|
43
54
|
.metadata("example tunnel metadata from nodejs")
|
|
44
55
|
.listen().then((tunnel) => {
|
|
45
|
-
http.tunnel = tunnel; // prevent garbage collection
|
|
46
56
|
console.log("established tunnel at: " + tunnel.url())
|
|
47
57
|
tunnel.forwardUnix(UNIX_SOCKET);
|
|
48
58
|
})
|
|
49
|
-
})
|
|
59
|
+
});
|
|
@@ -7,10 +7,8 @@ http.createServer(
|
|
|
7
7
|
|
|
8
8
|
var ngrok = require('@ngrok/ngrok');
|
|
9
9
|
new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect().then((session) => {
|
|
10
|
-
http.ngrok_session = session; // prevent garbage collection
|
|
11
10
|
session.httpEndpoint().listen().then((tunnel) => {
|
|
12
|
-
http.tunnel = tunnel; // prevent garbage collection
|
|
13
11
|
console.log('tunnel at: ' + tunnel.url());
|
|
14
12
|
tunnel.forwardTcp('localhost:8081');
|
|
15
13
|
})
|
|
16
|
-
})
|
|
14
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var UNIX_SOCKET = "/tmp/http.socket";
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
fs.unlinkSync(UNIX_SOCKET)
|
|
3
|
+
try{fs.unlinkSync(UNIX_SOCKET)} catch {}
|
|
4
4
|
|
|
5
5
|
// make webserver
|
|
6
6
|
var http = require('http');
|
|
@@ -19,13 +19,11 @@ builder.authtokenFromEnv()
|
|
|
19
19
|
.metadata("Online in One Line");
|
|
20
20
|
|
|
21
21
|
builder.connect().then((session) => {
|
|
22
|
-
http.ngrok_session = session; // prevent garbage collection
|
|
23
22
|
session.labeledTunnel()
|
|
24
23
|
.label("edge", "edghts_<edge_id>")
|
|
25
24
|
.metadata("example tunnel metadata from nodejs")
|
|
26
25
|
.listen().then((tunnel) => {
|
|
27
|
-
http.tunnel = tunnel; // prevent garbage collection
|
|
28
26
|
console.log("established tunnel at: " + JSON.stringify(tunnel.labels()))
|
|
29
27
|
tunnel.forwardUnix(UNIX_SOCKET);
|
|
30
28
|
})
|
|
31
|
-
})
|
|
29
|
+
});
|
package/examples/ngrok-tcp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var UNIX_SOCKET = "/tmp/http.socket";
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
fs.unlinkSync(UNIX_SOCKET)
|
|
3
|
+
try{fs.unlinkSync(UNIX_SOCKET)} catch {}
|
|
4
4
|
|
|
5
5
|
// make webserver
|
|
6
6
|
var http = require('http');
|
|
@@ -20,17 +20,15 @@ builder.authtokenFromEnv()
|
|
|
20
20
|
|
|
21
21
|
var global_tunnel;
|
|
22
22
|
builder.connect().then((session) => {
|
|
23
|
-
http.ngrok_session = session; // prevent garbage collection
|
|
24
23
|
session.tcpEndpoint()
|
|
25
|
-
// .
|
|
26
|
-
// .
|
|
24
|
+
// .allowCidr("0.0.0.0/0")
|
|
25
|
+
// .denyCidr("10.1.1.1/32")
|
|
27
26
|
// .forwardsTo("example nodejs")
|
|
28
27
|
// .proxyProto("") // One of: "", "V1", "V2"
|
|
29
28
|
// .remoteAddr("<n>.tcp.ngrok.io:<p>")
|
|
30
29
|
.metadata("example tunnel metadata from nodejs")
|
|
31
30
|
.listen().then((tunnel) => {
|
|
32
|
-
http.tunnel = tunnel; // prevent garbage collection
|
|
33
31
|
console.log("established tunnel at: " + tunnel.url())
|
|
34
32
|
tunnel.forwardUnix(UNIX_SOCKET);
|
|
35
33
|
})
|
|
36
|
-
})
|
|
34
|
+
});
|
package/examples/ngrok-tls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var UNIX_SOCKET = "/tmp/http.socket";
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
fs.unlinkSync(UNIX_SOCKET)
|
|
3
|
+
try{fs.unlinkSync(UNIX_SOCKET)} catch {}
|
|
4
4
|
|
|
5
5
|
// make webserver
|
|
6
6
|
var http = require('http');
|
|
@@ -19,22 +19,20 @@ builder.authtokenFromEnv()
|
|
|
19
19
|
.metadata("Online in One Line");
|
|
20
20
|
|
|
21
21
|
builder.connect().then((session) => {
|
|
22
|
-
http.ngrok_session = session; // prevent garbage collection
|
|
23
22
|
console.log("established session");
|
|
24
23
|
session.tlsEndpoint()
|
|
25
|
-
// .
|
|
26
|
-
// .
|
|
24
|
+
// .allowCidr("0.0.0.0/0")
|
|
25
|
+
// .denyCidr("10.1.1.1/32")
|
|
27
26
|
// .domain("<somedomain>.ngrok.io")
|
|
28
27
|
// .forwardsTo("example nodejs")
|
|
29
28
|
// .mutualTlsca(fs.readFileSync('ca.crt'))
|
|
30
29
|
// .proxyProto("") // One of: "", "V1", "V2"
|
|
31
30
|
// .remoteAddr("<n>.tcp.ngrok.io:<p>")
|
|
32
|
-
.
|
|
33
|
-
|
|
31
|
+
.termination(fs.readFileSync('domain.crt'),
|
|
32
|
+
fs.readFileSync('domain.key'))
|
|
34
33
|
.metadata("example tunnel metadata from nodejs")
|
|
35
34
|
.listen().then((tunnel) => {
|
|
36
|
-
http.tunnel = tunnel; // prevent garbage collection
|
|
37
35
|
console.log("established tunnel at: " + tunnel.url())
|
|
38
36
|
tunnel.forwardUnix(UNIX_SOCKET);
|
|
39
37
|
})
|
|
40
|
-
})
|
|
38
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Run with 'ts-node examples/ngrok-typescript.ts'
|
|
2
|
+
|
|
3
|
+
import * as http from "http";
|
|
4
|
+
const httpServer = http.createServer(
|
|
5
|
+
function(req,res){res.writeHead(200);
|
|
6
|
+
res.write('Hello');
|
|
7
|
+
res.end();
|
|
8
|
+
} );
|
|
9
|
+
|
|
10
|
+
import * as ngrok from "../index";
|
|
11
|
+
ngrok.consoleLog();
|
|
12
|
+
|
|
13
|
+
const run = async (): Promise<void> => {
|
|
14
|
+
// await listenServer();
|
|
15
|
+
// await listenable();
|
|
16
|
+
// await listen();
|
|
17
|
+
await standardConfig();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function listenServer() {
|
|
21
|
+
const tunnel = await ngrok.listen(httpServer);
|
|
22
|
+
if ( typeof tunnel['url'] === 'function') {
|
|
23
|
+
console.log("tunnel at: " + tunnel['url']());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function listenable() {
|
|
28
|
+
const tunnel = await ngrok.listenable();
|
|
29
|
+
httpServer.listen(tunnel);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function listen() {
|
|
33
|
+
const sessionBuilder = new ngrok.NgrokSessionBuilder().authtokenFromEnv()
|
|
34
|
+
const session = await sessionBuilder.connect();
|
|
35
|
+
const tunnel = await session.httpEndpoint().listen();
|
|
36
|
+
httpServer.listen(tunnel);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function standardConfig() {
|
|
40
|
+
ngrok.loggingCallback(function(level, target, message) {
|
|
41
|
+
console.log(`${level} ${target} - ${message}`);
|
|
42
|
+
});
|
|
43
|
+
const sessionBuilder = new ngrok.NgrokSessionBuilder().authtokenFromEnv()
|
|
44
|
+
.handleStopCommand(() => {
|
|
45
|
+
console.log("stop command");
|
|
46
|
+
})
|
|
47
|
+
.handleRestartCommand(() => {
|
|
48
|
+
console.log("restart command");
|
|
49
|
+
})
|
|
50
|
+
.handleUpdateCommand((update) => {
|
|
51
|
+
console.log("update command, version: " + update.version
|
|
52
|
+
+ " permitMajorVersion: " + update.permitMajorVersion);
|
|
53
|
+
});
|
|
54
|
+
const session = await sessionBuilder.connect();
|
|
55
|
+
const tunnel = await session.httpEndpoint().listen();
|
|
56
|
+
console.log('tunnel at: ' + tunnel.url());
|
|
57
|
+
httpServer.listen(8081);
|
|
58
|
+
tunnel.forwardTcp('localhost:8081');
|
|
59
|
+
|
|
60
|
+
// unregister logging callback
|
|
61
|
+
ngrok.loggingCallback();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
run();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// create winston logger
|
|
2
|
+
const { createLogger, format, transports } = require('winston');
|
|
3
|
+
const logger = createLogger({
|
|
4
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
5
|
+
level: 'silly',
|
|
6
|
+
transports: [new transports.Console({})],
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// plumb ngrok logging to winston
|
|
10
|
+
var ngrok = require('@ngrok/ngrok');
|
|
11
|
+
ngrok.loggingCallback(function (level, target, message) {
|
|
12
|
+
level = level == "TRACE" ? "silly" : level.toLowerCase();
|
|
13
|
+
logger.log(level, message, {"target": target});
|
|
14
|
+
}, "TRACE");
|
|
15
|
+
|
|
16
|
+
// set up tunnel
|
|
17
|
+
const server = require('http').createServer(
|
|
18
|
+
function(req,res){res.writeHead(200);
|
|
19
|
+
res.write('Hello');
|
|
20
|
+
res.end();
|
|
21
|
+
});
|
|
22
|
+
ngrok.listen(server).then((tunnel) => {
|
|
23
|
+
console.log("url: " + tunnel.url());
|
|
24
|
+
});
|