opentunnel-cli 1.0.22 → 1.0.25

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.
Files changed (50) hide show
  1. package/README.md +69 -864
  2. package/dist/cli/index.js +712 -84
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/client/CloudflareTunnelClient.d.ts +110 -0
  5. package/dist/client/CloudflareTunnelClient.d.ts.map +1 -0
  6. package/dist/client/CloudflareTunnelClient.js +531 -0
  7. package/dist/client/CloudflareTunnelClient.js.map +1 -0
  8. package/dist/client/NgrokClient.d.ts +18 -1
  9. package/dist/client/NgrokClient.d.ts.map +1 -1
  10. package/dist/client/NgrokClient.js +130 -4
  11. package/dist/client/NgrokClient.js.map +1 -1
  12. package/dist/client/TunnelClient.d.ts +0 -1
  13. package/dist/client/TunnelClient.d.ts.map +1 -1
  14. package/dist/client/TunnelClient.js +2 -96
  15. package/dist/client/TunnelClient.js.map +1 -1
  16. package/dist/client/index.d.ts +1 -0
  17. package/dist/client/index.d.ts.map +1 -1
  18. package/dist/client/index.js +3 -1
  19. package/dist/client/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +3 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/index.d.ts +2 -0
  25. package/dist/lib/index.d.ts.map +1 -0
  26. package/dist/lib/index.js +18 -0
  27. package/dist/lib/index.js.map +1 -0
  28. package/dist/lib/pages/index.d.ts +2 -0
  29. package/dist/lib/pages/index.d.ts.map +1 -0
  30. package/dist/lib/pages/index.js +6 -0
  31. package/dist/lib/pages/index.js.map +1 -0
  32. package/dist/lib/pages/not-running.d.ts +10 -0
  33. package/dist/lib/pages/not-running.d.ts.map +1 -0
  34. package/dist/lib/pages/not-running.js +117 -0
  35. package/dist/lib/pages/not-running.js.map +1 -0
  36. package/dist/server/TunnelServer.d.ts +7 -3
  37. package/dist/server/TunnelServer.d.ts.map +1 -1
  38. package/dist/server/TunnelServer.js +164 -51
  39. package/dist/server/TunnelServer.js.map +1 -1
  40. package/dist/shared/credentials.d.ts +101 -0
  41. package/dist/shared/credentials.d.ts.map +1 -0
  42. package/dist/shared/credentials.js +302 -0
  43. package/dist/shared/credentials.js.map +1 -0
  44. package/dist/shared/ip-filter.d.ts +75 -0
  45. package/dist/shared/ip-filter.d.ts.map +1 -0
  46. package/dist/shared/ip-filter.js +203 -0
  47. package/dist/shared/ip-filter.js.map +1 -0
  48. package/dist/shared/types.d.ts +46 -0
  49. package/dist/shared/types.d.ts.map +1 -1
  50. package/package.json +7 -3
package/README.md CHANGED
@@ -1,946 +1,151 @@
1
1
  <h1 align="center">OpenTunnel</h1>
2
2
 
3
- <p align="center">Self-hosted alternative to ngrok. Expose local services to the internet with custom subdomains.</p>
3
+ <p align="center">Self-hosted alternative to ngrok. Expose local services to the internet with custom subdomains, or use ngrok/Cloudflare Tunnel.</p>
4
4
 
5
5
  ---
6
6
 
7
- ## Table of Contents
8
-
9
- - [As a Client](#-as-a-client) - Expose your local ports
10
- - [As a Server](#-as-a-server) - Host your own tunnel server
11
- - [Home Use](#-home-use-behind-routernat) - Run from home network
12
- - [Multi-Domain Support](#-multi-domain-support) - Handle multiple domains on one server
13
- - [Authentication](#-authentication) - Secure your server
14
- - [IP Access Control](#-ip-access-control) - Allow/deny IPs and CIDR ranges
15
- - [Configuration File](#-configuration-file) - opentunnel.yml reference
16
- - [Environment Variables](#environment-variables) - Docker-style ${VAR:-default} syntax
17
- - [Commands Reference](#-commands-reference)
18
- - [Expose Local (expl)](#expose-local-command-expl) - Fastest way to expose a port
19
- - [Domain Configuration](#domain-configuration) - Set default domain
20
-
21
- ---
22
-
23
- # 📱 As a Client
24
-
25
- Use OpenTunnel to expose your local services to the internet. Connect to any OpenTunnel server (your own or one shared with you).
26
-
27
- ## Installation
28
-
29
- ```bash
30
- # NPM (recommended)
31
- npm cache clean --force && npm install -g opentunnel-cli
32
-
33
- # Or use without installing
34
- npx opentunnel-cli quick 3000 -s example.com
35
- ```
36
-
37
7
  ## Quick Start
38
8
 
39
- ### Option 1: Expose Local (Recommended for Home Use)
40
-
41
- The fastest way to expose a port with your own domain:
9
+ ### Installation
42
10
 
43
11
  ```bash
44
- # First, set your default domain (one time only)
45
- opentunnel setdomain yourdomain.com
46
-
47
- # Then expose any port with a single command
48
- opentunnel expl 3000
12
+ npm install -g opentunnel-cli
49
13
  ```
50
14
 
51
- This starts a local server and exposes your port. Requires your domain to point to your machine (with port forwarding if behind NAT).
52
- [Check this](#-home-use-behind-routernat) - Run from home network
53
-
54
- ### Option 2: Quick Command
15
+ ### As a Client
55
16
 
56
17
  Connect to an existing OpenTunnel server:
57
18
 
58
19
  ```bash
59
- # Connect to a remote OpenTunnel server
20
+ # Quick tunnel
60
21
  opentunnel quick 3000 -s example.com
61
22
 
62
- # Or start your own local server
63
- opentunnel quick 3000 -s yourdomain.com --local-server
64
- ```
65
-
66
- Your local port 3000 is now accessible from the internet:
67
-
68
- ```
69
- Status: ● Online
70
- Local: localhost:3000
71
- Public: https://myapp.op.example.com
72
- ```
73
-
74
- **Options:**
75
- ```bash
76
- opentunnel quick 3000 -s example.com # Basic HTTP tunnel
77
- opentunnel quick 3000 --domain example.com -n myapp # Custom subdomain
78
- opentunnel quick 5432 -s example.com -p tcp # TCP tunnel
79
- opentunnel quick 3000 -s example.com -t SECRET # With auth token
80
- opentunnel quick 3000 -s example.com --insecure # Self-signed cert
81
- opentunnel quick 3000 -s example.com -b "" # No basePath (direct domain)
82
- opentunnel quick 3000 -s yourdomain.com --local-server # Start server + tunnel in one terminal
83
- #
84
- ```
85
-
86
- ### Option 3: HTTP/TCP Commands
87
-
88
- More control with specific commands:
89
-
90
- ```bash
91
- # HTTP tunnel
92
- opentunnel http 3000 -s example.com
93
- opentunnel http 3000 --domain example.com --subdomain myapp
94
-
95
23
  # With authentication
96
- opentunnel http 3000 -s example.com -t SECRET
97
-
98
- # TCP tunnel
99
- opentunnel tcp 5432 -s example.com -r 15432
100
- opentunnel tcp 5432 --domain example.com --remote-port 15432
101
- ```
102
-
103
- ### Option 4: Using Config File
104
-
105
- Create `opentunnel.yml`:
106
-
107
- ```yaml
108
- server:
109
- remote: example.com # Base domain (system adds basePath)
110
- token: ${AUTH_TOKEN} # From .env file (optional)
111
-
112
- tunnels:
113
- - name: web
114
- protocol: http
115
- port: 3000
116
- subdomain: myapp # → myapp.op.example.com
117
-
118
- - name: api
119
- protocol: http
120
- port: 4000
121
- subdomain: api # → api.op.example.com
24
+ opentunnel quick 3000 -s example.com -t YOUR_TOKEN
122
25
 
123
- - name: postgres
124
- protocol: tcp
125
- port: 5432
126
- remotePort: 15432 # → example.com:15432
26
+ # Custom subdomain
27
+ opentunnel quick 3000 -s example.com -n myapp
28
+ # → https://myapp.op.example.com
127
29
  ```
128
30
 
129
- ```bash
130
- opentunnel up # Start all tunnels
131
- opentunnel up -d # Start in background
132
- opentunnel down # Stop all tunnels
133
- opentunnel ps # Check status
134
- ```
135
-
136
- ---
137
-
138
- # 🖥️ As a Server
139
-
140
- Host your own OpenTunnel server to have full control. Your server can be **public** (anyone can connect) or **private** (requires authentication).
141
-
142
- ## Requirements
143
-
144
- - **VPS or server** with a public IP address
145
- - **Domain** pointing to your server
146
- - **Ports** 443 (HTTPS) and optionally 10000-20000 (TCP tunnels)
147
-
148
- ## DNS Configuration
31
+ ### As a Server
149
32
 
150
- Create these DNS records pointing to your server:
151
-
152
- | Type | Name | Value | Notes |
153
- |------|------|-------|-------|
154
- | A | `op` | `YOUR_SERVER_IP` | Main server (or your basePath) |
155
- | A | `*.op` | `YOUR_SERVER_IP` | Wildcard for subdomains |
156
-
157
- > **Cloudflare users:** Set proxy status to "DNS only" (gray cloud)
158
-
159
- Example for domain `example.com`:
160
- - `op.example.com` → Your server IP
161
- - `*.op.example.com` → Your server IP (wildcard)
162
-
163
- Tunnels will be available at: `https://myapp.op.example.com`
164
-
165
- ## Deployment Options
166
-
167
- ### Option 1: Quick Start (Manual)
33
+ Host your own tunnel server:
168
34
 
169
35
  ```bash
170
- # Install
171
- npm cache clean --force && npm install -g opentunnel-cli
172
-
173
- # Start public server (anyone can connect)
36
+ # Public server
174
37
  opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
175
38
 
176
- # Start private server (requires token to connect)
177
- opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "SECRET123"
178
-
179
- # Stop server
180
- opentunnel stop
181
- ```
182
-
183
- ### Option 2: Using Config File
184
-
185
- Create `opentunnel.yml`:
186
-
187
- ```yaml
188
- server:
189
- domain: example.com # Base domain only
190
- # token: SECRET123 # Uncomment for private server
191
- # tcpPortMin: 10000 # TCP tunnel port range (optional)
192
- # tcpPortMax: 20000
193
- ```
194
-
195
- ```bash
196
- opentunnel server -d # Start in background (reads from opentunnel.yml)
197
- opentunnel stop # Stop server
198
- ```
199
-
200
- ### Option 3: Docker (Recommended for Production)
201
-
202
- ```bash
203
- git clone https://github.com/FJRG2007/opentunnel.git
204
- cd opentunnel
205
-
206
- # Configure
207
- cp .env.example .env
208
- nano .env
39
+ # Private server (with auth)
40
+ opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "SECRET"
209
41
  ```
210
42
 
211
- Edit `.env`:
212
- ```env
213
- DOMAIN=example.com # Base domain only (without the op prefix)
214
- AUTH_TOKENS=SECRET123 # Leave empty for public server
215
- LETSENCRYPT_EMAIL=admin@example.com
216
- LETSENCRYPT_PRODUCTION=true
217
- ```
43
+ **DNS Setup:** Point `op.example.com` and `*.op.example.com` to your server IP.
218
44
 
219
- ```bash
220
- docker-compose up -d
221
- docker-compose down # Stop server
222
- ```
45
+ ### Home Use (Hybrid Mode)
223
46
 
224
- ### Option 4: One-Line Install (Linux with systemd)
47
+ Run server + tunnel in one terminal:
225
48
 
226
49
  ```bash
227
- curl -fsSL https://raw.githubusercontent.com/FJRG2007/opentunnel/main/deploy/install.sh | sudo bash
228
- ```
229
-
230
- Then configure:
231
- ```bash
232
- sudo nano /opt/opentunnel/.env
233
- sudo systemctl start opentunnel
234
- sudo systemctl stop opentunnel
235
- sudo systemctl status opentunnel
236
- ```
237
-
238
- ## Server Options
239
-
240
- ```bash
241
- opentunnel server [options]
242
-
243
- Required:
244
- --domain <domain> Your base domain (e.g., example.com)
245
- Tunnels will be at: *.op.example.com
246
-
247
- Optional:
248
- -p, --port <port> Server port (default: 443)
249
- -b, --base-path <path> Subdomain prefix (default: op, empty for direct)
250
- --tcp-min <port> Min TCP tunnel port (default: 10000)
251
- --tcp-max <port> Max TCP tunnel port (default: 20000)
252
- -d, --detach Run in background
253
-
254
- Authentication:
255
- --auth-tokens <tokens> Comma-separated tokens for private server
256
- Leave empty for public server
257
-
258
- SSL/TLS:
259
- --letsencrypt Enable Let's Encrypt certificates
260
- --email <email> Email for Let's Encrypt
261
- --production Use Let's Encrypt production (not staging)
262
- --cloudflare-token <token> Cloudflare API token for DNS-01 challenge
263
-
264
- IP Access Control:
265
- --ip-mode <mode> Access mode: all, allowlist, denylist (default: all)
266
- --ip-allow <ips> Comma-separated IPs/CIDRs to allow
267
- --ip-deny <ips> Comma-separated IPs/CIDRs to deny
268
- ```
269
-
270
- ## Server Modes
271
-
272
- ### Public Server
273
-
274
- Anyone can connect without authentication:
275
-
276
- ```bash
277
- opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
278
- ```
279
-
280
- Clients connect with:
281
- ```bash
282
- opentunnel quick 3000 -s example.com
283
- ```
284
-
285
- ### Private Server
286
-
287
- Only clients with valid tokens can connect:
288
-
289
- ```bash
290
- opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "token1,token2"
291
- ```
292
-
293
- Clients must provide a token:
294
- ```bash
295
- opentunnel quick 3000 -s example.com -t token1
296
- ```
297
-
298
- ---
299
-
300
- # 🏠 Home Use (Behind Router/NAT)
301
-
302
- If you want to run OpenTunnel server from your home network, you need to configure your router properly.
303
-
304
- ## Step 1: Static Internal IP
305
-
306
- First, assign a static IP to your computer in your router's DHCP settings. This prevents your IP from changing after a reboot.
307
-
308
- **Example:** `192.168.1.134`
309
-
310
- Most routers have this in: **Settings → LAN → DHCP Reservation** or **Address Reservation**
311
-
312
- ## Step 2: Port Forwarding
313
-
314
- Configure your router to forward external ports to your computer:
315
-
316
- | Name | Protocol | WAN Port | LAN Host | LAN Port | Description |
317
- |------|----------|----------|----------|----------|-------------|
318
- | OpenTunnel HTTP | TCP/UDP | 80 | 192.168.1.134 | 8080 | Let's Encrypt HTTP-01 challenge |
319
- | OpenTunnel HTTPS | TCP | 443 | 192.168.1.134 | 443 | Main HTTPS traffic |
320
- | OpenTunnel TCP | TCP/UDP | 10000-20000 | 192.168.1.134 | 10000-20000 | TCP tunnel ports |
321
-
322
- > **Note:** Replace `192.168.1.134` with your computer's static IP.
323
-
324
- ## Step 3: Dynamic DNS (Optional)
325
-
326
- If you don't have a static public IP, use a dynamic DNS service:
327
-
328
- - **DuckDNS** (free): `yourdomain.duckdns.org`
329
- - **Cloudflare** (free tier): Use with your own domain
330
- - **No-IP**, **DynDNS**, etc.
331
-
332
- ## Step 4: Start the Server
333
-
334
- ```bash
335
- # With Let's Encrypt (recommended)
336
- opentunnel server -d --domain yourdomain.duckdns.org --letsencrypt --email you@email.com --production
337
-
338
- # With self-signed certificate (for testing)
339
- opentunnel server -d --domain yourdomain.duckdns.org
340
- ```
341
-
342
- ## Step 5: Connect from Anywhere
343
-
344
- From any other network:
345
-
346
- ```bash
347
- opentunnel quick 3000 -s yourdomain.duckdns.org
348
- ```
349
-
350
- ## Quick Hybrid Mode (Server + Tunnel in One)
351
-
352
- For the simplest setup, expose a local port while running the server:
50
+ # Set default domain (one time)
51
+ opentunnel setdomain yourdomain.com
353
52
 
354
- ```bash
355
- # Easiest: set default domain once, then use expl
356
- opentunnel setdomain yourdomain.duckdns.org
53
+ # Expose any port
357
54
  opentunnel expl 3000
358
-
359
- # Or specify domain each time
360
- opentunnel expl 3000 -s yourdomain.duckdns.org
361
-
362
- # Alternative with quick command
363
- opentunnel quick 3000 -s yourdomain.duckdns.org --local-server
364
-
365
- # Or with config file
366
- opentunnel init --hybrid
367
- opentunnel up
368
- ```
369
-
370
- ## Troubleshooting
371
-
372
- **Ports not accessible from outside:**
373
- 1. Check your ISP doesn't block ports 80/443 (some do for residential)
374
- 2. Verify port forwarding rules are active
375
- 3. Test from a different network (not from inside your home network)
376
- 4. Check Windows Firewall / Linux iptables rules
377
-
378
- **Use alternative ports if ISP blocks 80/443:**
379
- ```bash
380
- opentunnel server -d --domain yourdomain.com -p 8443 --public-port 8443
381
- ```
382
-
383
- ---
384
-
385
- # 🌐 Multi-Domain Support
386
-
387
- OpenTunnel can handle **multiple domains** on a single server instance. Each domain works independently - clients connect to whichever domain they prefer and create their own tunnels.
388
-
389
- ## DNS Configuration
390
-
391
- For each domain you want to use, create DNS records pointing to your server:
392
-
393
- | Domain | Type | Name | Value |
394
- |--------|------|------|-------|
395
- | `domain1.com` | A | `op` | `YOUR_SERVER_IP` |
396
- | `domain1.com` | A | `*.op` | `YOUR_SERVER_IP` |
397
- | `domain2.com` | A | `op` | `YOUR_SERVER_IP` |
398
- | `domain2.com` | A | `*.op` | `YOUR_SERVER_IP` |
399
-
400
- ## Server Configuration
401
-
402
- Configure the server with multiple domains in `opentunnel.yml`:
403
-
404
- ```yaml
405
- server:
406
- domains:
407
- - domain: domain1.com
408
- basePath: op # Accepts tunnels at: *.op.domain1.com
409
- - domain: domain2.com
410
- basePath: op # Accepts tunnels at: *.op.domain2.com
411
- port: 443
412
55
  ```
413
56
 
414
- Start the server:
415
- ```bash
416
- opentunnel up -d
417
- ```
418
-
419
- ## How Clients Connect
57
+ ### Using ngrok or Cloudflare Tunnel
420
58
 
421
- Clients connect to whichever domain they want. Each client creates their own tunnels independently:
422
-
423
- **Client A** (connects to domain1.com):
424
- ```bash
425
- opentunnel quick 3000 -s domain1.com -n myapp
426
- # → https://myapp.op.domain1.com
427
- ```
428
-
429
- **Client B** (connects to domain2.com):
430
- ```bash
431
- opentunnel quick 8080 -s domain2.com -n api
432
- # → https://api.op.domain2.com
433
- ```
59
+ Don't have a server? Use third-party tunnel providers:
434
60
 
435
- **Client C** (also connects to domain1.com):
436
61
  ```bash
437
- opentunnel quick 5000 -s domain1.com -n backend
438
- # https://backend.op.domain1.com
439
- ```
440
-
441
- Each tunnel only exists on the domain the client connected to.
442
-
443
- ## Single Domain (Backward Compatible)
444
-
445
- If you only need one domain:
446
-
447
- ```yaml
448
- server:
449
- domain: example.com
450
- basePath: op
451
- ```
452
-
453
- ## Domains Without Wildcard Support (DuckDNS)
454
-
455
- Some DNS providers like **DuckDNS** don't support wildcard subdomains (`*.domain`). OpenTunnel automatically detects DuckDNS domains and uses **port-based routing** instead of subdomains.
456
-
457
- **Auto-detection:** Domains ending in `.duckdns.org` automatically use port-based mode.
458
-
459
- **Important:** DuckDNS domains cannot use `basePath` - it will throw an error:
460
-
461
- ```yaml
462
- # ❌ WRONG - Will throw an error
463
- server:
464
- domains:
465
- - domain: myapp.duckdns.org
466
- basePath: op # Error! DuckDNS doesn't support subdomains
467
-
468
- # ✅ CORRECT
469
- server:
470
- domains:
471
- - domain: fjrg2007.com
472
- basePath: op # Subdomain-based: *.op.fjrg2007.com
473
- - domain: myapp.duckdns.org
474
- # Port-based: myapp.duckdns.org:<port>
475
- ```
476
-
477
- **Manual configuration:** Use `wildcard: false` for other domains without wildcard support:
478
-
479
- ```yaml
480
- server:
481
- domains:
482
- - domain: fjrg2007.com
483
- basePath: op # Subdomain-based: *.op.fjrg2007.com
484
- - domain: other-no-wildcard.com
485
- wildcard: false # Manual: port-based
486
- ```
487
-
488
- **How it works:**
489
- - **Wildcard domains:** `https://myapp.op.fjrg2007.com`
490
- - **Non-wildcard domains:** `https://myapp.duckdns.org:10001`
491
-
492
- Clients connecting to non-wildcard domains receive port-based URLs automatically.
493
-
494
- ## SSL Certificates
495
-
496
- When using self-signed certificates with multiple domains, OpenTunnel automatically generates a **SAN (Subject Alternative Name) certificate** that covers all configured domains and their wildcards.
497
-
498
- For Let's Encrypt, you'll need separate certificates or a multi-domain certificate with all your domains listed.
499
-
500
- ## Use Cases
501
-
502
- ### Different Teams/Projects
503
-
504
- ```yaml
505
- server:
506
- domains:
507
- - domain: dev.company.com
508
- basePath: op # Dev team connects here
509
- - domain: staging.company.com
510
- basePath: op # QA team connects here
511
- ```
512
-
513
- ### White-Label Service
514
-
515
- ```yaml
516
- server:
517
- domains:
518
- - domain: client1.com
519
- basePath: op # Client 1's tunnels
520
- - domain: client2.com
521
- basePath: op # Client 2's tunnels
522
- ```
523
-
524
- ### Migration Between Domains
62
+ # With Cloudflare Tunnel (free, no account needed for quick tunnels)
63
+ opentunnel http 3000 --cloudflare
64
+ opentunnel http 3000 --cf
525
65
 
526
- ```yaml
527
- server:
528
- domains:
529
- - domain: newdomain.com
530
- basePath: op # New domain
531
- - domain: olddomain.com
532
- basePath: op # Old domain (still supported)
66
+ # With ngrok
67
+ opentunnel http 3000 --ngrok
68
+ opentunnel http 3000 --ngrok --region eu
533
69
  ```
534
70
 
535
- ---
536
-
537
- # 🔐 Authentication
538
-
539
- OpenTunnel uses a **shared secret** system for authentication. The server defines a list of valid tokens, and clients must provide one to connect.
71
+ ### Authentication & Named Tunnels
540
72
 
541
- ## Server Setup
73
+ Store credentials securely and manage Cloudflare named tunnels:
542
74
 
543
75
  ```bash
544
- # Single token
545
- opentunnel server -d --domain example.com --auth-tokens "my-secret-token"
546
-
547
- # Multiple tokens (one per user/team)
548
- opentunnel server -d --domain example.com --auth-tokens "team-a-token,team-b-token,dev-token"
549
- ```
550
-
551
- Or in `opentunnel.yml`:
552
- ```yaml
553
- server:
554
- domain: example.com
555
- token: my-secret-token
556
- ```
76
+ # Login to providers
77
+ opentunnel login cloudflare # Opens browser for OAuth
78
+ opentunnel login ngrok --token YOUR_TOKEN
557
79
 
558
- Or in `.env`:
559
- ```env
560
- AUTH_TOKENS=team-a-token,team-b-token,dev-token
561
- ```
562
-
563
- ## Client Usage
80
+ # Create and manage named tunnels
81
+ opentunnel create my-tunnel --cf
82
+ opentunnel tunnels --cf
83
+ opentunnel route my-tunnel app.example.com
84
+ opentunnel delete my-tunnel --cf
564
85
 
565
- ```bash
566
- # Command line
567
- opentunnel quick 3000 -s example.com -t my-secret-token
86
+ # Use named tunnel with -n flag
87
+ opentunnel http 3000 --cf -n my-tunnel
568
88
 
569
- # Or in opentunnel.yml
570
- server:
571
- remote: example.com
572
- token: my-secret-token
89
+ # View stored credentials
90
+ opentunnel config list
573
91
  ```
574
92
 
575
- ## Security Recommendations
576
-
577
- 1. **Use strong tokens**: Generate random strings (e.g., `openssl rand -hex 32`)
578
- 2. **One token per user/team**: Easier to revoke access if needed
579
- 3. **HTTPS only**: Always use `--letsencrypt` in production
580
- 4. **Rotate tokens periodically**: Update tokens and notify users
581
-
582
93
  ---
583
94
 
584
- # 🛡️ IP Access Control
585
-
586
- Control which IP addresses can connect to your server. By default, all IPs are allowed.
587
-
588
- ## Access Modes
589
-
590
- | Mode | Description |
591
- |------|-------------|
592
- | `all` | Allow all IPs (default) |
593
- | `allowlist` | Only allow IPs in the allow list |
594
- | `denylist` | Deny IPs in the deny list, allow others |
595
-
596
- ## Command Line
597
-
598
- ```bash
599
- # Only allow specific IPs/ranges
600
- opentunnel server -d --domain example.com --ip-mode allowlist --ip-allow "192.168.1.0/24,10.0.0.1"
601
-
602
- # Deny specific IPs
603
- opentunnel server -d --domain example.com --ip-mode denylist --ip-deny "1.2.3.4,5.6.7.0/24"
604
- ```
605
-
606
- ## Configuration File
607
-
608
- ```yaml
609
- server:
610
- domain: example.com
611
- token: ${AUTH_TOKEN}
612
- ipAccess:
613
- mode: allowlist # all, allowlist, or denylist
614
- allowList:
615
- - 192.168.1.0/24 # Allow entire subnet
616
- - 10.0.0.1 # Allow single IP
617
- - 172.16.0.0/16 # Allow another range
618
- ```
619
-
620
- ```yaml
621
- server:
622
- domain: example.com
623
- ipAccess:
624
- mode: denylist
625
- denyList:
626
- - 1.2.3.4 # Block single IP
627
- - 5.6.7.0/24 # Block entire subnet
628
- ```
629
-
630
- ## Supported Formats
631
-
632
- - Single IP: `192.168.1.1`
633
- - CIDR notation: `192.168.1.0/24` (256 addresses)
634
- - IPv6: `::1`, `2001:db8::/32`
95
+ ## Documentation
96
+
97
+ | Guide | Description |
98
+ |-------|-------------|
99
+ | [Client Guide](docs/client-guide.md) | Complete client usage and options |
100
+ | [Server Guide](docs/server-guide.md) | Server deployment and configuration |
101
+ | [Commands Reference](docs/commands.md) | All CLI commands and options |
102
+ | [Configuration File](docs/configuration.md) | opentunnel.yml reference |
103
+ | [Home Use Guide](docs/home-use-guide.md) | Running from home with port forwarding |
104
+ | [Domain Setup](docs/domain-setup.md) | DNS and SSL configuration |
105
+ | [DuckDNS & Free DNS](docs/duckdns-setup.md) | Free DNS services setup |
106
+ | [Cloudflare Tunnel](docs/cloudflare-tunnel.md) | Cloudflare Tunnel & named tunnels |
107
+ | [Multi-Domain](docs/multi-domain.md) | Multiple domains on one server |
108
+ | [Authentication](docs/authentication.md) | Token-based authentication |
109
+ | [IP Access Control](docs/ip-access-control.md) | Allow/deny IP ranges (cross-provider) |
110
+ | [Firewall (Dymo API)](docs/firewall-dymo-api.md) | Fraud detection and bot protection |
635
111
 
636
112
  ---
637
113
 
638
- # 📄 Configuration File
639
-
640
- Create `opentunnel.yml` in your project directory.
641
-
642
- ## Environment Variables
643
-
644
- OpenTunnel supports **Docker-style environment variable substitution** in config files. Variables are loaded from `.env` file automatically.
645
-
646
- | Syntax | Description |
647
- |--------|-------------|
648
- | `${VAR}` | Use value of VAR |
649
- | `${VAR:-default}` | Use VAR if set, otherwise use "default" |
650
- | `${VAR:=default}` | Same as above (alternative syntax) |
651
-
652
- **Example with `.env` file:**
653
-
654
- ```env
655
- # .env
656
- AUTH_TOKEN=my-secret-token
657
- SERVER_DOMAIN=example.com
658
- ```
659
-
660
- ```yaml
661
- # opentunnel.yml
662
- server:
663
- remote: ${SERVER_DOMAIN:-localhost} # Uses example.com from .env
664
- token: ${AUTH_TOKEN} # Uses my-secret-token from .env
665
-
666
- tunnels:
667
- - name: web
668
- protocol: http
669
- port: 3000
670
- subdomain: app
671
- ```
672
-
673
- ## Client Mode (connect to remote server)
674
-
675
- ```yaml
676
- server:
677
- remote: ${SERVER_DOMAIN:-example.com} # Base domain (system adds basePath)
678
- token: ${AUTH_TOKEN} # From .env (optional)
679
-
680
- tunnels:
681
- - name: frontend
682
- protocol: http
683
- port: 3000
684
- subdomain: app # → app.op.example.com
685
-
686
- - name: backend
687
- protocol: http
688
- port: 4000
689
- subdomain: api # → api.op.example.com
690
-
691
- - name: database
692
- protocol: tcp
693
- port: 5432
694
- remotePort: 15432 # → example.com:15432
695
- autostart: false # Don't start automatically
696
- ```
697
-
698
- ## Server Mode (run your own server)
699
-
700
- ```yaml
701
- server:
702
- domain: ${DOMAIN:-example.com} # Base domain only
703
- token: ${AUTH_TOKEN} # Optional: for private server
704
- # tcpPortMin: 10000 # TCP tunnel port range (optional)
705
- # tcpPortMax: 20000
706
- ```
707
-
708
- ## Hybrid Mode (server + tunnels in one terminal)
709
-
710
- For home use or development, you can run the server AND expose local ports in the same terminal without needing a separate server process.
711
-
712
- ```yaml
713
- mode: hybrid # Server + tunnels in one terminal
714
-
715
- server:
716
- domain: ${DOMAIN:-example.com} # Your domain
717
- token: ${AUTH_TOKEN} # Optional
718
-
719
- tunnels:
720
- - name: web
721
- protocol: http
722
- port: 3000
723
- subdomain: web # → web.op.example.com
724
-
725
- - name: api
726
- protocol: http
727
- port: 4000
728
- subdomain: api # → api.op.example.com
729
- ```
730
-
731
- ```bash
732
- opentunnel up # Starts server + all tunnels
733
- ```
734
-
735
- **Quick hybrid start (no config file):**
736
- ```bash
737
- # Easiest way (with default domain set)
738
- opentunnel expl 3000
739
-
740
- # Or with explicit domain
741
- opentunnel expl 3000 -s yourdomain.com
742
-
743
- # Alternative
744
- opentunnel quick 3000 -s yourdomain.com --local-server
745
- ```
746
-
747
- ## Commands
748
-
749
- ```bash
750
- opentunnel init # Create example config file
751
- opentunnel up # Start server/tunnels from config
752
- opentunnel up -d # Start in background
753
- opentunnel down # Stop everything
754
- opentunnel stop # Stop server
755
- opentunnel ps # Show running processes
756
- ```
757
-
758
- ---
759
-
760
- # 📖 Commands Reference
761
-
762
- | Command | Description |
763
- |---------|-------------|
764
- | `opentunnel expl <port>` | Expose local port via local server (uses default domain) |
765
- | `opentunnel quick <port> -s <domain>` | Quick tunnel to a server |
766
- | `opentunnel http <port>` | HTTP tunnel with options |
767
- | `opentunnel tcp <port>` | TCP tunnel with options |
768
- | `opentunnel server -d` | Start tunnel server in background |
769
- | `opentunnel up` | Start from opentunnel.yml |
770
- | `opentunnel down` | Stop all tunnels |
771
- | `opentunnel restart` | Restart tunnels (down + up) |
772
- | `opentunnel stop` | Stop server |
773
- | `opentunnel ps` | List running processes |
774
- | `opentunnel init` | Create config file |
775
- | `opentunnel setdomain <domain>` | Set default domain for expl command |
776
- | `opentunnel getdomain` | Show current default domain |
777
- | `opentunnel cleardomain` | Remove default domain configuration |
778
-
779
- ## Expose Local Command (expl)
780
-
781
- The simplest way to expose a local port. Starts a local server and creates a tunnel automatically.
782
-
783
- ```bash
784
- opentunnel expl <port> [options]
785
-
786
- Options:
787
- -s, --domain <domain> Server domain (uses default if not specified)
788
- -b, --base-path <path> Server base path (default: op)
789
- -n, --subdomain <name> Request specific subdomain
790
- -p, --protocol <proto> http, https, or tcp (default: http)
791
- -h, --host <host> Local host (default: localhost)
792
- -t, --token <token> Authentication token
793
- --insecure Skip SSL verification
794
- --server-port <port> Port for local server (default: 443)
795
- ```
796
-
797
- **Examples:**
798
- ```bash
799
- # With default domain configured
800
- opentunnel expl 3000
801
-
802
- # With explicit domain
803
- opentunnel expl 3000 -s example.com
804
-
805
- # With subdomain
806
- opentunnel expl 3000 -n myapp
807
- ```
808
-
809
- ## Domain Configuration
810
-
811
- Set a default domain so you don't need to specify `-s` every time:
812
-
813
- ```bash
814
- # Set default domain
815
- opentunnel setdomain example.com
816
- opentunnel setdomain example.com -b op # with custom base path
817
-
818
- # View current configuration
819
- opentunnel getdomain
820
-
821
- # Remove default domain
822
- opentunnel cleardomain
823
- ```
824
-
825
- Configuration is stored in `~/.opentunnel/config.json`:
826
- ```json
827
- {
828
- "defaultDomain": {
829
- "domain": "example.com",
830
- "basePath": "op"
831
- }
832
- }
833
- ```
834
-
835
- ## Quick Command
836
-
837
- ```bash
838
- opentunnel quick <port> [options]
839
-
840
- Required:
841
- -s, --domain <domain> Server domain (e.g., example.com)
842
-
843
- Options:
844
- -b, --base-path <path> Server base path (default: op, empty for direct)
845
- -n, --subdomain <name> Request specific subdomain
846
- -p, --protocol <proto> http, https, or tcp (default: http)
847
- -h, --host <host> Local host (default: localhost)
848
- -t, --token <token> Authentication token
849
- --insecure Skip SSL verification (self-signed certs)
850
- --local-server Start a local server (use with -s for your domain)
851
- --server-port <port> Port for local server (default: 443)
852
- ```
853
-
854
- ## HTTP/TCP Commands
855
-
856
- ```bash
857
- opentunnel http <port> [options]
858
- opentunnel tcp <port> [options]
859
-
860
- Required:
861
- -s, --domain <domain> Server domain (e.g., example.com)
862
-
863
- Options:
864
- -b, --base-path <path> Server base path (default: op)
865
- -t, --token <token> Authentication token
866
- -n, --subdomain <name> Custom subdomain
867
- -h, --host <host> Local host (default: localhost)
868
- -r, --remote-port <port> Remote TCP port (tcp only)
869
- --insecure Skip SSL verification
870
- ```
871
-
872
- ## Background Mode
873
-
874
- Run multiple instances in the background:
875
-
876
- ```bash
877
- # Start instances
878
- opentunnel up -d # Default instance
879
- opentunnel up production -d # Named instance "production"
880
- opentunnel up staging -d # Named instance "staging"
881
-
882
- # List running instances
883
- opentunnel ps
884
-
885
- # Restart instances
886
- opentunnel restart # Restart all in current directory
887
- opentunnel restart production # Restart specific instance
888
-
889
- # Stop instances
890
- opentunnel down production # Stop specific instance
891
- opentunnel down # Stop all instances
892
- ```
893
-
894
- ---
895
-
896
- # 🏗️ Architecture
114
+ ## Architecture
897
115
 
898
116
  ```
899
117
  ┌─────────────────────────────────────────────────────────────────┐
900
- │ INTERNET
901
-
902
- │ Users access: https://myapp.op.example.com │
118
+ │ INTERNET
119
+ Users access: https://myapp.op.example.com
903
120
  └──────────────────────────────┬──────────────────────────────────┘
904
121
 
905
122
 
906
123
  ┌─────────────────────────────────────────────────────────────────┐
907
- │ OpenTunnel Server
124
+ │ OpenTunnel Server
908
125
  │ (op.example.com) │
909
- │ │
910
- │ - Receives HTTPS requests │
911
126
  │ - Routes by subdomain │
912
- │ - Forwards to connected clients via WebSocket
127
+ │ - Forwards via WebSocket
913
128
  └──────────────────────────────┬──────────────────────────────────┘
914
-
915
- │ WebSocket (persistent connection)
916
-
917
- ┌──────────────────────────────┴──────────────────────────────────┐
918
- │ Your Computer │
129
+ WebSocket
130
+
131
+ ┌─────────────────────────────────────────────────────────────────┐
132
+ │ Your Computer │
919
133
  │ (behind NAT/firewall) │
920
- │ │
921
134
  │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
922
135
  │ │ Web App │ │ API Server │ │ Database │ │
923
136
  │ │ :3000 │ │ :4000 │ │ :5432 │ │
924
137
  │ └──────────────┘ └──────────────┘ └──────────────┘ │
925
- │ │
926
- │ opentunnel up ← Connects to server, no port forwarding │
927
138
  └─────────────────────────────────────────────────────────────────┘
928
139
  ```
929
140
 
930
- **Key points:**
931
- - Client initiates connection (outbound only)
932
- - No port forwarding needed on client's router
933
- - All traffic goes through the server
934
- - WebSocket keeps connection alive
935
-
936
141
  ---
937
142
 
938
- # 📜 License
143
+ ## License
939
144
 
940
145
  [Proprietary License](LICENSE) - All rights reserved.
941
146
 
942
147
  - ✅ Personal, educational, and commercial use allowed
943
148
  - ❌ No forks or redistribution without permission
944
- - ❌ No reselling or monetization without explicit consent
149
+ - ❌ No reselling without explicit consent
945
150
 
946
151
  Contact FJRG2007 for licensing questions.