opentunnel-cli 1.0.5 → 1.0.7

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