@mucan54/porterman 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Porterman Contributors
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,165 @@
1
+ # Porterman
2
+
3
+ > Your ports, delivered. Zero-config HTTPS for any local service.
4
+
5
+ One command. Real SSL. No external servers. No accounts. No BS.
6
+
7
+ ```bash
8
+ $ porterman expose 3000
9
+ https://3000-85-100-50-25.sslip.io -> http://localhost:3000
10
+ ```
11
+
12
+ ## How It Works
13
+
14
+ Porterman runs on machines with a public IP (VPS, cloud instances, dedicated servers). It automatically:
15
+
16
+ 1. Detects your public IP address
17
+ 2. Obtains Let's Encrypt SSL certificates via ACME HTTP-01 challenge
18
+ 3. Starts an HTTPS reverse proxy that routes based on hostname
19
+ 4. Uses [sslip.io](https://sslip.io) for DNS — no configuration needed
20
+
21
+ The hostname pattern `{port}-{ip-dashed}.sslip.io` embeds both the port and IP, enabling multi-port exposure from a single instance.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install -g @mucan54/porterman
27
+ ```
28
+
29
+ Requires Node.js 18+.
30
+
31
+ ## Usage
32
+
33
+ ### Expose a single port
34
+
35
+ ```bash
36
+ porterman expose 3000
37
+ ```
38
+
39
+ ### Expose multiple ports
40
+
41
+ ```bash
42
+ porterman expose 3000 8080 5173
43
+ # https://3000-85-100-50-25.sslip.io -> http://localhost:3000
44
+ # https://8080-85-100-50-25.sslip.io -> http://localhost:8080
45
+ # https://5173-85-100-50-25.sslip.io -> http://localhost:5173
46
+ ```
47
+
48
+ ### Custom subdomain name
49
+
50
+ ```bash
51
+ porterman expose 3000 --name myapp
52
+ # https://myapp-85-100-50-25.sslip.io -> http://localhost:3000
53
+ ```
54
+
55
+ ### HTTP-only mode (skip SSL)
56
+
57
+ ```bash
58
+ porterman expose 3000 --no-ssl
59
+ ```
60
+
61
+ ### With basic auth
62
+
63
+ ```bash
64
+ porterman expose 3000 --auth user:pass
65
+ ```
66
+
67
+ ### Restrict by IP
68
+
69
+ ```bash
70
+ porterman expose 3000 --ip-allow 1.2.3.4,5.6.7.8
71
+ ```
72
+
73
+ ### All options
74
+
75
+ ```
76
+ porterman expose [...ports]
77
+
78
+ Options:
79
+ -n, --name <name> Custom subdomain prefix (single port only)
80
+ --no-ssl HTTP only mode (skip SSL)
81
+ -v, --verbose Log all requests
82
+ --timeout <seconds> Proxy timeout (default: 30)
83
+ --host <ip> Override auto-detected IP
84
+ --staging Use Let's Encrypt staging environment
85
+ --http-port <port> Custom HTTP port (default: 80)
86
+ --https-port <port> Custom HTTPS port (default: 443)
87
+ --auth <user:pass> Enable basic auth
88
+ --ip-allow <ips> Comma-separated allowed IPs
89
+ ```
90
+
91
+ ### Other commands
92
+
93
+ ```bash
94
+ porterman status # Show running instance info
95
+ porterman stop # Stop running instance
96
+ porterman certs --clean # Remove all cached certificates
97
+ porterman --help # Show help
98
+ porterman --version # Show version
99
+ ```
100
+
101
+ ## Architecture
102
+
103
+ ```
104
+ Internet Request
105
+ |
106
+ | https://3000-85-100-50-25.sslip.io
107
+ v
108
+ +-----------------------------+
109
+ | Porterman HTTPS Server |
110
+ | (port 443) |
111
+ | |
112
+ | TLS Termination |
113
+ | (Auto Let's Encrypt) |
114
+ | | |
115
+ | Host-based Router |
116
+ | |
117
+ | 3000-ip.sslip.io -> localhost:3000 |
118
+ | 8080-ip.sslip.io -> localhost:8080 |
119
+ +-----------------------------+
120
+ | ACME HTTP-01 Server |
121
+ | (port 80) |
122
+ +-----------------------------+
123
+ ```
124
+
125
+ ## Features
126
+
127
+ - **Zero config** — just specify the port(s)
128
+ - **Real SSL** — automatic Let's Encrypt certificates
129
+ - **Multi-port** — expose multiple services simultaneously
130
+ - **WebSocket support** — full WS/WSS proxying (critical for HMR)
131
+ - **SNI routing** — per-hostname certificate serving
132
+ - **Auto IP detection** — with multiple fallback services
133
+ - **Cert caching** — certificates persist in `~/.porterman/certs/`
134
+ - **Self-signed fallback** — if Let's Encrypt rate limits are hit
135
+ - **Basic auth** — optional password protection
136
+ - **IP allowlist** — restrict access by source IP
137
+ - **Proxy headers** — X-Forwarded-For, X-Forwarded-Proto, X-Real-IP
138
+
139
+ ## Requirements
140
+
141
+ - Node.js >= 18
142
+ - A machine with a public IP address
143
+ - Ports 80 and 443 available (or use `--http-port` / `--https-port`)
144
+
145
+ ## Programmatic API
146
+
147
+ ```typescript
148
+ import { startServer } from "@mucan54/porterman";
149
+
150
+ const server = await startServer({
151
+ ports: [3000, 8080],
152
+ verbose: true,
153
+ timeout: 60,
154
+ });
155
+
156
+ // server.urls is a Map<number, string> of port -> URL
157
+ console.log(server.urls);
158
+
159
+ // Graceful shutdown
160
+ await server.close();
161
+ ```
162
+
163
+ ## License
164
+
165
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/cli.js";