pi-better-server 0.2.2 → 0.2.4
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/package.json +1 -1
- package/src/handshake.ts +1 -1
- package/src/shared-ssh-core/index.ts +30 -1
package/package.json
CHANGED
package/src/handshake.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ServerBuild } from "./startup/managed-types.ts";
|
|
|
4
4
|
import { PROTOCOL_VERSION, type HelloCommand, type HelloData } from "./protocol.ts";
|
|
5
5
|
|
|
6
6
|
/** Kept equal to package.json `version`; a test pins that. */
|
|
7
|
-
export const SERVER_VERSION = "0.2.
|
|
7
|
+
export const SERVER_VERSION = "0.2.4";
|
|
8
8
|
|
|
9
9
|
export const SERVER_EXTENSION_VERSIONS: Readonly<Record<string, string>> = { "pi-better-server": SERVER_VERSION };
|
|
10
10
|
|
|
@@ -90,6 +90,7 @@ export interface SshMuxControllerOptions extends ResolvedSshCommand {
|
|
|
90
90
|
runner: RemoteRunner;
|
|
91
91
|
sessionScope: string;
|
|
92
92
|
controlPathRoot?: string;
|
|
93
|
+
platform?: NodeJS.Platform;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
export interface SshMuxStatus {
|
|
@@ -101,7 +102,6 @@ export interface SshMuxStatus {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
export interface SshMuxEnsureResult extends SshMuxStatus {
|
|
104
|
-
state: "up";
|
|
105
105
|
reused: boolean;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -340,6 +340,35 @@ export function defaultSshControlPathRoot(): string {
|
|
|
340
340
|
*/
|
|
341
341
|
export function createSshMuxController(options: SshMuxControllerOptions): SshMuxController {
|
|
342
342
|
const sessionScope = requireValue(options.sessionScope, "ssh mux sessionScope is required").trim();
|
|
343
|
+
// Native Windows OpenSSH cannot provide a working ControlMaster socket.
|
|
344
|
+
if ((options.platform ?? process.platform) === "win32") {
|
|
345
|
+
const commandResult: CommandResult = {
|
|
346
|
+
exitCode: null, signal: null, stdout: "", stderr: "", startedAt: 0, endedAt: 0,
|
|
347
|
+
};
|
|
348
|
+
const disabled: SshMuxStatus = {
|
|
349
|
+
state: "down",
|
|
350
|
+
target: options.identity.target,
|
|
351
|
+
controlPath: "",
|
|
352
|
+
detail: "SSH multiplexing is disabled on Windows; commands use independent connections.",
|
|
353
|
+
commandResult,
|
|
354
|
+
};
|
|
355
|
+
const unsupportedForward = async (): Promise<SshMuxForwardResult> => {
|
|
356
|
+
throw new SshMuxError("SSH Unix socket forwarding is not supported on Windows without ControlMaster.", commandResult);
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
controlPath: "",
|
|
360
|
+
forwardUnixSocket: unsupportedForward,
|
|
361
|
+
cancelUnixSocketForward: unsupportedForward,
|
|
362
|
+
status: async () => disabled,
|
|
363
|
+
ensure: async () => ({ ...disabled, reused: false }),
|
|
364
|
+
cleanup: async () => ({ ...disabled, state: "not_running" }),
|
|
365
|
+
withMux: (commandSpec) => muxCommandSpec(commandSpec, options.identity.target, [
|
|
366
|
+
"-o", "ControlMaster=no",
|
|
367
|
+
"-o", "ControlPersist=no",
|
|
368
|
+
"-o", "ControlPath=none",
|
|
369
|
+
], true),
|
|
370
|
+
};
|
|
371
|
+
}
|
|
343
372
|
const controlPathRoot = resolve(options.controlPathRoot ?? defaultSshControlPathRoot());
|
|
344
373
|
const controlPath = join(controlPathRoot, `cm-${muxIdentityHash(options.identity, sessionScope)}`);
|
|
345
374
|
if (Buffer.byteLength(controlPath) > MAX_SSH_CONTROL_PATH_BYTES) {
|