@fish-under-sea/dsh-ssh-fish 1.0.2 → 2.0.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/NOTICE +1 -1
- package/README.en.md +7 -5
- package/README.md +7 -5
- package/README.zh.md +7 -5
- package/icon.png +0 -0
- package/lib/client.js +783 -170
- package/lib/client.js.map +1 -1
- package/lib/index.js +128 -14
- package/lib/types/client/api.d.ts +21 -0
- package/lib/types/client/locales.d.ts +13 -2
- package/lib/types/client/panel/TerminalTab.d.ts +12 -7
- package/lib/types/client/panel/controller.d.ts +185 -21
- package/lib/types/engine/connection-pool.d.ts +52 -1
- package/lib/types/engine.d.ts +7 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +18 -1
- package/lib/types/store.d.ts +7 -0
- package/lib/types/tool-surface.d.ts +1 -0
- package/lib/types/tools.d.ts +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +25 -22
- package/src/client/api.ts +70 -0
- package/src/client/index.ts +1 -2
- package/src/client/locales.ts +26 -4
- package/src/client/panel/HostFormDialog.tsx +16 -2
- package/src/client/panel/HostsTab.tsx +3 -0
- package/src/client/panel/SshPanel.tsx +7 -15
- package/src/client/panel/TerminalTab.tsx +371 -151
- package/src/client/panel/controller.ts +370 -30
- package/src/client/panel/panel.module.css +108 -0
- package/src/client/settings-binding.ts +0 -1
- package/src/engine/connection-pool.ts +96 -4
- package/src/engine.ts +10 -0
- package/src/index.ts +16 -1
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +18 -1
- package/src/routes.ts +4 -1
- package/src/store.ts +26 -0
- package/src/tool-surface.ts +1 -0
- package/src/tools.ts +9 -4
- package/icon.svg +0 -3
package/lib/index.js
CHANGED
|
@@ -216,6 +216,7 @@ function validateHostPayload(payload) {
|
|
|
216
216
|
const proxyJump = Array.isArray(p.proxyJump) ? p.proxyJump : [];
|
|
217
217
|
if (proxyCommand !== void 0 && proxyJump.length > 0) return "proxyCommand and proxyJump cannot be combined — pick one transport per host";
|
|
218
218
|
if (p.tags !== void 0 && (!Array.isArray(p.tags) || p.tags.some((x) => typeof x !== "string"))) return "tags must be an array of strings";
|
|
219
|
+
if (p.forwardAgent !== void 0 && typeof p.forwardAgent !== "boolean") return "forwardAgent must be a boolean";
|
|
219
220
|
}
|
|
220
221
|
/** Alias grammar: letters/digits plus dots, hyphens, underscores (IP/domain aliases included). */
|
|
221
222
|
const ALIAS_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
@@ -265,6 +266,7 @@ var HostStore = class {
|
|
|
265
266
|
...entry.environment !== void 0 ? { environment: entry.environment } : {},
|
|
266
267
|
tags: [...entry.tags],
|
|
267
268
|
...entry.location !== void 0 ? { location: entry.location } : {},
|
|
269
|
+
forwardAgent: entry.forwardAgent === true,
|
|
268
270
|
createdAt: entry.createdAt,
|
|
269
271
|
updatedAt: entry.updatedAt
|
|
270
272
|
};
|
|
@@ -299,6 +301,7 @@ var HostStore = class {
|
|
|
299
301
|
environment: payload.environment?.trim() || void 0,
|
|
300
302
|
tags: [...payload.tags ?? []].map((tag) => tag.trim()).filter((tag) => tag !== ""),
|
|
301
303
|
location: payload.location?.trim() || void 0,
|
|
304
|
+
forwardAgent: payload.forwardAgent === true ? true : void 0,
|
|
302
305
|
createdAt: now,
|
|
303
306
|
updatedAt: now
|
|
304
307
|
};
|
|
@@ -316,6 +319,7 @@ var HostStore = class {
|
|
|
316
319
|
if (patch.port !== void 0 && (typeof patch.port !== "number" || !Number.isInteger(patch.port) || patch.port < 1 || patch.port > 65535)) throw new Error("port must be an integer in 1..65535");
|
|
317
320
|
if (patch.proxyJump !== void 0 && (!Array.isArray(patch.proxyJump) || patch.proxyJump.some((x) => typeof x !== "string" || x === ""))) throw new Error("proxyJump must be an array of alias strings");
|
|
318
321
|
if (patch.proxyCommand !== void 0 && typeof patch.proxyCommand !== "string") throw new Error("proxyCommand must be a string when provided");
|
|
322
|
+
if (patch.forwardAgent !== void 0 && typeof patch.forwardAgent !== "boolean") throw new Error("forwardAgent must be a boolean");
|
|
319
323
|
const mergedProxyCommand = patch.proxyCommand !== void 0 ? normalizeProxyCommand(patch.proxyCommand) : entry.proxyCommand;
|
|
320
324
|
if (mergedProxyCommand !== void 0 && (patch.proxyJump ?? entry.proxyJump).length > 0) throw new Error("proxyCommand and proxyJump cannot be combined — pick one transport per host");
|
|
321
325
|
if (patch.tags !== void 0 && (!Array.isArray(patch.tags) || patch.tags.some((x) => typeof x !== "string"))) throw new Error("tags must be an array of strings");
|
|
@@ -343,6 +347,7 @@ var HostStore = class {
|
|
|
343
347
|
if (patch.environment !== void 0) entry.environment = patch.environment.trim() || void 0;
|
|
344
348
|
if (patch.tags !== void 0) entry.tags = [...patch.tags].map((tag) => tag.trim()).filter((tag) => tag !== "");
|
|
345
349
|
if (patch.location !== void 0) entry.location = patch.location.trim() || void 0;
|
|
350
|
+
if (patch.forwardAgent !== void 0) entry.forwardAgent = patch.forwardAgent === true ? true : void 0;
|
|
346
351
|
entry.updatedAt = Date.now();
|
|
347
352
|
this.save(file);
|
|
348
353
|
return entry;
|
|
@@ -410,7 +415,8 @@ var HostStore = class {
|
|
|
410
415
|
description: block.props.description,
|
|
411
416
|
environment: block.props.environment,
|
|
412
417
|
tags: (block.props.tags ?? "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== ""),
|
|
413
|
-
location: block.props.location
|
|
418
|
+
location: block.props.location,
|
|
419
|
+
forwardAgent: parseForwardAgentValue(block.props.forwardagent)
|
|
414
420
|
};
|
|
415
421
|
try {
|
|
416
422
|
this.create(payload);
|
|
@@ -500,6 +506,16 @@ function normalizeProxyCommand(raw) {
|
|
|
500
506
|
if (trimmed.toLowerCase() === "none") return void 0;
|
|
501
507
|
return trimmed;
|
|
502
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
|
|
511
|
+
* an explicit yes/true/on enables forwarding; an absent value, no/false/off,
|
|
512
|
+
* and anything unrecognized leave it off instead of failing the import — an
|
|
513
|
+
* unknown keyword must never cost the user the whole Host block.
|
|
514
|
+
*/
|
|
515
|
+
function parseForwardAgentValue(raw) {
|
|
516
|
+
const value = raw?.trim().toLowerCase();
|
|
517
|
+
return value === "yes" || value === "true" || value === "on";
|
|
518
|
+
}
|
|
503
519
|
/** Expand a leading `~` in a filesystem path. */
|
|
504
520
|
function expandHome(path) {
|
|
505
521
|
if (path === "~") return homedir();
|
|
@@ -713,10 +729,16 @@ function startProxyCommand(rawCommand, target) {
|
|
|
713
729
|
* Connection pool: per-alias persistent ssh2 connections with multi-hop jump
|
|
714
730
|
* support, the acquire / dispose / sweep lifecycle, and the pooled exec path.
|
|
715
731
|
*/
|
|
732
|
+
/**
|
|
733
|
+
* Default ceiling for TCP connect, SSH key exchange and user authentication
|
|
734
|
+
* together (ms). Password authentication behind PAM / LDAP can outlast the
|
|
735
|
+
* previous 15 s ceiling while the server still eventually accepts it.
|
|
736
|
+
*/
|
|
737
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
|
|
716
738
|
/** Default engine knobs (applied when an option is omitted). */
|
|
717
739
|
const DEFAULTS = {
|
|
718
740
|
idleTimeoutMs: 30 * 6e4,
|
|
719
|
-
connectTimeoutMs:
|
|
741
|
+
connectTimeoutMs: DEFAULT_CONNECT_TIMEOUT_MS,
|
|
720
742
|
keepaliveIntervalMs: 15e3,
|
|
721
743
|
maxOutputBytes: 2 * 1024 * 1024,
|
|
722
744
|
defaultExecTimeoutMs: 6e4,
|
|
@@ -746,21 +768,71 @@ function buildConnectConfig(entry, sock, opts) {
|
|
|
746
768
|
config.privateKey = readFileSync(keyPath, "utf8");
|
|
747
769
|
if (entry.auth.passphrase !== void 0 && entry.auth.passphrase !== "") config.passphrase = entry.auth.passphrase;
|
|
748
770
|
}
|
|
771
|
+
if (entry.forwardAgent === true) {
|
|
772
|
+
const agentPath = typeof config.agent === "string" ? config.agent : resolveForwardAgentPath(entry.auth.agentPath);
|
|
773
|
+
if (agentPath === void 0) throw new Error("agent forwarding is enabled for this host but no ssh-agent endpoint is available: set SSH_AUTH_SOCK, start Pageant on Windows, or configure an agent path");
|
|
774
|
+
config.agent = agentPath;
|
|
775
|
+
config.agentForward = true;
|
|
776
|
+
}
|
|
749
777
|
return config;
|
|
750
778
|
}
|
|
779
|
+
/**
|
|
780
|
+
* The default ssh-agent endpoint on Windows: the named pipe the native
|
|
781
|
+
* OpenSSH ssh-agent service listens on. ssh2 connects to a named pipe for any
|
|
782
|
+
* path matching its Windows pipe form, so the default is a real endpoint
|
|
783
|
+
* rather than a protocol name (#1910). PuTTY Pageant is still reachable — it
|
|
784
|
+
* is what the literal `pageant` agent path selects — but it is no longer the
|
|
785
|
+
* assumption.
|
|
786
|
+
*/
|
|
787
|
+
const WINDOWS_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
|
|
751
788
|
/** Resolve the ssh2 agent path for 'agent' auth. */
|
|
752
789
|
function resolveAgentPath(agentPath) {
|
|
753
790
|
const explicit = normalizeAgentPath(agentPath);
|
|
754
791
|
if (explicit !== void 0) return explicit;
|
|
755
792
|
const sock = process.env.SSH_AUTH_SOCK;
|
|
756
793
|
if (sock !== void 0 && sock !== "") return sock;
|
|
757
|
-
if (process.platform === "win32") return
|
|
794
|
+
if (process.platform === "win32") return WINDOWS_AGENT_PIPE;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Resolve the ssh-agent endpoint that forwarding brokers signatures through:
|
|
798
|
+
* an explicitly configured agent path wins, then SSH_AUTH_SOCK, then the
|
|
799
|
+
* native OpenSSH named pipe on Windows. Undefined means no endpoint exists on
|
|
800
|
+
* this machine.
|
|
801
|
+
*
|
|
802
|
+
* Forwarding shares the auth resolution on purpose — the endpoint a host
|
|
803
|
+
* signs through is the same one it authenticates with — but it is a separate
|
|
804
|
+
* name so the forwarding path can evolve without touching auth.
|
|
805
|
+
*/
|
|
806
|
+
function resolveForwardAgentPath(agentPath) {
|
|
807
|
+
return resolveAgentPath(agentPath);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Name the phase that actually stalled. ssh2 reports every pre-ready timeout
|
|
811
|
+
* as "Timed out while waiting for handshake", including one that expires
|
|
812
|
+
* during user authentication after a completed key exchange.
|
|
813
|
+
*
|
|
814
|
+
* @param timeoutMs - the configured `readyTimeout` (0 disables it).
|
|
815
|
+
* @param handshakeComplete - whether ssh2 completed the key exchange.
|
|
816
|
+
* @returns the operator-facing timeout message.
|
|
817
|
+
*/
|
|
818
|
+
function readyTimeoutMessage(timeoutMs, handshakeComplete) {
|
|
819
|
+
const budget = typeof timeoutMs === "number" && timeoutMs > 0 ? " after " + timeoutMs + " ms" : "";
|
|
820
|
+
return handshakeComplete ? "SSH authentication timed out" + budget + ": TCP connect and key exchange completed, but the server did not finish authenticating the user - raise the dsh-ssh connectTimeoutMs setting if this host is slow" : "SSH connection timed out" + budget + " before key exchange completed: TCP connect or the SSH key exchange did not finish - raise the dsh-ssh connectTimeoutMs setting if this host is slow";
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Whether ssh2 ended the attempt with its pre-ready timeout. The level is the
|
|
824
|
+
* stable discriminator; the message is reused for connect, key exchange and
|
|
825
|
+
* authentication alike.
|
|
826
|
+
*/
|
|
827
|
+
function isReadyTimeout(error) {
|
|
828
|
+
return error.level === "client-timeout";
|
|
758
829
|
}
|
|
759
830
|
/** Connect one ssh2 client (resolve on ready, reject on error/close). */
|
|
760
831
|
function connectClient(config, onKeyboardInteractive) {
|
|
761
832
|
return new Promise((resolve, reject) => {
|
|
762
833
|
const client = new Client();
|
|
763
834
|
let settled = false;
|
|
835
|
+
let handshakeComplete = false;
|
|
764
836
|
const fail = (error) => {
|
|
765
837
|
if (settled) return;
|
|
766
838
|
settled = true;
|
|
@@ -771,8 +843,12 @@ function connectClient(config, onKeyboardInteractive) {
|
|
|
771
843
|
try {
|
|
772
844
|
client.destroy();
|
|
773
845
|
} catch {}
|
|
774
|
-
|
|
846
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
847
|
+
reject(isReadyTimeout(cause) ? new Error(readyTimeoutMessage(config.readyTimeout, handshakeComplete)) : cause);
|
|
775
848
|
};
|
|
849
|
+
client.once("handshake", () => {
|
|
850
|
+
handshakeComplete = true;
|
|
851
|
+
});
|
|
776
852
|
client.once("ready", () => {
|
|
777
853
|
if (settled) return;
|
|
778
854
|
settled = true;
|
|
@@ -865,6 +941,12 @@ function parseJumpSpec(spec) {
|
|
|
865
941
|
* Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
|
|
866
942
|
* other value is read as an OpenSSH address whose credentials come from the
|
|
867
943
|
* target entry (an ad-hoc hop has no stored auth of its own).
|
|
944
|
+
*
|
|
945
|
+
* An address hop deliberately carries no forwardAgent flag: OpenSSH's
|
|
946
|
+
* ForwardAgent is a per-Host setting and an ad-hoc address was never
|
|
947
|
+
* configured, so it must never inherit the target's opt-in. A hop written as
|
|
948
|
+
* an alias uses that alias's own entry, which is how a user forwards on a
|
|
949
|
+
* bastion on purpose.
|
|
868
950
|
*/
|
|
869
951
|
function resolveHop(engine, entry, spec) {
|
|
870
952
|
const configured = engine.store.find(spec);
|
|
@@ -1663,6 +1745,15 @@ var SshEngine = class {
|
|
|
1663
1745
|
this.sweepTimer = setInterval(() => sweepPool(this), Math.max(1e4, this.opts.idleTimeoutMs / 4));
|
|
1664
1746
|
this.sweepTimer.unref?.();
|
|
1665
1747
|
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Change the pre-ready ceiling (TCP connect + key exchange + user
|
|
1750
|
+
* authentication) for connections opened from now on. A pooled connection
|
|
1751
|
+
* keeps serving until it reconnects, because the ceiling governs the
|
|
1752
|
+
* connect path only.
|
|
1753
|
+
*/
|
|
1754
|
+
setConnectTimeout(timeoutMs) {
|
|
1755
|
+
this.opts.connectTimeoutMs = timeoutMs;
|
|
1756
|
+
}
|
|
1666
1757
|
/** Secret-free host list (filtered by the optional query). */
|
|
1667
1758
|
list(query) {
|
|
1668
1759
|
const needle = query?.trim().toLowerCase();
|
|
@@ -2088,12 +2179,26 @@ function isLoopbackHostname(hostname) {
|
|
|
2088
2179
|
return isIPv4Loopback(hostname);
|
|
2089
2180
|
}
|
|
2090
2181
|
/**
|
|
2182
|
+
* Whether a reverse proxy stood between the client and this host: the request
|
|
2183
|
+
* carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
|
|
2184
|
+
* hop that forwards traffic, so the request did not originate on this machine.
|
|
2185
|
+
* @param request - node HTTP request.
|
|
2186
|
+
* @returns true when a forwarding header is present.
|
|
2187
|
+
*/
|
|
2188
|
+
function isProxiedRequest(request) {
|
|
2189
|
+
return request.headers["cf-connecting-ip"] !== void 0 || request.headers["x-forwarded-for"] !== void 0;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2091
2192
|
* Request-level trust fence: a loopback socket address AND a loopback Host
|
|
2092
2193
|
* header, plus browser same-origin markers. The socket address is
|
|
2093
|
-
* authoritative;
|
|
2194
|
+
* authoritative for a direct connection; a request that carries a forwarding
|
|
2195
|
+
* header is refused outright, because a proxy in front of the host makes both
|
|
2196
|
+
* the socket address and the Host header describe the proxy rather than the
|
|
2197
|
+
* client. X-Forwarded-For is therefore never evidence *for* loopback.
|
|
2094
2198
|
*/
|
|
2095
2199
|
function isLoopbackRequest(request) {
|
|
2096
2200
|
if (!isLoopbackAddress(request.socket.remoteAddress)) return false;
|
|
2201
|
+
if (isProxiedRequest(request)) return false;
|
|
2097
2202
|
const host = request.headers.host;
|
|
2098
2203
|
if (typeof host !== "string") return false;
|
|
2099
2204
|
let hostUrl;
|
|
@@ -2227,7 +2332,8 @@ function makeRoutes(deps) {
|
|
|
2227
2332
|
"user",
|
|
2228
2333
|
"auth",
|
|
2229
2334
|
"proxyJump",
|
|
2230
|
-
"proxyCommand"
|
|
2335
|
+
"proxyCommand",
|
|
2336
|
+
"forwardAgent"
|
|
2231
2337
|
].some((key) => patch[key] !== void 0)) engine.dropAlias(alias);
|
|
2232
2338
|
writeJson(res, 200, { host: store.summarize(entry) });
|
|
2233
2339
|
} catch (error) {
|
|
@@ -2632,8 +2738,8 @@ function toAgentHostRow(host) {
|
|
|
2632
2738
|
function renderHosts(hosts) {
|
|
2633
2739
|
if (hosts.length === 0) return "no hosts configured";
|
|
2634
2740
|
return [
|
|
2635
|
-
"alias | host | port | user | auth | proxy | environment | tags | description",
|
|
2636
|
-
"--- | --- | --- | --- | --- | --- | --- | --- | ---",
|
|
2741
|
+
"alias | host | port | user | auth | proxy | forward | environment | tags | description",
|
|
2742
|
+
"--- | --- | --- | --- | --- | --- | --- | --- | --- | ---",
|
|
2637
2743
|
...hosts.map((host) => [
|
|
2638
2744
|
host.alias,
|
|
2639
2745
|
host.host,
|
|
@@ -2641,6 +2747,7 @@ function renderHosts(hosts) {
|
|
|
2641
2747
|
host.user,
|
|
2642
2748
|
host.auth,
|
|
2643
2749
|
host.proxyJump.length > 0 ? "jump:" + host.proxyJump.join(",") : host.proxyCommandConfigured ? "proxy-command" : "-",
|
|
2750
|
+
host.forwardAgent ? "yes" : "-",
|
|
2644
2751
|
host.environment ?? "-",
|
|
2645
2752
|
host.tags.length > 0 ? host.tags.join(",") : "-",
|
|
2646
2753
|
host.description ?? ""
|
|
@@ -2673,7 +2780,7 @@ function renderTunnel(tunnel) {
|
|
|
2673
2780
|
function sshListTool(engine) {
|
|
2674
2781
|
return defineTool({
|
|
2675
2782
|
name: "ssh_list",
|
|
2676
|
-
description: "List configured SSH hosts (alias, host, user, auth, environment, tags, description). Use ssh_exec etc. with the alias.",
|
|
2783
|
+
description: "List configured SSH hosts (alias, host, user, auth, agent forwarding, environment, tags, description). Use ssh_exec etc. with the alias.",
|
|
2677
2784
|
parameters: { query: {
|
|
2678
2785
|
type: "string",
|
|
2679
2786
|
description: "Optional fuzzy match against alias, description, host, and tags."
|
|
@@ -2727,6 +2834,10 @@ function sshListTool(engine) {
|
|
|
2727
2834
|
type: "boolean",
|
|
2728
2835
|
required: true
|
|
2729
2836
|
},
|
|
2837
|
+
forwardAgent: {
|
|
2838
|
+
type: "boolean",
|
|
2839
|
+
required: true
|
|
2840
|
+
},
|
|
2730
2841
|
description: { type: "string" },
|
|
2731
2842
|
environment: { type: "string" },
|
|
2732
2843
|
tags: {
|
|
@@ -2773,7 +2884,7 @@ function sshExecTool(engine) {
|
|
|
2773
2884
|
},
|
|
2774
2885
|
timeoutMs: {
|
|
2775
2886
|
type: "integer",
|
|
2776
|
-
description: "
|
|
2887
|
+
description: "Remote command execution timeout in milliseconds (default 60000); it starts after the connection is ready. The connection and authentication ceiling is the dsh-ssh connectTimeoutMs setting, not this argument."
|
|
2777
2888
|
}
|
|
2778
2889
|
},
|
|
2779
2890
|
output: {
|
|
@@ -3156,7 +3267,7 @@ function sshClusterTool(engine) {
|
|
|
3156
3267
|
},
|
|
3157
3268
|
timeoutMs: {
|
|
3158
3269
|
type: "integer",
|
|
3159
|
-
description: "Per-host timeout in milliseconds."
|
|
3270
|
+
description: "Per-host command execution timeout in milliseconds (default 60000); it does not extend the connection and authentication ceiling (the dsh-ssh connectTimeoutMs setting)."
|
|
3160
3271
|
},
|
|
3161
3272
|
maxWorkers: {
|
|
3162
3273
|
type: "integer",
|
|
@@ -3350,7 +3461,8 @@ function mountOnce(packageName, fn) {
|
|
|
3350
3461
|
*/
|
|
3351
3462
|
const PLUGIN_TOOL_SECTION_ORDERS = {
|
|
3352
3463
|
ssh: 150,
|
|
3353
|
-
"task-board": 200
|
|
3464
|
+
"task-board": 200,
|
|
3465
|
+
agents: 220
|
|
3354
3466
|
};
|
|
3355
3467
|
/**
|
|
3356
3468
|
* Build a section provider that renders \`text\` only while at least one of
|
|
@@ -3398,7 +3510,8 @@ const inject = [
|
|
|
3398
3510
|
const Config = z.object({
|
|
3399
3511
|
announceToAgent: z.boolean().default(false).volatile(),
|
|
3400
3512
|
enabled: z.boolean().default(true).volatile(),
|
|
3401
|
-
terminalFontFamily: z.string().default("").volatile()
|
|
3513
|
+
terminalFontFamily: z.string().default("").volatile(),
|
|
3514
|
+
connectTimeoutMs: z.number().step(1).min(1e3).max(6e5).default(DEFAULT_CONNECT_TIMEOUT_MS).volatile().description("TCP connect, SSH key exchange and user authentication timeout in milliseconds; raise it for hosts whose authentication is slow.")
|
|
3402
3515
|
});
|
|
3403
3516
|
/** Schema defaults, re-read for hand-built test contexts (the loader applies them normally). */
|
|
3404
3517
|
const DEFAULT_ANNOUNCE = false;
|
|
@@ -3439,7 +3552,7 @@ const SSH_GUIDANCE = "本机已安装 dsh-ssh 插件(DSH 远程 SSH 运维)
|
|
|
3439
3552
|
const apply = mountOnce("@fish-under-sea/dsh-ssh-fish", applyImpl);
|
|
3440
3553
|
function applyImpl(ctx, config) {
|
|
3441
3554
|
const store = new HostStore();
|
|
3442
|
-
const engine = new SshEngine(store);
|
|
3555
|
+
const engine = new SshEngine(store, { connectTimeoutMs: readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS) });
|
|
3443
3556
|
ctx.effect(() => () => {
|
|
3444
3557
|
engine.dispose();
|
|
3445
3558
|
}, "dsh-ssh: engine");
|
|
@@ -3467,6 +3580,7 @@ function applyImpl(ctx, config) {
|
|
|
3467
3580
|
let disposeTools;
|
|
3468
3581
|
let disposeSection;
|
|
3469
3582
|
const sync = () => {
|
|
3583
|
+
engine.setConnectTimeout(readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS));
|
|
3470
3584
|
const value = resolve();
|
|
3471
3585
|
if (disposeSection !== void 0) {
|
|
3472
3586
|
disposeSection();
|
|
@@ -135,6 +135,27 @@ export declare class SshApi {
|
|
|
135
135
|
* @param rows - the view's current height.
|
|
136
136
|
*/
|
|
137
137
|
attachTerminal(sessionId: string, cols: number, rows: number): TerminalConnection;
|
|
138
|
+
/**
|
|
139
|
+
* End a host session this view is not attached to (closing a background
|
|
140
|
+
* tab). The session has no other handle from the browser: giving it a
|
|
141
|
+
* dedicated HTTP route would widen the host's surface for one frame, so this
|
|
142
|
+
* opens one short-lived attach instead and sends the close frame as soon as
|
|
143
|
+
* the socket is open.
|
|
144
|
+
*
|
|
145
|
+
* The answer is "is this session no longer running", which has three
|
|
146
|
+
* truthful answers and one lie to avoid:
|
|
147
|
+
* - the frame went out on an open socket: the host ends the session;
|
|
148
|
+
* - the host answered with an exit frame: an unknown id is reported as
|
|
149
|
+
* `terminal session expired` and an ended shell also exits, and in both
|
|
150
|
+
* cases nothing is running, so the tab really is closed;
|
|
151
|
+
* - the socket errored, closed before opening, or never settled inside
|
|
152
|
+
* `timeoutMs`: delivery is unproven, so the session may still be alive and
|
|
153
|
+
* the caller must keep the tab instead of claiming it closed.
|
|
154
|
+
* @param sessionId - the session id the host reported on its ready frame.
|
|
155
|
+
* @param timeoutMs - bounded wait for the delivery signal (default 5000).
|
|
156
|
+
* @returns true when the session is known to be gone.
|
|
157
|
+
*/
|
|
158
|
+
closeTerminalSession(sessionId: string, timeoutMs?: number): Promise<boolean>;
|
|
138
159
|
/** One terminal socket over either an alias (open) or a session id (attach). */
|
|
139
160
|
private terminalSocket;
|
|
140
161
|
}
|
|
@@ -37,6 +37,8 @@ export declare const zh: {
|
|
|
37
37
|
readonly 'hosts.deleteConfirm': "确定删除主机「{alias}」?将同时停止其隧道。";
|
|
38
38
|
readonly 'hosts.imported': "解析 {parsed} 个配置块,新增 {added} 台主机,跳过 {skipped} 个。";
|
|
39
39
|
readonly 'hosts.proxyBadge': "代理";
|
|
40
|
+
readonly 'hosts.forwardAgentBadge': "Agent 转发";
|
|
41
|
+
readonly 'hosts.forwardAgentHint': "仅对可信主机开启:远端可用本机私钥签名(等价 ssh -A)。";
|
|
40
42
|
readonly 'import.reason.wildcard': "通配符 pattern,需手动配置";
|
|
41
43
|
readonly 'import.reason.existing': "别名已存在";
|
|
42
44
|
readonly 'import.reason.match': "Match 条件块,不支持";
|
|
@@ -59,8 +61,8 @@ export declare const zh: {
|
|
|
59
61
|
readonly 'form.auth.password': "密码";
|
|
60
62
|
readonly 'form.auth.agent': "SSH Agent";
|
|
61
63
|
readonly 'form.agentPath': "Agent 路径";
|
|
62
|
-
readonly 'form.agentPathHint': "留空自动检测(SSH_AUTH_SOCK
|
|
63
|
-
readonly 'form.authKeepHint': "
|
|
64
|
+
readonly 'form.agentPathHint': "留空自动检测(SSH_AUTH_SOCK;Windows 上为原生 ssh-agent 命名管道);也可填 socket 路径或 pageant";
|
|
65
|
+
readonly 'form.authKeepHint': "编辑时密码 / 私钥留空将保留已存凭据;Agent 路径留空是合法的自动检测,选「SSH Agent」即切换到 agent 认证。";
|
|
64
66
|
readonly 'form.keyPath': "私钥路径";
|
|
65
67
|
readonly 'form.keyPathHint': "如 ~/.ssh/id_ed25519";
|
|
66
68
|
readonly 'form.passphrase': "密钥口令";
|
|
@@ -71,6 +73,8 @@ export declare const zh: {
|
|
|
71
73
|
readonly 'form.proxyJumpHint': "逗号分隔的本地主机别名,或 [user@]host[:port] 地址,按顺序连接";
|
|
72
74
|
readonly 'form.proxyCommand': "ProxyCommand";
|
|
73
75
|
readonly 'form.proxyCommandHint': "OpenSSH ProxyCommand:%h 主机、%p 端口、%r 用户、%n 别名;留空或填 none 表示不使用。与跳板机别名互斥。";
|
|
76
|
+
readonly 'form.forwardAgent': "启用 Agent 转发";
|
|
77
|
+
readonly 'form.forwardAgentHint': "把本机 SSH Agent 转发到该主机(等价 ssh -A):远端可用本机私钥签名。仅对可信主机开启。";
|
|
74
78
|
readonly 'form.description': "备注";
|
|
75
79
|
readonly 'form.environment': "环境";
|
|
76
80
|
readonly 'form.environmentHint': "如 development / production";
|
|
@@ -95,6 +99,13 @@ export declare const zh: {
|
|
|
95
99
|
readonly 'terminal.auth.cancel': "取消";
|
|
96
100
|
readonly 'terminal.auth.placeholder': "请输入验证码或口令";
|
|
97
101
|
readonly 'terminal.auth.hint': "服务器请求进行交互式二次验证(输入仅本次生效,不落盘):";
|
|
102
|
+
readonly 'terminal.tabs': "终端标签";
|
|
103
|
+
readonly 'terminal.newTab': "按当前主机新开标签";
|
|
104
|
+
readonly 'terminal.closeTab': "关闭标签";
|
|
105
|
+
readonly 'terminal.authPending': "待验证";
|
|
106
|
+
readonly 'terminal.tabExited': "已退出";
|
|
107
|
+
readonly 'terminal.tabError': "出错";
|
|
108
|
+
readonly 'terminal.closeFailed': "无法确认该标签已关闭:关闭帧未送达宿主。标签已保留——可重试,或切到该标签前台,用它自己的连接关闭。";
|
|
98
109
|
readonly 'transfer.selectHost': "选择主机";
|
|
99
110
|
readonly 'transfer.remotePath': "远程路径";
|
|
100
111
|
readonly 'transfer.remotePathHint': "如 /tmp/ 或 /home/user/app.tar.gz";
|
|
@@ -4,19 +4,24 @@ import { type TerminalFontSource } from './helpers.ts';
|
|
|
4
4
|
/** Terminal tab props. */
|
|
5
5
|
export interface TerminalTabProps {
|
|
6
6
|
api: SshApi;
|
|
7
|
-
/** The panel controller that owns the
|
|
7
|
+
/** The panel controller that owns the tabs and their host session ids. */
|
|
8
8
|
controller: PanelController;
|
|
9
|
-
/** Host session to reattach to on mount (survives a panel switch). */
|
|
10
|
-
sessionId?: string;
|
|
11
9
|
/** Alias preselected by a "connect" action from the hosts tab. */
|
|
12
10
|
presetAlias?: string;
|
|
13
|
-
/** Monotonic id of the connect request (re-applies presetAlias). */
|
|
14
|
-
requestId?: number;
|
|
15
11
|
/**
|
|
16
12
|
* Live terminal-font setting source (issue #577). Absent in tests and
|
|
17
13
|
* legacy mounts: the font then comes from the CSS custom-property chain.
|
|
18
14
|
*/
|
|
19
15
|
terminalFont?: TerminalFontSource;
|
|
20
16
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Whether the visible challenge form may answer on the bound socket: the form
|
|
19
|
+
* and the socket must belong to the same tab. Both are read at submit time, and
|
|
20
|
+
* the window between a tab switch's commit and the effect that rebinds the
|
|
21
|
+
* socket is exactly when they can disagree.
|
|
22
|
+
* @param linkTabId - the tab the bound socket belongs to.
|
|
23
|
+
* @param formTabId - the tab whose challenge form is on screen.
|
|
24
|
+
*/
|
|
25
|
+
export declare function challengeBelongsToLink(linkTabId: string | undefined, formTabId: string | undefined): boolean;
|
|
26
|
+
/** The terminal view with its tab strip. */
|
|
27
|
+
export declare function TerminalTab({ api, controller, presetAlias, terminalFont }: TerminalTabProps): import("react").JSX.Element;
|