opentunnel-cli 1.0.6 → 1.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/README.md +130 -84
- package/dist/cli/index.js +255 -152
- package/dist/cli/index.js.map +1 -1
- package/dist/client/TunnelClient.d.ts +1 -0
- package/dist/client/TunnelClient.d.ts.map +1 -1
- package/dist/client/TunnelClient.js +129 -10
- package/dist/client/TunnelClient.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- [As a Server](#-as-a-server) - Host your own tunnel server
|
|
11
11
|
- [Authentication](#-authentication) - Secure your server
|
|
12
12
|
- [Configuration File](#-configuration-file) - opentunnel.yml reference
|
|
13
|
+
- [Environment Variables](#environment-variables) - Docker-style ${VAR:-default} syntax
|
|
13
14
|
- [Commands Reference](#-commands-reference)
|
|
14
15
|
|
|
15
16
|
---
|
|
@@ -25,7 +26,7 @@ Use OpenTunnel to expose your local services to the internet. Connect to any Ope
|
|
|
25
26
|
npm install -g opentunnel-cli
|
|
26
27
|
|
|
27
28
|
# Or use without installing
|
|
28
|
-
npx opentunnel-cli quick 3000 -s
|
|
29
|
+
npx opentunnel-cli quick 3000 -s example.com
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
## Quick Start
|
|
@@ -35,7 +36,7 @@ npx opentunnel-cli quick 3000 -s op.example.com
|
|
|
35
36
|
The fastest way to expose a port:
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
|
-
opentunnel quick 3000 -s
|
|
39
|
+
opentunnel quick 3000 -s example.com
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
Your local port 3000 is now accessible from the internet:
|
|
@@ -48,11 +49,12 @@ Your local port 3000 is now accessible from the internet:
|
|
|
48
49
|
|
|
49
50
|
**Options:**
|
|
50
51
|
```bash
|
|
51
|
-
opentunnel quick 3000 -s
|
|
52
|
-
opentunnel quick 3000 -s
|
|
53
|
-
opentunnel quick 5432 -s
|
|
54
|
-
opentunnel quick 3000 -s
|
|
55
|
-
opentunnel quick 3000 -s
|
|
52
|
+
opentunnel quick 3000 -s example.com # Basic HTTP tunnel
|
|
53
|
+
opentunnel quick 3000 -s example.com -n myapp # Custom subdomain
|
|
54
|
+
opentunnel quick 5432 -s example.com -p tcp # TCP tunnel
|
|
55
|
+
opentunnel quick 3000 -s example.com -t SECRET # With auth token
|
|
56
|
+
opentunnel quick 3000 -s example.com --insecure # Self-signed cert
|
|
57
|
+
opentunnel quick 3000 -s example.com -b "" # No basePath (direct domain)
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
### Option 2: HTTP/TCP Commands
|
|
@@ -61,13 +63,13 @@ More control with specific commands:
|
|
|
61
63
|
|
|
62
64
|
```bash
|
|
63
65
|
# HTTP tunnel
|
|
64
|
-
opentunnel http 3000
|
|
66
|
+
opentunnel http 3000 -s example.com
|
|
65
67
|
|
|
66
68
|
# With authentication
|
|
67
|
-
opentunnel http 3000
|
|
69
|
+
opentunnel http 3000 -s example.com -t SECRET
|
|
68
70
|
|
|
69
71
|
# TCP tunnel
|
|
70
|
-
opentunnel tcp 5432
|
|
72
|
+
opentunnel tcp 5432 -s example.com -r 15432
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
### Option 3: Using Config File
|
|
@@ -75,33 +77,32 @@ opentunnel tcp 5432 --server op.example.com --remote-port 15432
|
|
|
75
77
|
Create `opentunnel.yml`:
|
|
76
78
|
|
|
77
79
|
```yaml
|
|
78
|
-
version: "1.0"
|
|
79
|
-
|
|
80
80
|
server:
|
|
81
|
-
remote:
|
|
82
|
-
token:
|
|
81
|
+
remote: example.com # Base domain (system adds basePath)
|
|
82
|
+
token: ${AUTH_TOKEN} # From .env file (optional)
|
|
83
83
|
|
|
84
84
|
tunnels:
|
|
85
85
|
- name: web
|
|
86
86
|
protocol: http
|
|
87
87
|
port: 3000
|
|
88
|
-
subdomain: myapp
|
|
88
|
+
subdomain: myapp # → myapp.op.example.com
|
|
89
89
|
|
|
90
90
|
- name: api
|
|
91
91
|
protocol: http
|
|
92
92
|
port: 4000
|
|
93
|
-
subdomain: api
|
|
93
|
+
subdomain: api # → api.op.example.com
|
|
94
94
|
|
|
95
95
|
- name: postgres
|
|
96
96
|
protocol: tcp
|
|
97
97
|
port: 5432
|
|
98
|
-
remotePort: 15432
|
|
98
|
+
remotePort: 15432 # → example.com:15432
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
|
-
opentunnel up
|
|
103
|
-
opentunnel
|
|
104
|
-
opentunnel
|
|
102
|
+
opentunnel up # Start all tunnels
|
|
103
|
+
opentunnel up -d # Start in background
|
|
104
|
+
opentunnel down # Stop all tunnels
|
|
105
|
+
opentunnel ps # Check status
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
---
|
|
@@ -122,7 +123,7 @@ Create these DNS records pointing to your server:
|
|
|
122
123
|
|
|
123
124
|
| Type | Name | Value | Notes |
|
|
124
125
|
|------|------|-------|-------|
|
|
125
|
-
| A | `op` | `YOUR_SERVER_IP` | Main server |
|
|
126
|
+
| A | `op` | `YOUR_SERVER_IP` | Main server (or your basePath) |
|
|
126
127
|
| A | `*.op` | `YOUR_SERVER_IP` | Wildcard for subdomains |
|
|
127
128
|
|
|
128
129
|
> **Cloudflare users:** Set proxy status to "DNS only" (gray cloud)
|
|
@@ -142,17 +143,33 @@ Tunnels will be available at: `https://myapp.op.example.com`
|
|
|
142
143
|
npm install -g opentunnel-cli
|
|
143
144
|
|
|
144
145
|
# Start public server (anyone can connect)
|
|
145
|
-
|
|
146
|
+
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
|
|
146
147
|
|
|
147
148
|
# Start private server (requires token to connect)
|
|
148
|
-
|
|
149
|
+
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "SECRET123"
|
|
150
|
+
|
|
151
|
+
# Stop server
|
|
152
|
+
opentunnel stop
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Option 2: Using Config File
|
|
149
156
|
|
|
150
|
-
|
|
157
|
+
Create `opentunnel.yml`:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
server:
|
|
161
|
+
domain: example.com # Base domain only
|
|
162
|
+
# token: SECRET123 # Uncomment for private server
|
|
163
|
+
# tcpPortMin: 10000 # TCP tunnel port range (optional)
|
|
164
|
+
# tcpPortMax: 20000
|
|
165
|
+
```
|
|
151
166
|
|
|
152
|
-
|
|
167
|
+
```bash
|
|
168
|
+
opentunnel server -d # Start in background (reads from opentunnel.yml)
|
|
169
|
+
opentunnel stop # Stop server
|
|
153
170
|
```
|
|
154
171
|
|
|
155
|
-
### Option
|
|
172
|
+
### Option 3: Docker (Recommended for Production)
|
|
156
173
|
|
|
157
174
|
```bash
|
|
158
175
|
git clone https://github.com/FJRG2007/opentunnel.git
|
|
@@ -165,7 +182,7 @@ nano .env
|
|
|
165
182
|
|
|
166
183
|
Edit `.env`:
|
|
167
184
|
```env
|
|
168
|
-
DOMAIN=example.com #
|
|
185
|
+
DOMAIN=example.com # Base domain only (without the op prefix)
|
|
169
186
|
AUTH_TOKENS=SECRET123 # Leave empty for public server
|
|
170
187
|
LETSENCRYPT_EMAIL=admin@example.com
|
|
171
188
|
LETSENCRYPT_PRODUCTION=true
|
|
@@ -173,9 +190,10 @@ LETSENCRYPT_PRODUCTION=true
|
|
|
173
190
|
|
|
174
191
|
```bash
|
|
175
192
|
docker-compose up -d
|
|
193
|
+
docker-compose down # Stop server
|
|
176
194
|
```
|
|
177
195
|
|
|
178
|
-
### Option
|
|
196
|
+
### Option 4: One-Line Install (Linux with systemd)
|
|
179
197
|
|
|
180
198
|
```bash
|
|
181
199
|
curl -fsSL https://raw.githubusercontent.com/FJRG2007/opentunnel/main/deploy/install.sh | sudo bash
|
|
@@ -185,6 +203,7 @@ Then configure:
|
|
|
185
203
|
```bash
|
|
186
204
|
sudo nano /opt/opentunnel/.env
|
|
187
205
|
sudo systemctl start opentunnel
|
|
206
|
+
sudo systemctl stop opentunnel
|
|
188
207
|
sudo systemctl status opentunnel
|
|
189
208
|
```
|
|
190
209
|
|
|
@@ -199,9 +218,10 @@ Required:
|
|
|
199
218
|
|
|
200
219
|
Optional:
|
|
201
220
|
-p, --port <port> Server port (default: 443)
|
|
202
|
-
-b, --base-path <path> Subdomain prefix (default: op)
|
|
221
|
+
-b, --base-path <path> Subdomain prefix (default: op, empty for direct)
|
|
203
222
|
--tcp-min <port> Min TCP tunnel port (default: 10000)
|
|
204
223
|
--tcp-max <port> Max TCP tunnel port (default: 20000)
|
|
224
|
+
-d, --detach Run in background
|
|
205
225
|
|
|
206
226
|
Authentication:
|
|
207
227
|
--auth-tokens <tokens> Comma-separated tokens for private server
|
|
@@ -212,9 +232,6 @@ SSL/TLS:
|
|
|
212
232
|
--email <email> Email for Let's Encrypt
|
|
213
233
|
--production Use Let's Encrypt production (not staging)
|
|
214
234
|
--cloudflare-token <token> Cloudflare API token for DNS-01 challenge
|
|
215
|
-
|
|
216
|
-
Other:
|
|
217
|
-
-d, --detach Run in background
|
|
218
235
|
```
|
|
219
236
|
|
|
220
237
|
## Server Modes
|
|
@@ -224,12 +241,12 @@ Other:
|
|
|
224
241
|
Anyone can connect without authentication:
|
|
225
242
|
|
|
226
243
|
```bash
|
|
227
|
-
opentunnel server --domain example.com --letsencrypt --email admin@example.com
|
|
244
|
+
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
|
|
228
245
|
```
|
|
229
246
|
|
|
230
247
|
Clients connect with:
|
|
231
248
|
```bash
|
|
232
|
-
opentunnel quick 3000 -s
|
|
249
|
+
opentunnel quick 3000 -s example.com
|
|
233
250
|
```
|
|
234
251
|
|
|
235
252
|
### Private Server
|
|
@@ -237,12 +254,12 @@ opentunnel quick 3000 -s op.example.com
|
|
|
237
254
|
Only clients with valid tokens can connect:
|
|
238
255
|
|
|
239
256
|
```bash
|
|
240
|
-
opentunnel server --domain example.com --letsencrypt --email admin@example.com --auth-tokens "token1,token2
|
|
257
|
+
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "token1,token2"
|
|
241
258
|
```
|
|
242
259
|
|
|
243
260
|
Clients must provide a token:
|
|
244
261
|
```bash
|
|
245
|
-
opentunnel quick 3000 -s
|
|
262
|
+
opentunnel quick 3000 -s example.com -t token1
|
|
246
263
|
```
|
|
247
264
|
|
|
248
265
|
---
|
|
@@ -255,10 +272,17 @@ OpenTunnel uses a **shared secret** system for authentication. The server define
|
|
|
255
272
|
|
|
256
273
|
```bash
|
|
257
274
|
# Single token
|
|
258
|
-
opentunnel server --domain example.com --auth-tokens "my-secret-token"
|
|
275
|
+
opentunnel server -d --domain example.com --auth-tokens "my-secret-token"
|
|
259
276
|
|
|
260
277
|
# Multiple tokens (one per user/team)
|
|
261
|
-
opentunnel server --domain example.com --auth-tokens "team-a-token,team-b-token,dev-token"
|
|
278
|
+
opentunnel server -d --domain example.com --auth-tokens "team-a-token,team-b-token,dev-token"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Or in `opentunnel.yml`:
|
|
282
|
+
```yaml
|
|
283
|
+
server:
|
|
284
|
+
domain: example.com
|
|
285
|
+
token: my-secret-token
|
|
262
286
|
```
|
|
263
287
|
|
|
264
288
|
Or in `.env`:
|
|
@@ -270,11 +294,11 @@ AUTH_TOKENS=team-a-token,team-b-token,dev-token
|
|
|
270
294
|
|
|
271
295
|
```bash
|
|
272
296
|
# Command line
|
|
273
|
-
opentunnel quick 3000
|
|
297
|
+
opentunnel quick 3000 -s example.com -t my-secret-token
|
|
274
298
|
|
|
275
299
|
# Or in opentunnel.yml
|
|
276
300
|
server:
|
|
277
|
-
remote:
|
|
301
|
+
remote: example.com
|
|
278
302
|
token: my-secret-token
|
|
279
303
|
```
|
|
280
304
|
|
|
@@ -289,51 +313,72 @@ server:
|
|
|
289
313
|
|
|
290
314
|
# 📄 Configuration File
|
|
291
315
|
|
|
292
|
-
Create `opentunnel.yml` in your project directory
|
|
316
|
+
Create `opentunnel.yml` in your project directory.
|
|
293
317
|
|
|
294
|
-
##
|
|
318
|
+
## Environment Variables
|
|
319
|
+
|
|
320
|
+
OpenTunnel supports **Docker-style environment variable substitution** in config files. Variables are loaded from `.env` file automatically.
|
|
321
|
+
|
|
322
|
+
| Syntax | Description |
|
|
323
|
+
|--------|-------------|
|
|
324
|
+
| `${VAR}` | Use value of VAR |
|
|
325
|
+
| `${VAR:-default}` | Use VAR if set, otherwise use "default" |
|
|
326
|
+
| `${VAR:=default}` | Same as above (alternative syntax) |
|
|
327
|
+
|
|
328
|
+
**Example with `.env` file:**
|
|
329
|
+
|
|
330
|
+
```env
|
|
331
|
+
# .env
|
|
332
|
+
AUTH_TOKEN=my-secret-token
|
|
333
|
+
SERVER_DOMAIN=example.com
|
|
334
|
+
```
|
|
295
335
|
|
|
296
336
|
```yaml
|
|
297
|
-
|
|
337
|
+
# opentunnel.yml
|
|
338
|
+
server:
|
|
339
|
+
remote: ${SERVER_DOMAIN:-localhost} # Uses example.com from .env
|
|
340
|
+
token: ${AUTH_TOKEN} # Uses my-secret-token from .env
|
|
298
341
|
|
|
342
|
+
tunnels:
|
|
343
|
+
- name: web
|
|
344
|
+
protocol: http
|
|
345
|
+
port: 3000
|
|
346
|
+
subdomain: app
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Client Mode (connect to remote server)
|
|
350
|
+
|
|
351
|
+
```yaml
|
|
299
352
|
server:
|
|
300
|
-
remote:
|
|
301
|
-
token:
|
|
353
|
+
remote: ${SERVER_DOMAIN:-example.com} # Base domain (system adds basePath)
|
|
354
|
+
token: ${AUTH_TOKEN} # From .env (optional)
|
|
302
355
|
|
|
303
356
|
tunnels:
|
|
304
357
|
- name: frontend
|
|
305
358
|
protocol: http
|
|
306
359
|
port: 3000
|
|
307
|
-
subdomain: app
|
|
308
|
-
autostart: true
|
|
360
|
+
subdomain: app # → app.op.example.com
|
|
309
361
|
|
|
310
362
|
- name: backend
|
|
311
363
|
protocol: http
|
|
312
364
|
port: 4000
|
|
313
|
-
subdomain: api
|
|
365
|
+
subdomain: api # → api.op.example.com
|
|
314
366
|
|
|
315
367
|
- name: database
|
|
316
368
|
protocol: tcp
|
|
317
369
|
port: 5432
|
|
318
|
-
remotePort: 15432
|
|
319
|
-
autostart: false
|
|
370
|
+
remotePort: 15432 # → example.com:15432
|
|
371
|
+
autostart: false # Don't start automatically
|
|
320
372
|
```
|
|
321
373
|
|
|
322
374
|
## Server Mode (run your own server)
|
|
323
375
|
|
|
324
376
|
```yaml
|
|
325
|
-
version: "1.0"
|
|
326
|
-
|
|
327
377
|
server:
|
|
328
|
-
domain: example.com
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
tcpPortMin: 10000
|
|
333
|
-
tcpPortMax: 20000
|
|
334
|
-
# token: optional-auth-token # Uncomment for private server
|
|
335
|
-
|
|
336
|
-
tunnels: [] # Server-only, no local tunnels
|
|
378
|
+
domain: ${DOMAIN:-example.com} # Base domain only
|
|
379
|
+
token: ${AUTH_TOKEN} # Optional: for private server
|
|
380
|
+
# tcpPortMin: 10000 # TCP tunnel port range (optional)
|
|
381
|
+
# tcpPortMax: 20000
|
|
337
382
|
```
|
|
338
383
|
|
|
339
384
|
## Commands
|
|
@@ -343,6 +388,7 @@ opentunnel init # Create example config file
|
|
|
343
388
|
opentunnel up # Start server/tunnels from config
|
|
344
389
|
opentunnel up -d # Start in background
|
|
345
390
|
opentunnel down # Stop everything
|
|
391
|
+
opentunnel stop # Stop server
|
|
346
392
|
opentunnel ps # Show running processes
|
|
347
393
|
```
|
|
348
394
|
|
|
@@ -352,32 +398,31 @@ opentunnel ps # Show running processes
|
|
|
352
398
|
|
|
353
399
|
| Command | Description |
|
|
354
400
|
|---------|-------------|
|
|
355
|
-
| `opentunnel quick <port> -s <
|
|
401
|
+
| `opentunnel quick <port> -s <domain>` | Quick tunnel to a server |
|
|
356
402
|
| `opentunnel http <port>` | HTTP tunnel with options |
|
|
357
403
|
| `opentunnel tcp <port>` | TCP tunnel with options |
|
|
358
|
-
| `opentunnel server` | Start tunnel server |
|
|
404
|
+
| `opentunnel server -d` | Start tunnel server in background |
|
|
359
405
|
| `opentunnel up` | Start from opentunnel.yml |
|
|
360
406
|
| `opentunnel down` | Stop all tunnels |
|
|
407
|
+
| `opentunnel stop` | Stop server |
|
|
361
408
|
| `opentunnel ps` | List running processes |
|
|
362
409
|
| `opentunnel init` | Create config file |
|
|
363
|
-
| `opentunnel setup` | Show setup guide |
|
|
364
|
-
| `opentunnel logs` | View server logs |
|
|
365
|
-
| `opentunnel status` | Check server status |
|
|
366
410
|
|
|
367
411
|
## Quick Command
|
|
368
412
|
|
|
369
413
|
```bash
|
|
370
|
-
opentunnel quick <port> -s <
|
|
414
|
+
opentunnel quick <port> -s <domain> [options]
|
|
371
415
|
|
|
372
416
|
Required:
|
|
373
|
-
-s, --server <
|
|
417
|
+
-s, --server <domain> Server base domain (e.g., example.com)
|
|
374
418
|
|
|
375
419
|
Options:
|
|
376
|
-
-
|
|
377
|
-
-
|
|
378
|
-
-
|
|
379
|
-
-
|
|
380
|
-
--
|
|
420
|
+
-b, --base-path <path> Server base path (default: op, empty for direct)
|
|
421
|
+
-n, --subdomain <name> Request specific subdomain
|
|
422
|
+
-p, --protocol <proto> http, https, or tcp (default: http)
|
|
423
|
+
-h, --host <host> Local host (default: localhost)
|
|
424
|
+
-t, --token <token> Authentication token
|
|
425
|
+
--insecure Skip SSL verification (self-signed certs)
|
|
381
426
|
```
|
|
382
427
|
|
|
383
428
|
## HTTP/TCP Commands
|
|
@@ -387,12 +432,13 @@ opentunnel http <port> [options]
|
|
|
387
432
|
opentunnel tcp <port> [options]
|
|
388
433
|
|
|
389
434
|
Options:
|
|
390
|
-
-s, --server <
|
|
391
|
-
-
|
|
392
|
-
-
|
|
393
|
-
-
|
|
394
|
-
-
|
|
395
|
-
-
|
|
435
|
+
-s, --server <domain> Server base domain (e.g., example.com)
|
|
436
|
+
-b, --base-path <path> Server base path (default: op)
|
|
437
|
+
-t, --token <token> Authentication token
|
|
438
|
+
-n, --subdomain <name> Custom subdomain
|
|
439
|
+
-h, --host <host> Local host (default: localhost)
|
|
440
|
+
-r, --remote-port <port> Remote TCP port (tcp only)
|
|
441
|
+
-d, --detach Run in background
|
|
396
442
|
```
|
|
397
443
|
|
|
398
444
|
---
|
|
@@ -403,13 +449,13 @@ Options:
|
|
|
403
449
|
┌─────────────────────────────────────────────────────────────────┐
|
|
404
450
|
│ INTERNET │
|
|
405
451
|
│ │
|
|
406
|
-
│ Users access: https://myapp.op.example.com
|
|
452
|
+
│ Users access: https://myapp.op.example.com │
|
|
407
453
|
└──────────────────────────────┬──────────────────────────────────┘
|
|
408
454
|
│
|
|
409
455
|
▼
|
|
410
456
|
┌─────────────────────────────────────────────────────────────────┐
|
|
411
457
|
│ OpenTunnel Server │
|
|
412
|
-
│
|
|
458
|
+
│ (op.example.com) │
|
|
413
459
|
│ │
|
|
414
460
|
│ - Receives HTTPS requests │
|
|
415
461
|
│ - Routes by subdomain │
|
|
@@ -443,8 +489,8 @@ Options:
|
|
|
443
489
|
|
|
444
490
|
[Proprietary License](LICENSE) - All rights reserved.
|
|
445
491
|
|
|
446
|
-
- ✅ Personal and
|
|
492
|
+
- ✅ Personal, educational, and commercial use allowed
|
|
447
493
|
- ❌ No forks or redistribution without permission
|
|
448
|
-
- ❌ No
|
|
494
|
+
- ❌ No reselling or monetization without explicit consent
|
|
449
495
|
|
|
450
|
-
Contact FJRG2007 for
|
|
496
|
+
Contact FJRG2007 for licensing questions.
|