opentunnel-cli 1.0.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/LICENSE +21 -0
- package/README.md +284 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1357 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/NgrokClient.d.ts +40 -0
- package/dist/client/NgrokClient.d.ts.map +1 -0
- package/dist/client/NgrokClient.js +155 -0
- package/dist/client/NgrokClient.js.map +1 -0
- package/dist/client/TunnelClient.d.ts +47 -0
- package/dist/client/TunnelClient.d.ts.map +1 -0
- package/dist/client/TunnelClient.js +435 -0
- package/dist/client/TunnelClient.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/dns/CloudflareDNS.d.ts +45 -0
- package/dist/dns/CloudflareDNS.d.ts.map +1 -0
- package/dist/dns/CloudflareDNS.js +286 -0
- package/dist/dns/CloudflareDNS.js.map +1 -0
- package/dist/dns/DuckDNS.d.ts +20 -0
- package/dist/dns/DuckDNS.d.ts.map +1 -0
- package/dist/dns/DuckDNS.js +109 -0
- package/dist/dns/DuckDNS.js.map +1 -0
- package/dist/dns/index.d.ts +3 -0
- package/dist/dns/index.d.ts.map +1 -0
- package/dist/dns/index.js +9 -0
- package/dist/dns/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/server/CertManager.d.ts +54 -0
- package/dist/server/CertManager.d.ts.map +1 -0
- package/dist/server/CertManager.js +414 -0
- package/dist/server/CertManager.js.map +1 -0
- package/dist/server/TunnelServer.d.ts +42 -0
- package/dist/server/TunnelServer.d.ts.map +1 -0
- package/dist/server/TunnelServer.js +790 -0
- package/dist/server/TunnelServer.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +48 -0
- package/dist/server/index.js.map +1 -0
- package/dist/shared/types.d.ts +147 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +3 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/utils.d.ts +29 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +135 -0
- package/dist/shared/utils.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FJRG2007
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# OpenTunnel
|
|
2
|
+
|
|
3
|
+
Self-hosted alternative to ngrok. Expose local services to the internet with custom subdomains.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### NPM (Recommended - All OS)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install globally
|
|
11
|
+
npm install -g opentunnel-cli
|
|
12
|
+
|
|
13
|
+
# Verify installation
|
|
14
|
+
opentunnel --version
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### NPX (No installation)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx opentunnel-cli up
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### From Source
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/FJRG2007/opentunnel.git
|
|
27
|
+
cd opentunnel
|
|
28
|
+
npm install
|
|
29
|
+
npm run build
|
|
30
|
+
npm link # Makes 'opentunnel' available globally
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Update
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm update -g opentunnel-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Main commands
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
opentunnel up # Start server and tunnels
|
|
47
|
+
opentunnel down # Stop everything
|
|
48
|
+
opentunnel init # Create opentunnel.yml config file
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Deployment Types
|
|
54
|
+
|
|
55
|
+
### 1. On a VPS/Server
|
|
56
|
+
|
|
57
|
+
Typical production use. The server runs on a VPS with a public IP and configured domain.
|
|
58
|
+
|
|
59
|
+
**Requirements:**
|
|
60
|
+
- VPS with public IP
|
|
61
|
+
- Domain pointing to the VPS (e.g., `*.op.yourdomain.com`)
|
|
62
|
+
- Port 443 open
|
|
63
|
+
|
|
64
|
+
**DNS Configuration:**
|
|
65
|
+
```
|
|
66
|
+
Type Name Content/Value Proxy status (Cloudflare only)
|
|
67
|
+
A *.op <VPS_IP_ADDRESS> DNS only
|
|
68
|
+
A op <VPS_IP_ADDRESS> DNS only
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**opentunnel.yml on the VPS:**
|
|
72
|
+
```yaml
|
|
73
|
+
version: "1.0"
|
|
74
|
+
|
|
75
|
+
server:
|
|
76
|
+
port: 443
|
|
77
|
+
domain: yourdomain.com
|
|
78
|
+
basePath: op
|
|
79
|
+
|
|
80
|
+
tunnels: [] # VPS only runs the server
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**On your local machine:**
|
|
84
|
+
```yaml
|
|
85
|
+
version: "1.0"
|
|
86
|
+
|
|
87
|
+
server:
|
|
88
|
+
url: wss://op.yourdomain.com/_tunnel # Connect to VPS
|
|
89
|
+
|
|
90
|
+
tunnels:
|
|
91
|
+
- name: web
|
|
92
|
+
protocol: http
|
|
93
|
+
port: 3000
|
|
94
|
+
subdomain: web
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# On the VPS
|
|
99
|
+
opentunnel up
|
|
100
|
+
|
|
101
|
+
# On your local machine
|
|
102
|
+
opentunnel up
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Result: `https://web.op.yourdomain.com` -> `localhost:3000`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### 2. At Home (Domestic Use)
|
|
110
|
+
|
|
111
|
+
Run the server on your own local network. Requires router configuration.
|
|
112
|
+
|
|
113
|
+
**Requirements:**
|
|
114
|
+
- Domain pointing to your public IP (can be dynamic with DuckDNS)
|
|
115
|
+
- Configure port forwarding on your router
|
|
116
|
+
|
|
117
|
+
**DNS Configuration:**
|
|
118
|
+
```
|
|
119
|
+
Type Name Content/Value Proxy status (Cloudflare only)
|
|
120
|
+
A *.op <YOUR_PUBLIC_IP> DNS only
|
|
121
|
+
A op <YOUR_PUBLIC_IP> DNS only
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If you have a dynamic IP, use DuckDNS:
|
|
125
|
+
```
|
|
126
|
+
Type Name Content/Value
|
|
127
|
+
A *.op yoursubdomain.duckdns.org (auto-updated)
|
|
128
|
+
A op yoursubdomain.duckdns.org (auto-updated)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Router Configuration (Port Forwarding):**
|
|
132
|
+
|
|
133
|
+
| Name | Protocol | WAN Port | LAN Port | LAN IP |
|
|
134
|
+
|------|----------|----------|----------|--------|
|
|
135
|
+
| OpenTunnel HTTPS | TCP | 443 | 443 | 192.168.1.X |
|
|
136
|
+
| OpenTunnel TCP | TCP | 10000-20000 | 10000-20000 | 192.168.1.X |
|
|
137
|
+
|
|
138
|
+
> Replace `192.168.1.X` with your machine's local IP address.
|
|
139
|
+
|
|
140
|
+
**opentunnel.yml:**
|
|
141
|
+
```yaml
|
|
142
|
+
version: "1.0"
|
|
143
|
+
|
|
144
|
+
server:
|
|
145
|
+
port: 443
|
|
146
|
+
domain: yourdomain.com # or yoursubdomain.duckdns.org
|
|
147
|
+
basePath: op
|
|
148
|
+
|
|
149
|
+
tunnels:
|
|
150
|
+
- name: web
|
|
151
|
+
protocol: http
|
|
152
|
+
port: 3000
|
|
153
|
+
subdomain: web
|
|
154
|
+
autostart: true
|
|
155
|
+
|
|
156
|
+
- name: api
|
|
157
|
+
protocol: http
|
|
158
|
+
port: 4000
|
|
159
|
+
subdomain: api
|
|
160
|
+
autostart: true
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
opentunnel up
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Result:
|
|
168
|
+
- `https://web.op.yourdomain.com` -> `localhost:3000`
|
|
169
|
+
- `https://api.op.yourdomain.com` -> `localhost:4000`
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Full Configuration
|
|
174
|
+
|
|
175
|
+
**opentunnel.yml:**
|
|
176
|
+
```yaml
|
|
177
|
+
version: "1.0"
|
|
178
|
+
|
|
179
|
+
server:
|
|
180
|
+
port: 443 # Server port (default: 443)
|
|
181
|
+
domain: yourdomain.com # Base domain
|
|
182
|
+
basePath: op # Subdomain prefix (default: op)
|
|
183
|
+
https: true # Enable HTTPS (default: true)
|
|
184
|
+
tcpPortMin: 10000 # Minimum TCP port (default: 10000)
|
|
185
|
+
tcpPortMax: 20000 # Maximum TCP port (default: 20000)
|
|
186
|
+
token: secret # Authentication token (optional)
|
|
187
|
+
|
|
188
|
+
# To connect to a remote server:
|
|
189
|
+
# url: wss://server.com/_tunnel
|
|
190
|
+
|
|
191
|
+
tunnels:
|
|
192
|
+
# HTTP Tunnel
|
|
193
|
+
- name: web
|
|
194
|
+
protocol: http
|
|
195
|
+
port: 3000
|
|
196
|
+
subdomain: web
|
|
197
|
+
host: localhost # (default: localhost)
|
|
198
|
+
autostart: true # (default: true)
|
|
199
|
+
|
|
200
|
+
# TCP Tunnel (databases, etc.)
|
|
201
|
+
- name: postgres
|
|
202
|
+
protocol: tcp
|
|
203
|
+
port: 5432
|
|
204
|
+
remotePort: 15432 # Public TCP port
|
|
205
|
+
autostart: false
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Additional Commands
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Quick HTTP tunnel (without yml file)
|
|
214
|
+
opentunnel http 3000 --subdomain web --domain yourdomain.com
|
|
215
|
+
|
|
216
|
+
# TCP tunnel
|
|
217
|
+
opentunnel tcp 5432 --remote-port 15432 --domain yourdomain.com
|
|
218
|
+
|
|
219
|
+
# Start in background
|
|
220
|
+
opentunnel up -d
|
|
221
|
+
|
|
222
|
+
# View status
|
|
223
|
+
opentunnel ps
|
|
224
|
+
|
|
225
|
+
# Stop everything
|
|
226
|
+
opentunnel down
|
|
227
|
+
|
|
228
|
+
# Initialize configuration file
|
|
229
|
+
opentunnel init
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Architecture
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
INTERNET
|
|
238
|
+
|
|
|
239
|
+
v
|
|
240
|
+
+--------------------------------------------------+
|
|
241
|
+
| ROUTER |
|
|
242
|
+
| Port Forward: 443 -> 192.168.1.X:443 |
|
|
243
|
+
+--------------------------------------------------+
|
|
244
|
+
|
|
|
245
|
+
v
|
|
246
|
+
+--------------------------------------------------+
|
|
247
|
+
| YOUR MACHINE (192.168.1.X) |
|
|
248
|
+
| |
|
|
249
|
+
| +-------------------------------------------+ |
|
|
250
|
+
| | OpenTunnel Server | |
|
|
251
|
+
| | (port 443) | |
|
|
252
|
+
| +-------------------------------------------+ |
|
|
253
|
+
| | | |
|
|
254
|
+
| v v |
|
|
255
|
+
| +------------+ +------------+ |
|
|
256
|
+
| | Web App | | API | |
|
|
257
|
+
| | :3000 | | :4000 | |
|
|
258
|
+
| +------------+ +------------+ |
|
|
259
|
+
+--------------------------------------------------+
|
|
260
|
+
|
|
261
|
+
Access from internet:
|
|
262
|
+
https://web.op.yourdomain.com -> localhost:3000
|
|
263
|
+
https://api.op.yourdomain.com -> localhost:4000
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## SSL Certificates
|
|
269
|
+
|
|
270
|
+
OpenTunnel generates SSL certificates automatically:
|
|
271
|
+
|
|
272
|
+
- **Self-signed** (default): Works but browser shows warning
|
|
273
|
+
- **Let's Encrypt**: Valid certificates (requires port 80)
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Use Let's Encrypt
|
|
277
|
+
opentunnel server --letsencrypt --email your@email.com
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## License
|
|
283
|
+
|
|
284
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|