airloom 0.1.32 → 0.1.33
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/dist/index.js +14 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2176,8 +2176,8 @@ function parseRelayUrl(value) {
|
|
|
2176
2176
|
}
|
|
2177
2177
|
return parsed.toString();
|
|
2178
2178
|
}
|
|
2179
|
-
function parseHostBind(value, isDev) {
|
|
2180
|
-
const bind = value?.trim() || (isDev ? "0.0.0.0" : DEFAULT_HOST_BIND);
|
|
2179
|
+
function parseHostBind(value, isDev, isSSH) {
|
|
2180
|
+
const bind = value?.trim() || (isDev || isSSH ? "0.0.0.0" : DEFAULT_HOST_BIND);
|
|
2181
2181
|
if (bind === "localhost" || isIP(bind) !== 0) return bind;
|
|
2182
2182
|
if (/^[A-Za-z0-9.-]+$/.test(bind)) return bind;
|
|
2183
2183
|
throw new Error("HOST_BIND must be localhost, an IP address, or a hostname");
|
|
@@ -2186,11 +2186,12 @@ function isLoopbackBind(bind) {
|
|
|
2186
2186
|
return bind === "127.0.0.1" || bind === "::1" || bind === "localhost";
|
|
2187
2187
|
}
|
|
2188
2188
|
function parseHostEnv(cliPort, isDev = false) {
|
|
2189
|
+
const isSSH = !!(process.env.SSH_CONNECTION || process.env.SSH_TTY || process.env.SSH_CLIENT);
|
|
2189
2190
|
const relayUrl = parseRelayUrl(process.env.RELAY_URL);
|
|
2190
2191
|
const ablyApiKey = process.env.ABLY_API_KEY ?? (relayUrl ? void 0 : DEFAULT_ABLY_KEY);
|
|
2191
2192
|
const ablyTokenTtlMs = parseInteger("ABLY_TOKEN_TTL", process.env.ABLY_TOKEN_TTL, DEFAULT_ABLY_TOKEN_TTL_MS, 6e4, 31 * 24 * 60 * 60 * 1e3);
|
|
2192
2193
|
const hostPort = cliPort ?? parseInteger("HOST_PORT", process.env.HOST_PORT, DEFAULT_HOST_PORT, 0, 65535);
|
|
2193
|
-
const hostBind = parseHostBind(process.env.HOST_BIND, isDev);
|
|
2194
|
+
const hostBind = parseHostBind(process.env.HOST_BIND, isDev, isSSH);
|
|
2194
2195
|
const viewerUrl = parseViewerUrl(process.env.VIEWER_URL);
|
|
2195
2196
|
return {
|
|
2196
2197
|
viewerUrl,
|
|
@@ -2200,7 +2201,8 @@ function parseHostEnv(cliPort, isDev = false) {
|
|
|
2200
2201
|
hostPort,
|
|
2201
2202
|
hostBind,
|
|
2202
2203
|
useAbly: !!ablyApiKey,
|
|
2203
|
-
isDefaultAblyKey: !!ablyApiKey && ablyApiKey === DEFAULT_ABLY_KEY
|
|
2204
|
+
isDefaultAblyKey: !!ablyApiKey && ablyApiKey === DEFAULT_ABLY_KEY,
|
|
2205
|
+
isSSH
|
|
2204
2206
|
};
|
|
2205
2207
|
}
|
|
2206
2208
|
|
|
@@ -2517,12 +2519,15 @@ async function main() {
|
|
|
2517
2519
|
if (lanViewerUrl) console.log(`LAN Viewer: ${lanViewerUrl}`);
|
|
2518
2520
|
}
|
|
2519
2521
|
if (!useAbly) console.log(`Relay: ${RELAY_URL}`);
|
|
2520
|
-
const
|
|
2521
|
-
const controlUrl = encodeControlUrl(
|
|
2522
|
+
const controlBase = isLoopbackBind(HOST_BIND) ? `http://localhost:${port}` : lanBaseUrl;
|
|
2523
|
+
const controlUrl = encodeControlUrl(controlBase, controlToken);
|
|
2522
2524
|
console.log(`Host UI: ${controlUrl}`);
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2525
|
+
if (env.isSSH) {
|
|
2526
|
+
if (isLoopbackBind(HOST_BIND)) {
|
|
2527
|
+
console.log("\n (SSH session detected but server is bound to localhost \u2014 set HOST_BIND=0.0.0.0 to allow remote access)");
|
|
2528
|
+
} else {
|
|
2529
|
+
console.log("\n (SSH session \u2014 open the Host UI URL above in a browser on your local machine)");
|
|
2530
|
+
}
|
|
2526
2531
|
} else {
|
|
2527
2532
|
import("node:child_process").then(({ exec }) => {
|
|
2528
2533
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|