Compare commits

...
Author SHA1 Message Date
paseo-bot[bot] 217223b1e6 fix(cli): explain how to connect to TLS endpoints
A bare host and port selects plaintext WebSocket. A TLS proxy that replies with HTTP 400 leaves the user with generic connection advice, even though the same address works with wss://.
2026-11-30 03:58:26 +00:00
3 changed files with 43 additions and 5 deletions
+8 -2
View File
@@ -56,17 +56,23 @@ export function buildDaemonConnectionCommandError(options: ConnectOptions & { er
message: message.startsWith("Cannot connect to daemon at ")
? message
: `Cannot connect to daemon at ${describeDaemonTarget(options.target)}: ${message}`,
details: describeConnectionRemedy(code, options.target),
details: describeConnectionRemedy(code, options.target, message),
};
}
function describeConnectionRemedy(code: string, target: DaemonTarget): string {
function describeConnectionRemedy(code: string, target: DaemonTarget, message: string): string {
if (code === "AUTH_REQUIRED")
return "The daemon requires a password. Set PASEO_PASSWORD and retry.";
if (code === "AUTH_FAILED")
return "The daemon rejected the password. Check PASEO_PASSWORD and retry.";
if (target.kind === "instance")
return `Start with: paseo daemon start --home ${JSON.stringify(target.home)}`;
const host = target.host.trim();
if (
message === "Unexpected server response: 400" &&
/^(?:[\w.-]+|\[[\da-f:.]+\]):\d+$/i.test(host)
)
return `The endpoint returned HTTP 400 to a plaintext WebSocket request. If this endpoint uses TLS, use wss://${host}.`;
return "Check the selected endpoint and credentials. SSH transport does not install or start the daemon.";
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { selectDaemonTarget } from "./daemon-target.js";
const JSON_OPTION_DESCRIPTION = "Output in JSON format";
const DAEMON_HOST_OPTION_DESCRIPTION =
"Explicit daemon endpoint: host:port, TCP, socket, SSH, or pairing URL (default: local home)";
"Explicit daemon endpoint: host:port, TCP, socket, SSH, or pairing URL (default: local home). For TLS, use wss://host:port.";
const localCommands = new WeakSet<Command>();
+34 -2
View File
@@ -20,6 +20,8 @@
*/
import assert from "node:assert";
import { once } from "node:events";
import { createServer } from "node:http";
import { mkdtemp, rm } from "fs/promises";
import { tmpdir } from "os";
import { join } from "path";
@@ -179,9 +181,39 @@ try {
console.log("✓ global --host targets the requested daemon\n");
}
// Test 11: conflicting explicit --host selectors are rejected
// Test 11: a bare endpoint that returns HTTP 400 gets TLS guidance
{
console.log("Test 11: conflicting explicit --host selectors are rejected");
const server = createServer((_request, response) => {
response.writeHead(400).end();
});
server.listen(0, "127.0.0.1");
try {
await once(server, "listening");
const address = server.address();
assert(address && typeof address !== "string");
const host = `127.0.0.1:${address.port}`;
const result = await runLocalPaseo(["--host", host, "ls"], { PASEO_HOME: paseoHome });
assert.strictEqual(result.exitCode, 1);
assert.match(result.stderr, /Unexpected server response: 400/);
assert(result.stderr.includes(`If this endpoint uses TLS, use wss://${host}`));
const explicit = await runLocalPaseo(["--host", `ws://${host}`, "ls"], {
PASEO_HOME: paseoHome,
});
assert.strictEqual(explicit.exitCode, 1);
assert.match(explicit.stderr, /Unexpected server response: 400/);
assert(!explicit.stderr.includes("If this endpoint uses TLS"));
const help = await runLocalPaseo(["ls", "--help"]);
assert.strictEqual(help.exitCode, 0);
assert.match(help.stdout, /For TLS, use\s+wss:\/\/host:port/);
} finally {
server.close();
}
}
// Test 12: conflicting explicit --host selectors are rejected
{
console.log("Test 12: conflicting explicit --host selectors are rejected");
const firstHost = `localhost:${port}`;
const lastHost = `localhost:${await getAvailablePort()}`;
const result = await runLocalPaseo(["--host", firstHost, "ls", "--host", lastHost]);