asyx 0.1.2 → 0.2.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/README.md +150 -8
- package/package.json +10 -2
- package/src/commands/tunnel.js +1160 -91
- package/src/control-plane/MqttControlPlaneClient.js +1150 -0
- package/src/control-plane/MqttControlPlaneTransport.js +150 -0
- package/src/lib/logger.js +8 -4
- package/src/mqtt/awaiter-map.js +92 -2
- package/src/mqtt/events/handlers.js +120 -11
- package/src/mqtt/ingress.js +11 -1
- package/src/state/assignment.js +9 -0
- package/src/tcp-v1/framing.js +203 -0
- package/src/tunnel/http-tunnel.js +246 -28
- package/src/tunnel/tcp-tunnel.js +896 -0
package/README.md
CHANGED
|
@@ -34,13 +34,51 @@ npm uninstall -g asyx
|
|
|
34
34
|
- Captures a minimal hardware fingerprint, hashes it locally (SHA-256 with public salt), and shares only the hash so the Asyx backend can verify the CLI is on the authorized device.
|
|
35
35
|
- Certificates are single-device: copying them to another machine fails policy checks, so re-run `asyx setup` on every host.
|
|
36
36
|
|
|
37
|
+
### 🎮 Sharing Your Minecraft Server (Super Easy!)
|
|
38
|
+
|
|
39
|
+
Want to share your Minecraft server with friends? It's literally one command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. Start your local Minecraft server (on port 25565)
|
|
43
|
+
# 2. Run this:
|
|
44
|
+
asyx tunnel --minecraft
|
|
45
|
+
|
|
46
|
+
# 3. Share the hostname shown (e.g., smart.tunnel.asyx.ai)
|
|
47
|
+
# Your friends connect using just the hostname—no port needed!
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
That's it! No firewall configuration, no port forwarding, no DNS setup. The `--minecraft` verb handles everything automatically, including creating the SRV record that lets Minecraft clients discover the port automatically.
|
|
51
|
+
|
|
37
52
|
2. **Open a tunnel**
|
|
53
|
+
|
|
54
|
+
**HTTP tunnel:**
|
|
38
55
|
```bash
|
|
39
56
|
asyx tunnel --http --port 3000
|
|
40
57
|
```
|
|
41
|
-
- Creates a forward-only HTTP tunnel bound to your issued client ID.
|
|
42
|
-
- Automatically refreshes JWTs over the Asyx messaging pipeline and keeps the session alive while traffic is flowing.
|
|
43
|
-
|
|
58
|
+
- Creates a forward-only HTTP tunnel bound to your issued client ID.
|
|
59
|
+
- Automatically refreshes JWTs over the Asyx messaging pipeline and keeps the session alive while traffic is flowing.
|
|
60
|
+
|
|
61
|
+
**Minecraft tunnel (easiest way to share your server):**
|
|
62
|
+
```bash
|
|
63
|
+
asyx tunnel --minecraft
|
|
64
|
+
```
|
|
65
|
+
- **One command** to expose your local Minecraft server to the internet.
|
|
66
|
+
- Automatically configures port 25565 (override with `--port` if needed).
|
|
67
|
+
- Creates an SRV record so players can connect using just the hostname—**no port number needed**.
|
|
68
|
+
- **Example**: Run `asyx tunnel --minecraft`, then share `smart.tunnel.asyx.ai` with your friends. They connect in Minecraft using just that hostname.
|
|
69
|
+
- Optional `--name` flag for a custom subdomain (e.g., `--name my-server` → `my-server.smart.tunnel.asyx.ai`).
|
|
70
|
+
- That's it! No firewall rules, no port forwarding, no DNS configuration.
|
|
71
|
+
|
|
72
|
+
**TCP tunnel (for other services):**
|
|
73
|
+
```bash
|
|
74
|
+
asyx tunnel --tcp --port <localPort> [--name <service>]
|
|
75
|
+
```
|
|
76
|
+
- Creates a TCP tunnel for raw TCP connections (e.g., game servers, databases, SSH).
|
|
77
|
+
- `--port`: Local target port on `127.0.0.1` (e.g., `25565` for Minecraft on `127.0.0.1:25565`).
|
|
78
|
+
- `--name`: Optional service name; if provided, creates a CNAME alias `<name>.<subdomain>.tunnel.asyx.ai`; otherwise only `host:port` form is used.
|
|
79
|
+
- The CLI prints the assignment: `fqdn:publicPort` (alias if `--name` provided, otherwise `host:port`).
|
|
80
|
+
- Uses binary `tcp-v1` framing protocol over WebSocket (no user action needed; handled automatically).
|
|
81
|
+
- The relay URL in assignments uses `/tcp` endpoint (configured automatically).
|
|
44
82
|
|
|
45
83
|
3. **Clean up (optional)**
|
|
46
84
|
```bash
|
|
@@ -48,22 +86,35 @@ npm uninstall -g asyx
|
|
|
48
86
|
```
|
|
49
87
|
Removes local device material; re-run `asyx setup` afterwards to restore access.
|
|
50
88
|
|
|
89
|
+
## What's New in v0.2.0
|
|
90
|
+
|
|
91
|
+
- **Minecraft tunnels made easy**: New `--minecraft` verb—just run `asyx tunnel --minecraft` and share your server instantly. No port numbers, no configuration, no hassle.
|
|
92
|
+
- **SRV record support**: Minecraft clients automatically discover the correct port via DNS SRV records—players just enter the hostname.
|
|
93
|
+
- **TCP tunnel support**: Expose raw TCP services (game servers, databases, SSH) with `asyx tunnel --tcp --port <n>`
|
|
94
|
+
- **Binary tcp-v1 framing**: Automatic protocol handling for multi-stream TCP tunneling
|
|
95
|
+
- **Coordinator-based assignments**: TCP tunnels use the same assignment system as HTTP tunnels; no additional configuration needed
|
|
96
|
+
- **Service aliases**: Optional `--name` flag for friendly service names (when aliases are provisioned)
|
|
97
|
+
|
|
51
98
|
## Why Asyx
|
|
52
99
|
|
|
53
100
|
- **Device-bound identity** – Every `setup` run issues a unique certificate and uuLID. Asyx backend policies reject duplicate usage, preventing credential theft or relocation.
|
|
54
101
|
- **Hardware attestation without PII** – The CLI derives a hashed hardware fingerprint locally using the safe `hw-fingerprint` fields; raw hardware attributes never leave the device.
|
|
55
102
|
- **Resilient control plane** – Automatic JWT refresh via the background messaging queue, bounded reconnects, and observable logging (`ASYX_DEBUG=1`) keep tunnels stable during long soaks.
|
|
56
103
|
- **Zero manual relay config** – Asyx backend assignments route traffic for you; no hostnames, firewall poking, or manual DNS updates required.
|
|
57
|
-
- **
|
|
104
|
+
- **Multi-protocol support** – HTTP and TCP tunnels share the same assignment system; choose the protocol that fits your service.
|
|
105
|
+
- **Secure proxy architecture** – Forward-only mode avoids local port binding conflicts and keeps user services isolated from the CLI process.
|
|
58
106
|
- **Observability-first UX** – Friendly error messages, deterministic exit codes, and optional debug traces make support straightforward.
|
|
59
|
-
- **Future-ready auth** – Today
|
|
107
|
+
- **Future-ready auth** – Today's magic-link flow will extend to tunnel sharing with Asyx Quickpass, delivering passwordless approvals for downstream users.
|
|
60
108
|
|
|
61
109
|
## Command Reference
|
|
62
110
|
|
|
63
111
|
```bash
|
|
64
|
-
asyx setup
|
|
65
|
-
asyx tunnel --http --port <n>
|
|
66
|
-
asyx
|
|
112
|
+
asyx setup # Provision device certificate and client identity
|
|
113
|
+
asyx tunnel --http --port <n> # Start HTTP tunnel for local port <n>
|
|
114
|
+
asyx tunnel --minecraft # Start Minecraft tunnel (easiest way!)
|
|
115
|
+
asyx tunnel --minecraft --name <svc> # Start Minecraft tunnel with custom name
|
|
116
|
+
asyx tunnel --tcp --port <n> [--name <service>] # Start TCP tunnel for local port <n>
|
|
117
|
+
asyx mqtt ... # Development MQTT utilities (NODE_ENV=dev)
|
|
67
118
|
```
|
|
68
119
|
|
|
69
120
|
Use `asyx help` or `asyx <command> --help` for details.
|
|
@@ -83,6 +134,34 @@ ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000 # full verbosity for engine
|
|
|
83
134
|
- Structured logs (JSON) are emitted to stdout/stderr; by default, debug is suppressed.
|
|
84
135
|
- User-facing banners remain visible regardless of log level.
|
|
85
136
|
|
|
137
|
+
## MQTT Connection Mode
|
|
138
|
+
|
|
139
|
+
Control MQTT client ID generation and reconnect behavior with the `ASYX_MQTT_CLIENTID_MODE` environment variable:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
# Modes: legacy | unique
|
|
143
|
+
# Default: unique
|
|
144
|
+
ASYX_MQTT_CLIENTID_MODE=unique asyx tunnel --http --port 3000 # unique client IDs, clean sessions (default)
|
|
145
|
+
ASYX_MQTT_CLIENTID_MODE=legacy asyx tunnel --http --port 3000 # persistent client IDs, mqtt.js auto-reconnect
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**`unique` mode (default):**
|
|
149
|
+
- Generates a unique client ID for each CLI invocation using ULID suffixes (e.g., `baseClientId_01ABC...XYZ`)
|
|
150
|
+
- Uses clean MQTT sessions (`clean: true`) so AWS IoT doesn't retain session state between reconnects
|
|
151
|
+
- Implements manual reconnect loop with jittered exponential backoff (300ms → 600ms → 1.2s → max 5s)
|
|
152
|
+
- Immediately reconnects on `ECONNRESET` errors
|
|
153
|
+
- Prevents "identifier in use" errors from lingering AWS IoT sessions
|
|
154
|
+
|
|
155
|
+
**`legacy` mode:**
|
|
156
|
+
- Uses persistent client ID from device configuration
|
|
157
|
+
- Uses persistent MQTT sessions (`clean: false`) allowing AWS IoT to retain session state
|
|
158
|
+
- Relies on mqtt.js built-in auto-reconnect behavior
|
|
159
|
+
- Useful for compatibility with older deployments or debugging
|
|
160
|
+
|
|
161
|
+
**When to use each mode:**
|
|
162
|
+
- Use `unique` (default) for production deployments to avoid lingering session issues
|
|
163
|
+
- Use `legacy` only if you need to maintain session state across reconnects or are debugging specific MQTT behavior
|
|
164
|
+
|
|
86
165
|
## Heartbeat Behavior
|
|
87
166
|
|
|
88
167
|
The CLI manages heartbeats automatically to keep idle sessions stable without user tuning.
|
|
@@ -92,8 +171,71 @@ The CLI manages heartbeats automatically to keep idle sessions stable without us
|
|
|
92
171
|
- Heartbeat stops when the tunnel exits or errors.
|
|
93
172
|
- Use `ASYX_DEBUG=1` if you need to trace heartbeat activity for support purposes.
|
|
94
173
|
|
|
174
|
+
## Security Groups
|
|
175
|
+
|
|
176
|
+
### HTTP Tunnels with `--secgroup`
|
|
177
|
+
|
|
178
|
+
HTTP tunnels support per-guest authentication via Asyx Quickpass security groups. When you specify `--secgroup <slug>`, the tunnel enforces access control so only authorized guests (with valid Quickpass cookies) can access your service.
|
|
179
|
+
|
|
180
|
+
### TCP Tunnels
|
|
181
|
+
|
|
182
|
+
TCP tunnels in v4.1 do not enforce per-guest authentication. Access is owner-only via JWT validation; guests connecting to the public port are anonymous (no per-connection auth). TCP tunnels honor relay-level limits:
|
|
183
|
+
|
|
184
|
+
**Minecraft Tunnels (v0.2.0+):**
|
|
185
|
+
|
|
186
|
+
The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Start your server, then run:
|
|
190
|
+
asyx tunnel --minecraft
|
|
191
|
+
|
|
192
|
+
# Share the hostname with friends (no port needed!)
|
|
193
|
+
# Example: smart.tunnel.asyx.ai
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**How it works:**
|
|
197
|
+
- Asyx automatically provisions an SRV record (`_minecraft._tcp.<host>`) that tells Minecraft clients which port to use
|
|
198
|
+
- Players enter just the hostname in the Minecraft launcher—no port number required
|
|
199
|
+
- The Minecraft launcher automatically discovers the port via the SRV record
|
|
200
|
+
|
|
201
|
+
**With a custom name:**
|
|
202
|
+
```bash
|
|
203
|
+
asyx tunnel --minecraft --name my-server
|
|
204
|
+
# Share: my-server.smart.tunnel.asyx.ai
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Technical details:**
|
|
208
|
+
- **SRV-aware clients (Minecraft)**: Use the hostname directly (with or without `--name`). The Minecraft launcher automatically discovers the port via the SRV record.
|
|
209
|
+
- **Non-SRV-aware clients**: Use the `hostname:port` format (e.g., `smart.tunnel.asyx.ai:10000`).
|
|
210
|
+
- **SRV record format**: `_minecraft._tcp.<host>` → target `<fqdn>`, port `<publicPort>`
|
|
211
|
+
- With `--name`: `_minecraft._tcp.<name>.<subdomain>.tunnel.asyx.ai`
|
|
212
|
+
- Without `--name`: `_minecraft._tcp.<subdomain>.tunnel.asyx.ai`
|
|
213
|
+
- **TTL**: 60 seconds (low TTL for agility)
|
|
214
|
+
- **Best-effort design**: SRV provisioning failures don't block tunnel creation; the tunnel still works with `hostname:port` format.
|
|
215
|
+
- **No default alias**: CNAME aliases are only created if you provide `--name`.
|
|
216
|
+
- **Connection limits**: Maximum concurrent connections per lease
|
|
217
|
+
- **Rate limits**: Bandwidth and connection rate throttling
|
|
218
|
+
- **Idle timeouts**: Automatic connection closure after inactivity
|
|
219
|
+
|
|
220
|
+
Future TCP guard/securing features are planned but out of scope for v4.1.
|
|
221
|
+
|
|
95
222
|
## Troubleshooting
|
|
96
223
|
|
|
224
|
+
### TCP Tunnel Issues
|
|
225
|
+
|
|
226
|
+
**Alias unavailable:**
|
|
227
|
+
- If the Coordinator returns a warning that an alias is unavailable, use the `fqdn:publicPort` format shown in the CLI output.
|
|
228
|
+
- This is normal during validation phases; `host:port` always works.
|
|
229
|
+
|
|
230
|
+
**Local service not accessible:**
|
|
231
|
+
- Ensure your local service is running on `127.0.0.1:<port>` on the CLI machine.
|
|
232
|
+
- The tunnel forwards connections from the relay to `127.0.0.1:<localPort>`.
|
|
233
|
+
|
|
234
|
+
**Connection timeouts:**
|
|
235
|
+
- If external connections to `fqdn:publicPort` time out, check firewall/port exposure at the relay.
|
|
236
|
+
- The relay must have the `publicPort` open in its security group/firewall rules.
|
|
237
|
+
- Verify the relay is operational and the TCP tunnel is active (check CLI logs).
|
|
238
|
+
|
|
97
239
|
### MQTT Connection Issues (Windows)
|
|
98
240
|
|
|
99
241
|
If you experience issues where the CLI connects but never receives `open_ack` messages (especially on Windows after running `asyx setup` without OpenSSL), the private key may be in PKCS#8 format which Node's TLS stack on Windows rejects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asyx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Asyx Command Line Interface",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"src/commands/setup.js",
|
|
36
36
|
"src/commands/sts.js",
|
|
37
37
|
"src/commands/tunnel.js",
|
|
38
|
+
"src/control-plane/MqttControlPlaneClient.js",
|
|
39
|
+
"src/control-plane/MqttControlPlaneTransport.js",
|
|
38
40
|
"src/lib/.gitkeep",
|
|
39
41
|
"src/lib/certs.js",
|
|
40
42
|
"src/lib/csr.js",
|
|
@@ -51,28 +53,34 @@
|
|
|
51
53
|
"src/mqtt/events/schemas.js",
|
|
52
54
|
"src/mqtt/ingress.js",
|
|
53
55
|
"src/state/assignment.js",
|
|
56
|
+
"src/tcp-v1/framing.js",
|
|
54
57
|
"src/tunnel/http-tunnel.js",
|
|
58
|
+
"src/tunnel/tcp-tunnel.js",
|
|
55
59
|
"src/tunnel/ws-control.js",
|
|
56
60
|
"LICENSE",
|
|
57
61
|
"README.md",
|
|
58
62
|
"SECURITY.md"
|
|
59
63
|
],
|
|
60
64
|
"dependencies": {
|
|
65
|
+
"-": "^0.0.1",
|
|
61
66
|
"@asyx/mqtt-broker-aws": "^0.1.0",
|
|
62
67
|
"@asyx/mqtt-client": "^0.1.0",
|
|
63
68
|
"@peculiar/webcrypto": "^1.5.0",
|
|
64
69
|
"@peculiar/x509": "^1.14.0",
|
|
70
|
+
"asyx": "^0.1.3",
|
|
65
71
|
"chalk": "^5.3.0",
|
|
66
72
|
"hw-fingerprint": "^3.2.0",
|
|
67
73
|
"node-fetch": "^3.3.2",
|
|
68
74
|
"open": "^9.1.0",
|
|
75
|
+
"ulid": "^2.4.0",
|
|
69
76
|
"ws": "^8.14.2",
|
|
70
77
|
"zod": "3.23.8"
|
|
71
78
|
},
|
|
72
79
|
"scripts": {
|
|
80
|
+
"build": "npm install",
|
|
73
81
|
"postinstall": "node -e \"console.log('✅ asyx installed')\"",
|
|
74
82
|
"check": "node ./src/main.js --version",
|
|
75
|
-
"test": "NODE_OPTIONS
|
|
83
|
+
"test": "NODE_OPTIONS=\"--experimental-vm-modules --max-old-space-size=8192\" jest --runInBand",
|
|
76
84
|
"pack:verify": "node scripts/pack-verify.mjs",
|
|
77
85
|
"prepublishOnly": "npm test && npm run pack:verify",
|
|
78
86
|
"prepack": "node scripts/prepack.mjs",
|