@linxin666/dsh-ssh 0.4.8 → 0.4.10
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.i18n.yaml +2 -2
- package/README.md +6 -6
- package/README.zh.md +6 -6
- package/lib/client.js +6 -6
- package/lib/client.js.map +1 -1
- package/lib/index.js +64 -10
- package/lib/types/client/locales.d.ts +2 -2
- package/lib/types/engine/connection-pool.d.ts +38 -3
- package/lib/types/engine.d.ts +7 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/loopback.d.ts +21 -0
- package/lib/types/protocol.d.ts +1 -1
- package/lib/types/tool-surface.d.ts +1 -0
- package/package.json +17 -17
- package/src/client/locales.ts +4 -4
- package/src/client/panel/HostFormDialog.tsx +5 -2
- package/src/engine/connection-pool.ts +60 -6
- package/src/engine.ts +10 -0
- package/src/index.ts +16 -1
- package/src/loopback.ts +32 -0
- package/src/protocol.ts +1 -1
- package/src/tool-surface.ts +1 -0
- package/src/tools.ts +2 -2
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {} from '@deepseek-ai/dsh-host-webserver'
|
|
|
14
14
|
import type {} from '@deepseek-ai/dsh-system-prompt'
|
|
15
15
|
import type {} from '@deepseek-ai/dsh-tools'
|
|
16
16
|
import { SshEngine } from './engine.ts'
|
|
17
|
+
import { DEFAULT_CONNECT_TIMEOUT_MS } from './engine/connection-pool.ts'
|
|
17
18
|
import { makeRoutes } from './routes.ts'
|
|
18
19
|
import { HostStore } from './store.ts'
|
|
19
20
|
import { sshClusterTool, sshDownloadTool, sshExecTool, sshListTool, sshTunnelTool, sshUploadTool } from './tools.ts'
|
|
@@ -54,6 +55,13 @@ export interface Config {
|
|
|
54
55
|
* Nerd Font stack here to render powerline/Nerd glyphs.
|
|
55
56
|
*/
|
|
56
57
|
terminalFontFamily?: string
|
|
58
|
+
/**
|
|
59
|
+
* Ceiling for the whole pre-ready SSH sequence in milliseconds: TCP
|
|
60
|
+
* connect, key exchange and user authentication (default 30000). Raise it
|
|
61
|
+
* for hosts whose password authentication is slow (for example PAM / LDAP
|
|
62
|
+
* behind a distant directory service).
|
|
63
|
+
*/
|
|
64
|
+
connectTimeoutMs?: number
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
/** The stable reference a `volatile()` config field resolves to; its owner updates it in place. */
|
|
@@ -70,6 +78,7 @@ export interface ResolvedConfig {
|
|
|
70
78
|
announceToAgent?: ConfigField<boolean>
|
|
71
79
|
enabled?: ConfigField<boolean>
|
|
72
80
|
terminalFontFamily?: ConfigField<string>
|
|
81
|
+
connectTimeoutMs?: ConfigField<number>
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
/**
|
|
@@ -84,6 +93,8 @@ export const Config = z.object({
|
|
|
84
93
|
announceToAgent: z.boolean().default(false).volatile(),
|
|
85
94
|
enabled: z.boolean().default(true).volatile(),
|
|
86
95
|
terminalFontFamily: z.string().default('').volatile(),
|
|
96
|
+
connectTimeoutMs: z.number().step(1).min(1_000).max(600_000).default(DEFAULT_CONNECT_TIMEOUT_MS).volatile()
|
|
97
|
+
.description('TCP connect, SSH key exchange and user authentication timeout in milliseconds; raise it for hosts whose authentication is slow.'),
|
|
87
98
|
})
|
|
88
99
|
|
|
89
100
|
/** Schema defaults, re-read for hand-built test contexts (the loader applies them normally). */
|
|
@@ -136,7 +147,7 @@ export const apply = mountOnce('@linxin666/dsh-ssh', applyImpl)
|
|
|
136
147
|
|
|
137
148
|
function applyImpl(ctx: Context, config?: ResolvedConfig): void {
|
|
138
149
|
const store = new HostStore()
|
|
139
|
-
const engine = new SshEngine(store)
|
|
150
|
+
const engine = new SshEngine(store, { connectTimeoutMs: readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS) })
|
|
140
151
|
ctx.effect(() => () => { engine.dispose() }, 'dsh-ssh: engine')
|
|
141
152
|
|
|
142
153
|
const resolve = (): { announceToAgent: boolean; enabled: boolean } => {
|
|
@@ -176,6 +187,10 @@ function applyImpl(ctx: Context, config?: ResolvedConfig): void {
|
|
|
176
187
|
// is kept under one disposer: re-registering first tears the old one down
|
|
177
188
|
// so duplicate-name registrations never throw.
|
|
178
189
|
const sync = (): void => {
|
|
190
|
+
// A settings edit reaches this instance without a remount; apply the
|
|
191
|
+
// connection ceiling before re-deriving the surfaces so connections opened
|
|
192
|
+
// by the request that follows use the new value.
|
|
193
|
+
engine.setConnectTimeout(readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS))
|
|
179
194
|
const value = resolve()
|
|
180
195
|
if (disposeSection !== undefined) {
|
|
181
196
|
disposeSection()
|
package/src/loopback.ts
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* request. Forwarding headers are the signal that a hop stands in between: a
|
|
17
17
|
* request that carries CF-Connecting-IP or X-Forwarded-For is answered through
|
|
18
18
|
* a proxy and is never treated as a local one (issue #1906).
|
|
19
|
+
*
|
|
20
|
+
* An operator who runs that proxy or tunnel themselves can opt into the
|
|
21
|
+
* narrower case: isForwardedLoopbackRequest describes a forwarded request that
|
|
22
|
+
* still landed on this machine's loopback upstream, and a route family admits
|
|
23
|
+
* it only behind its own default-off switch (issue #1918).
|
|
19
24
|
* @module dsh-web-shared/host/loopback
|
|
20
25
|
*/
|
|
21
26
|
|
|
@@ -85,3 +90,30 @@ export function isLoopbackRequest(request: IncomingMessage): boolean {
|
|
|
85
90
|
return false
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Whether a forwarded request landed on this machine's loopback upstream: a
|
|
96
|
+
* forwarding header (the proxy's own stamp), a loopback socket address (the
|
|
97
|
+
* proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
|
|
98
|
+
* the authority to its upstream literal).
|
|
99
|
+
*
|
|
100
|
+
* This is a fact about the route, not a trust decision. A public request to a
|
|
101
|
+
* tunnel satisfies all three by construction, because the proxy is the client
|
|
102
|
+
* of this process: only a caller that operates the proxy can decide it stands
|
|
103
|
+
* for the browser, which is why every consumer keeps this behind an explicit
|
|
104
|
+
* default-off switch and its own browser markers. isLoopbackRequest is
|
|
105
|
+
* unchanged and still refuses a forwarded request (issue #1906).
|
|
106
|
+
* @param request - node HTTP request.
|
|
107
|
+
* @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
|
|
108
|
+
*/
|
|
109
|
+
export function isForwardedLoopbackRequest(request: IncomingMessage): boolean {
|
|
110
|
+
if (!isProxiedRequest(request)) return false
|
|
111
|
+
if (!isLoopbackAddress(request.socket.remoteAddress)) return false
|
|
112
|
+
const host = request.headers.host
|
|
113
|
+
if (typeof host !== 'string') return false
|
|
114
|
+
try {
|
|
115
|
+
return isLoopbackHostname(new URL('http://' + host).hostname)
|
|
116
|
+
} catch {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/protocol.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface SshHostEntry {
|
|
|
29
29
|
/**
|
|
30
30
|
* ssh-agent endpoint for 'agent' auth. A socket path, the special value
|
|
31
31
|
* 'pageant' (PuTTY Pageant on Windows), or undefined for auto-detect
|
|
32
|
-
* (SSH_AUTH_SOCK, then
|
|
32
|
+
* (SSH_AUTH_SOCK, then the native OpenSSH named pipe on Windows).
|
|
33
33
|
*/
|
|
34
34
|
agentPath?: string
|
|
35
35
|
}
|
package/src/tool-surface.ts
CHANGED
package/src/tools.ts
CHANGED
|
@@ -149,7 +149,7 @@ export function sshExecTool(engine: SshEngine) {
|
|
|
149
149
|
parameters: {
|
|
150
150
|
alias: { type: 'string', required: true, description: 'Host alias from ssh_list.' },
|
|
151
151
|
command: { type: 'string', required: true, description: 'The shell command to run remotely.' },
|
|
152
|
-
timeoutMs: { type: 'integer', description: '
|
|
152
|
+
timeoutMs: { type: 'integer', 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.' },
|
|
153
153
|
},
|
|
154
154
|
output: {
|
|
155
155
|
schema: {
|
|
@@ -367,7 +367,7 @@ export function sshClusterTool(engine: SshEngine) {
|
|
|
367
367
|
aliases: { type: 'array', items: { type: 'string' }, description: 'Optional alias filter; at least one of aliases, environment, or tags is required.' },
|
|
368
368
|
environment: { type: 'string', description: 'Optional environment filter; at least one selector is required.' },
|
|
369
369
|
tags: { type: 'array', items: { type: 'string' }, description: 'Optional ALL-tags filter; at least one selector is required.' },
|
|
370
|
-
timeoutMs: { type: 'integer', description: 'Per-host timeout in milliseconds.' },
|
|
370
|
+
timeoutMs: { type: 'integer', description: 'Per-host command execution timeout in milliseconds (default 60000); it does not extend the connection and authentication ceiling (the dsh-ssh connectTimeoutMs setting).' },
|
|
371
371
|
maxWorkers: { type: 'integer', description: 'Concurrency cap (default 8).' },
|
|
372
372
|
},
|
|
373
373
|
output: {
|