opentunnel-cli 1.0.6 → 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 op.example.com
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 op.example.com
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 op.example.com # Basic HTTP tunnel
52
- opentunnel quick 3000 -s op.example.com -n myapp # Custom subdomain
53
- opentunnel quick 5432 -s op.example.com -p tcp # TCP tunnel
54
- opentunnel quick 3000 -s op.example.com -t SECRET # With auth token
55
- opentunnel quick 3000 -s op.example.com --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 op.example.com
66
+ opentunnel http 3000 -s example.com
65
67
 
66
68
  # With authentication
67
- opentunnel http 3000 --server op.example.com --token SECRET
69
+ opentunnel http 3000 -s example.com -t SECRET
68
70
 
69
71
  # TCP tunnel
70
- opentunnel tcp 5432 --server op.example.com --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 -d --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 -d --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 -d --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=example.com # Solo el dominio base (sin el prefijo op)
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
 
@@ -199,9 +228,10 @@ Required:
199
228
 
200
229
  Optional:
201
230
  -p, --port <port> Server port (default: 443)
202
- -b, --base-path <path> Subdomain prefix (default: op)
231
+ -b, --base-path <path> Subdomain prefix (default: op, empty for direct)
203
232
  --tcp-min <port> Min TCP tunnel port (default: 10000)
204
233
  --tcp-max <port> Max TCP tunnel port (default: 20000)
234
+ -d, --detach Run in background
205
235
 
206
236
  Authentication:
207
237
  --auth-tokens <tokens> Comma-separated tokens for private server
@@ -212,9 +242,6 @@ SSL/TLS:
212
242
  --email <email> Email for Let's Encrypt
213
243
  --production Use Let's Encrypt production (not staging)
214
244
  --cloudflare-token <token> Cloudflare API token for DNS-01 challenge
215
-
216
- Other:
217
- -d, --detach Run in background
218
245
  ```
219
246
 
220
247
  ## Server Modes
@@ -224,12 +251,12 @@ Other:
224
251
  Anyone can connect without authentication:
225
252
 
226
253
  ```bash
227
- opentunnel server --domain example.com --letsencrypt --email admin@example.com
254
+ opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
228
255
  ```
229
256
 
230
257
  Clients connect with:
231
258
  ```bash
232
- opentunnel quick 3000 -s op.example.com
259
+ opentunnel quick 3000 -s example.com
233
260
  ```
234
261
 
235
262
  ### Private Server
@@ -237,12 +264,12 @@ opentunnel quick 3000 -s op.example.com
237
264
  Only clients with valid tokens can connect:
238
265
 
239
266
  ```bash
240
- opentunnel server --domain 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"
241
268
  ```
242
269
 
243
270
  Clients must provide a token:
244
271
  ```bash
245
- opentunnel quick 3000 -s op.example.com --token token1
272
+ opentunnel quick 3000 -s example.com -t token1
246
273
  ```
247
274
 
248
275
  ---
@@ -255,10 +282,17 @@ OpenTunnel uses a **shared secret** system for authentication. The server define
255
282
 
256
283
  ```bash
257
284
  # Single token
258
- opentunnel server --domain example.com --auth-tokens "my-secret-token"
285
+ opentunnel server -d --domain example.com --auth-tokens "my-secret-token"
259
286
 
260
287
  # Multiple tokens (one per user/team)
261
- 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
262
296
  ```
263
297
 
264
298
  Or in `.env`:
@@ -270,11 +304,11 @@ AUTH_TOKENS=team-a-token,team-b-token,dev-token
270
304
 
271
305
  ```bash
272
306
  # Command line
273
- opentunnel quick 3000 --token my-secret-token
307
+ opentunnel quick 3000 -s example.com -t my-secret-token
274
308
 
275
309
  # Or in opentunnel.yml
276
310
  server:
277
- remote: op.example.com
311
+ remote: example.com
278
312
  token: my-secret-token
279
313
  ```
280
314
 
@@ -289,7 +323,40 @@ server:
289
323
 
290
324
  # 📄 Configuration File
291
325
 
292
- 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
+ ```
293
360
 
294
361
  ## Client Mode (connect to remote server)
295
362
 
@@ -297,26 +364,27 @@ Create `opentunnel.yml` in your project directory:
297
364
  version: "1.0"
298
365
 
299
366
  server:
300
- remote: op.example.com # Server hostname
301
- 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
302
370
 
303
371
  tunnels:
304
372
  - name: frontend
305
373
  protocol: http
306
374
  port: 3000
307
- subdomain: app # → app.op.example.com
375
+ subdomain: app # → app.op.example.com
308
376
  autostart: true
309
377
 
310
378
  - name: backend
311
379
  protocol: http
312
380
  port: 4000
313
- subdomain: api # → api.op.example.com
381
+ subdomain: api # → api.op.example.com
314
382
 
315
383
  - name: database
316
384
  protocol: tcp
317
385
  port: 5432
318
- remotePort: 15432 # → op.example.com:15432
319
- autostart: false # Start manually with: opentunnel tunnel database
386
+ remotePort: 15432 # → example.com:15432
387
+ autostart: false
320
388
  ```
321
389
 
322
390
  ## Server Mode (run your own server)
@@ -325,15 +393,10 @@ tunnels:
325
393
  version: "1.0"
326
394
 
327
395
  server:
328
- domain: example.com # Solo el dominio base
329
- basePath: op # Prefijo *.op.example.com
330
- port: 443
331
- https: true
332
- tcpPortMin: 10000
333
- tcpPortMax: 20000
334
- # token: optional-auth-token # Uncomment for private server
396
+ domain: ${DOMAIN:-example.com} # Base domain only
397
+ token: ${AUTH_TOKEN} # Optional: for private server
335
398
 
336
- tunnels: [] # Server-only, no local tunnels
399
+ tunnels: []
337
400
  ```
338
401
 
339
402
  ## Commands
@@ -343,6 +406,7 @@ opentunnel init # Create example config file
343
406
  opentunnel up # Start server/tunnels from config
344
407
  opentunnel up -d # Start in background
345
408
  opentunnel down # Stop everything
409
+ opentunnel stop # Stop server
346
410
  opentunnel ps # Show running processes
347
411
  ```
348
412
 
@@ -352,32 +416,31 @@ opentunnel ps # Show running processes
352
416
 
353
417
  | Command | Description |
354
418
  |---------|-------------|
355
- | `opentunnel quick <port> -s <server>` | Quick tunnel to a server |
419
+ | `opentunnel quick <port> -s <domain>` | Quick tunnel to a server |
356
420
  | `opentunnel http <port>` | HTTP tunnel with options |
357
421
  | `opentunnel tcp <port>` | TCP tunnel with options |
358
- | `opentunnel server` | Start tunnel server |
422
+ | `opentunnel server -d` | Start tunnel server in background |
359
423
  | `opentunnel up` | Start from opentunnel.yml |
360
424
  | `opentunnel down` | Stop all tunnels |
425
+ | `opentunnel stop` | Stop server |
361
426
  | `opentunnel ps` | List running processes |
362
427
  | `opentunnel init` | Create config file |
363
- | `opentunnel setup` | Show setup guide |
364
- | `opentunnel logs` | View server logs |
365
- | `opentunnel status` | Check server status |
366
428
 
367
429
  ## Quick Command
368
430
 
369
431
  ```bash
370
- opentunnel quick <port> -s <server-url> [options]
432
+ opentunnel quick <port> -s <domain> [options]
371
433
 
372
434
  Required:
373
- -s, --server <host> Server hostname (e.g., op.example.com)
435
+ -s, --server <domain> Server base domain (e.g., example.com)
374
436
 
375
437
  Options:
376
- -n, --subdomain <name> Request specific subdomain
377
- -p, --protocol <proto> http, https, or tcp (default: http)
378
- -h, --host <host> Local host (default: localhost)
379
- -t, --token <token> Authentication token
380
- --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)
381
444
  ```
382
445
 
383
446
  ## HTTP/TCP Commands
@@ -387,12 +450,13 @@ opentunnel http <port> [options]
387
450
  opentunnel tcp <port> [options]
388
451
 
389
452
  Options:
390
- -s, --server <host> Server hostname (e.g., op.example.com)
391
- -t, --token <token> Authentication token
392
- -n, --subdomain <name> Custom subdomain
393
- -h, --host <host> Local host (default: localhost)
394
- -r, --remote-port <port> Remote TCP port (tcp only)
395
- -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
396
460
  ```
397
461
 
398
462
  ---
@@ -403,13 +467,13 @@ Options:
403
467
  ┌─────────────────────────────────────────────────────────────────┐
404
468
  │ INTERNET │
405
469
  │ │
406
- │ Users access: https://myapp.op.example.com
470
+ │ Users access: https://myapp.op.example.com
407
471
  └──────────────────────────────┬──────────────────────────────────┘
408
472
 
409
473
 
410
474
  ┌─────────────────────────────────────────────────────────────────┐
411
475
  │ OpenTunnel Server │
412
- (op.example.com)
476
+ (op.example.com)
413
477
  │ │
414
478
  │ - Receives HTTPS requests │
415
479
  │ - Routes by subdomain │
@@ -443,8 +507,8 @@ Options:
443
507
 
444
508
  [Proprietary License](LICENSE) - All rights reserved.
445
509
 
446
- - ✅ Personal and educational use allowed
510
+ - ✅ Personal, educational, and commercial use allowed
447
511
  - ❌ No forks or redistribution without permission
448
- - ❌ No commercial use without explicit consent
512
+ - ❌ No reselling or monetization without explicit consent
449
513
 
450
- Contact FJRG2007 for commercial licensing.
514
+ Contact FJRG2007 for licensing questions.