asyx 0.2.0 → 0.2.2
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 +11 -39
- package/package.json +1 -1
- package/src/commands/tunnel.js +21 -1
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ npm uninstall -g asyx
|
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
1. **Authorize the client**
|
|
27
28
|
```bash
|
|
28
29
|
asyx setup
|
|
@@ -43,7 +44,7 @@ Want to share your Minecraft server with friends? It's literally one command:
|
|
|
43
44
|
# 2. Run this:
|
|
44
45
|
asyx tunnel --minecraft
|
|
45
46
|
|
|
46
|
-
# 3. Share the hostname shown (e.g.,
|
|
47
|
+
# 3. Share the hostname shown (e.g., example.tunnel.asyx.ai)
|
|
47
48
|
# Your friends connect using just the hostname—no port needed!
|
|
48
49
|
```
|
|
49
50
|
|
|
@@ -65,8 +66,8 @@ That's it! No firewall configuration, no port forwarding, no DNS setup. The `--m
|
|
|
65
66
|
- **One command** to expose your local Minecraft server to the internet.
|
|
66
67
|
- Automatically configures port 25565 (override with `--port` if needed).
|
|
67
68
|
- Creates an SRV record so players can connect using just the hostname—**no port number needed**.
|
|
68
|
-
- **Example**: Run `asyx tunnel --minecraft`, then share `
|
|
69
|
-
- Optional `--name` flag for a custom subdomain (e.g., `--name my-server` → `my-server.
|
|
69
|
+
- **Example**: Run `asyx tunnel --minecraft`, then share `example.tunnel.asyx.ai` with your friends. They connect in Minecraft using just that hostname.
|
|
70
|
+
- Optional `--name` flag for a custom subdomain (e.g., `--name my-server` → `my-server.example.tunnel.asyx.ai`).
|
|
70
71
|
- That's it! No firewall rules, no port forwarding, no DNS configuration.
|
|
71
72
|
|
|
72
73
|
**TCP tunnel (for other services):**
|
|
@@ -77,7 +78,7 @@ That's it! No firewall configuration, no port forwarding, no DNS setup. The `--m
|
|
|
77
78
|
- `--port`: Local target port on `127.0.0.1` (e.g., `25565` for Minecraft on `127.0.0.1:25565`).
|
|
78
79
|
- `--name`: Optional service name; if provided, creates a CNAME alias `<name>.<subdomain>.tunnel.asyx.ai`; otherwise only `host:port` form is used.
|
|
79
80
|
- The CLI prints the assignment: `fqdn:publicPort` (alias if `--name` provided, otherwise `host:port`).
|
|
80
|
-
- Uses binary
|
|
81
|
+
- Uses Asyx binary framing over WebSocket (no user action needed; handled automatically).
|
|
81
82
|
- The relay URL in assignments uses `/tcp` endpoint (configured automatically).
|
|
82
83
|
|
|
83
84
|
3. **Clean up (optional)**
|
|
@@ -86,12 +87,12 @@ That's it! No firewall configuration, no port forwarding, no DNS setup. The `--m
|
|
|
86
87
|
```
|
|
87
88
|
Removes local device material; re-run `asyx setup` afterwards to restore access.
|
|
88
89
|
|
|
89
|
-
## What's New in v0.2.
|
|
90
|
+
## What's New in v0.2.2
|
|
90
91
|
|
|
91
92
|
- **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
93
|
- **SRV record support**: Minecraft clients automatically discover the correct port via DNS SRV records—players just enter the hostname.
|
|
93
94
|
- **TCP tunnel support**: Expose raw TCP services (game servers, databases, SSH) with `asyx tunnel --tcp --port <n>`
|
|
94
|
-
- **
|
|
95
|
+
- **Asyx binary framing**: Automatic protocol handling for multi-stream TCP tunneling
|
|
95
96
|
- **Coordinator-based assignments**: TCP tunnels use the same assignment system as HTTP tunnels; no additional configuration needed
|
|
96
97
|
- **Service aliases**: Optional `--name` flag for friendly service names (when aliases are provisioned)
|
|
97
98
|
|
|
@@ -114,7 +115,6 @@ asyx tunnel --http --port <n> # Start HTTP tunnel for local port <n>
|
|
|
114
115
|
asyx tunnel --minecraft # Start Minecraft tunnel (easiest way!)
|
|
115
116
|
asyx tunnel --minecraft --name <svc> # Start Minecraft tunnel with custom name
|
|
116
117
|
asyx tunnel --tcp --port <n> [--name <service>] # Start TCP tunnel for local port <n>
|
|
117
|
-
asyx mqtt ... # Development MQTT utilities (NODE_ENV=dev)
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
Use `asyx help` or `asyx <command> --help` for details.
|
|
@@ -134,34 +134,6 @@ ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000 # full verbosity for engine
|
|
|
134
134
|
- Structured logs (JSON) are emitted to stdout/stderr; by default, debug is suppressed.
|
|
135
135
|
- User-facing banners remain visible regardless of log level.
|
|
136
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
|
-
|
|
165
137
|
## Heartbeat Behavior
|
|
166
138
|
|
|
167
139
|
The CLI manages heartbeats automatically to keep idle sessions stable without user tuning.
|
|
@@ -181,7 +153,7 @@ HTTP tunnels support per-guest authentication via Asyx Quickpass security groups
|
|
|
181
153
|
|
|
182
154
|
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
155
|
|
|
184
|
-
**Minecraft Tunnels (v0.2.
|
|
156
|
+
**Minecraft Tunnels (v0.2.2+):**
|
|
185
157
|
|
|
186
158
|
The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
|
|
187
159
|
|
|
@@ -190,7 +162,7 @@ The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
|
|
|
190
162
|
asyx tunnel --minecraft
|
|
191
163
|
|
|
192
164
|
# Share the hostname with friends (no port needed!)
|
|
193
|
-
# Example:
|
|
165
|
+
# Example: example.tunnel.asyx.ai
|
|
194
166
|
```
|
|
195
167
|
|
|
196
168
|
**How it works:**
|
|
@@ -201,12 +173,12 @@ asyx tunnel --minecraft
|
|
|
201
173
|
**With a custom name:**
|
|
202
174
|
```bash
|
|
203
175
|
asyx tunnel --minecraft --name my-server
|
|
204
|
-
# Share: my-server.
|
|
176
|
+
# Share: my-server.example.tunnel.asyx.ai
|
|
205
177
|
```
|
|
206
178
|
|
|
207
179
|
**Technical details:**
|
|
208
180
|
- **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., `
|
|
181
|
+
- **Non-SRV-aware clients**: Use the `hostname:port` format (e.g., `example.tunnel.asyx.ai:10000`).
|
|
210
182
|
- **SRV record format**: `_minecraft._tcp.<host>` → target `<fqdn>`, port `<publicPort>`
|
|
211
183
|
- With `--name`: `_minecraft._tcp.<name>.<subdomain>.tunnel.asyx.ai`
|
|
212
184
|
- Without `--name`: `_minecraft._tcp.<subdomain>.tunnel.asyx.ai`
|
package/package.json
CHANGED
package/src/commands/tunnel.js
CHANGED
|
@@ -957,7 +957,7 @@ async function httpTunnel(localPort, secGroupSlug) {
|
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
|
|
960
|
-
async function connectToRelay(
|
|
960
|
+
export async function connectToRelay(
|
|
961
961
|
assignment,
|
|
962
962
|
deviceId,
|
|
963
963
|
localPort,
|
|
@@ -1019,6 +1019,26 @@ async function connectToRelay(
|
|
|
1019
1019
|
// TCP-S4: Skip refresh scheduling for TCP tunnels (refresh not implemented yet)
|
|
1020
1020
|
// HTTP tunnels continue to schedule refresh as before
|
|
1021
1021
|
// Note: This is a temporary limitation until TCP refresh is implemented
|
|
1022
|
+
if (mqttClient && assignment.jwt && assignment.leaseId) {
|
|
1023
|
+
try {
|
|
1024
|
+
// Decode JWT to get expiration timestamp (assignment doesn't store exp, must decode JWT)
|
|
1025
|
+
const parts = assignment.jwt.split('.');
|
|
1026
|
+
if (parts.length === 3) {
|
|
1027
|
+
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'));
|
|
1028
|
+
const expMs = payload.exp ? payload.exp * 1000 : null;
|
|
1029
|
+
if (expMs) {
|
|
1030
|
+
mqttClient.scheduleRefresh(expMs, assignment.leaseId);
|
|
1031
|
+
logger.debug('jwt.refresh.initial_scheduled', { expMs, leaseId: assignment.leaseId });
|
|
1032
|
+
} else {
|
|
1033
|
+
logger.warn('jwt.refresh.initial_failed', { reason: 'no_exp_in_jwt' });
|
|
1034
|
+
}
|
|
1035
|
+
} else {
|
|
1036
|
+
logger.warn('jwt.refresh.initial_failed', { reason: 'invalid_jwt_format' });
|
|
1037
|
+
}
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
logger.warn('jwt.refresh.initial_failed', { reason: 'jwt_decode_error', error: error.message });
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1022
1042
|
|
|
1023
1043
|
// QPA-CLI-11: Vault UX messaging - Final tunnel live message
|
|
1024
1044
|
const leaseMinutes = Math.floor(assignment.leaseMs / 60000);
|