@linxin666/dsh-ssh 0.4.7 → 0.4.8
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 +4 -2
- package/README.zh.md +4 -2
- package/lib/client.js +61 -2
- package/lib/client.js.map +1 -1
- package/lib/index.js +66 -6
- package/lib/types/client/locales.d.ts +4 -0
- package/lib/types/client/telemetry.d.ts +14 -2
- package/lib/types/engine/connection-pool.d.ts +16 -0
- package/lib/types/loopback.d.ts +20 -1
- package/lib/types/protocol.d.ts +17 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/tools.d.ts +1 -0
- package/package.json +1 -1
- package/src/client/locales.ts +8 -0
- package/src/client/panel/HostFormDialog.tsx +11 -0
- package/src/client/panel/HostsTab.tsx +3 -0
- package/src/client/panel/panel.module.css +6 -0
- package/src/client/telemetry.ts +47 -2
- package/src/engine/connection-pool.ts +38 -0
- package/src/loopback.ts +25 -1
- package/src/protocol.ts +17 -0
- package/src/routes.ts +4 -1
- package/src/store.ts +26 -0
- package/src/tools.ts +7 -2
package/src/protocol.ts
CHANGED
|
@@ -50,6 +50,12 @@ export interface SshHostEntry {
|
|
|
50
50
|
tags: string[]
|
|
51
51
|
/** Physical location note. */
|
|
52
52
|
location?: string
|
|
53
|
+
/**
|
|
54
|
+
* Opt-in ssh-agent forwarding (OpenSSH ForwardAgent / ssh -A): the host's
|
|
55
|
+
* sessions request agent forwarding so the remote can sign with this
|
|
56
|
+
* machine's agent. Default off; stored only when enabled.
|
|
57
|
+
*/
|
|
58
|
+
forwardAgent?: boolean
|
|
53
59
|
createdAt: number
|
|
54
60
|
updatedAt: number
|
|
55
61
|
}
|
|
@@ -70,6 +76,12 @@ export interface SshHostSummary {
|
|
|
70
76
|
environment?: string
|
|
71
77
|
tags: string[]
|
|
72
78
|
location?: string
|
|
79
|
+
/**
|
|
80
|
+
* Whether agent forwarding is enabled. Always projected as a definite
|
|
81
|
+
* boolean: the browser and the tool bridge need a value even for entries
|
|
82
|
+
* stored before the feature existed.
|
|
83
|
+
*/
|
|
84
|
+
forwardAgent: boolean
|
|
73
85
|
createdAt: number
|
|
74
86
|
updatedAt: number
|
|
75
87
|
}
|
|
@@ -160,6 +172,11 @@ export interface HostPayload {
|
|
|
160
172
|
environment?: string
|
|
161
173
|
tags?: string[]
|
|
162
174
|
location?: string
|
|
175
|
+
/**
|
|
176
|
+
* Agent forwarding for this host. Omitted on update keeps the stored value;
|
|
177
|
+
* false clears it (PATCH semantics).
|
|
178
|
+
*/
|
|
179
|
+
forwardAgent?: boolean
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
/** Why one ssh_config Host block was not imported. */
|
package/src/routes.ts
CHANGED
|
@@ -130,8 +130,11 @@ const maxUploadBytes = deps.maxUploadBytes ?? MAX_UPLOAD_BYTES
|
|
|
130
130
|
// Connection-relevant changes invalidate the pooled connection:
|
|
131
131
|
// without this the pool would keep running commands on the old
|
|
132
132
|
// host/credentials until the idle sweep (up to 30 min later).
|
|
133
|
+
// Agent forwarding belongs here too: it is fixed per connection
|
|
134
|
+
// (ssh2 negotiates it when the channel opens), so toggling it must
|
|
135
|
+
// reconnect or the new setting silently never takes effect.
|
|
133
136
|
const patch = body as Record<string, unknown>
|
|
134
|
-
if (['host', 'port', 'user', 'auth', 'proxyJump', 'proxyCommand'].some(key => patch[key] !== undefined)) {
|
|
137
|
+
if (['host', 'port', 'user', 'auth', 'proxyJump', 'proxyCommand', 'forwardAgent'].some(key => patch[key] !== undefined)) {
|
|
135
138
|
engine.dropAlias(alias)
|
|
136
139
|
}
|
|
137
140
|
writeJson(res, 200, { host: store.summarize(entry) })
|
package/src/store.ts
CHANGED
|
@@ -72,6 +72,9 @@ export function validateHostPayload(payload: unknown): string | undefined {
|
|
|
72
72
|
if (p.tags !== undefined && (!Array.isArray(p.tags) || p.tags.some(x => typeof x !== 'string'))) {
|
|
73
73
|
return 'tags must be an array of strings'
|
|
74
74
|
}
|
|
75
|
+
if (p.forwardAgent !== undefined && typeof p.forwardAgent !== 'boolean') {
|
|
76
|
+
return 'forwardAgent must be a boolean'
|
|
77
|
+
}
|
|
75
78
|
return undefined
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -136,6 +139,9 @@ export class HostStore {
|
|
|
136
139
|
...(entry.environment !== undefined ? { environment: entry.environment } : {}),
|
|
137
140
|
tags: [...entry.tags],
|
|
138
141
|
...(entry.location !== undefined ? { location: entry.location } : {}),
|
|
142
|
+
// Always a definite boolean, unlike the conditional optional fields:
|
|
143
|
+
// the tool bridge rejects undefined-valued JSON properties.
|
|
144
|
+
forwardAgent: entry.forwardAgent === true,
|
|
139
145
|
createdAt: entry.createdAt,
|
|
140
146
|
updatedAt: entry.updatedAt,
|
|
141
147
|
}
|
|
@@ -171,6 +177,9 @@ export class HostStore {
|
|
|
171
177
|
environment: payload.environment?.trim() || undefined,
|
|
172
178
|
tags: [...(payload.tags ?? [])].map(tag => tag.trim()).filter(tag => tag !== ''),
|
|
173
179
|
location: payload.location?.trim() || undefined,
|
|
180
|
+
// Stored only when enabled, so a store file written without agent
|
|
181
|
+
// forwarding stays byte-identical to the pre-feature format.
|
|
182
|
+
forwardAgent: payload.forwardAgent === true ? true : undefined,
|
|
174
183
|
createdAt: now,
|
|
175
184
|
updatedAt: now,
|
|
176
185
|
}
|
|
@@ -201,6 +210,9 @@ export class HostStore {
|
|
|
201
210
|
if (patch.proxyCommand !== undefined && typeof patch.proxyCommand !== 'string') {
|
|
202
211
|
throw new Error('proxyCommand must be a string when provided')
|
|
203
212
|
}
|
|
213
|
+
if (patch.forwardAgent !== undefined && typeof patch.forwardAgent !== 'boolean') {
|
|
214
|
+
throw new Error('forwardAgent must be a boolean')
|
|
215
|
+
}
|
|
204
216
|
// The mutual exclusion is checked on the MERGED view: a patch that only
|
|
205
217
|
// adds one transport must not slip past a stored value of the other.
|
|
206
218
|
const mergedProxyCommand = patch.proxyCommand !== undefined
|
|
@@ -250,6 +262,8 @@ export class HostStore {
|
|
|
250
262
|
if (patch.environment !== undefined) entry.environment = patch.environment.trim() || undefined
|
|
251
263
|
if (patch.tags !== undefined) entry.tags = [...patch.tags].map(tag => tag.trim()).filter(tag => tag !== '')
|
|
252
264
|
if (patch.location !== undefined) entry.location = patch.location.trim() || undefined
|
|
265
|
+
// PATCH semantics: an omitted key keeps the stored value, false clears it.
|
|
266
|
+
if (patch.forwardAgent !== undefined) entry.forwardAgent = patch.forwardAgent === true ? true : undefined
|
|
253
267
|
entry.updatedAt = Date.now()
|
|
254
268
|
this.save(file)
|
|
255
269
|
return entry
|
|
@@ -326,6 +340,7 @@ export class HostStore {
|
|
|
326
340
|
environment: block.props.environment,
|
|
327
341
|
tags: (block.props.tags ?? '').split(',').map(tag => tag.trim()).filter(tag => tag !== ''),
|
|
328
342
|
location: block.props.location,
|
|
343
|
+
forwardAgent: parseForwardAgentValue(block.props.forwardagent),
|
|
329
344
|
}
|
|
330
345
|
try {
|
|
331
346
|
this.create(payload)
|
|
@@ -411,6 +426,17 @@ export function normalizeProxyCommand(raw: string | undefined): string | undefin
|
|
|
411
426
|
return trimmed
|
|
412
427
|
}
|
|
413
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
|
|
431
|
+
* an explicit yes/true/on enables forwarding; an absent value, no/false/off,
|
|
432
|
+
* and anything unrecognized leave it off instead of failing the import — an
|
|
433
|
+
* unknown keyword must never cost the user the whole Host block.
|
|
434
|
+
*/
|
|
435
|
+
export function parseForwardAgentValue(raw: string | undefined): boolean {
|
|
436
|
+
const value = raw?.trim().toLowerCase()
|
|
437
|
+
return value === 'yes' || value === 'true' || value === 'on'
|
|
438
|
+
}
|
|
439
|
+
|
|
414
440
|
/** Expand a leading `~` in a filesystem path. */
|
|
415
441
|
export function expandHome(path: string): string {
|
|
416
442
|
if (path === '~') return homedir()
|
package/src/tools.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface AgentHostRow {
|
|
|
28
28
|
keyReady: boolean
|
|
29
29
|
proxyJump: string[]
|
|
30
30
|
proxyCommandConfigured: boolean
|
|
31
|
+
forwardAgent: boolean
|
|
31
32
|
description?: string
|
|
32
33
|
environment?: string
|
|
33
34
|
tags: string[]
|
|
@@ -52,11 +53,14 @@ function renderHosts(hosts: AgentHostRow[]): string {
|
|
|
52
53
|
host.user,
|
|
53
54
|
host.auth,
|
|
54
55
|
host.proxyJump.length > 0 ? 'jump:' + host.proxyJump.join(',') : host.proxyCommandConfigured ? 'proxy-command' : '-',
|
|
56
|
+
// Forwarding is a security-relevant opt-in (the remote can sign with this
|
|
57
|
+
// machine's agent), so the model must see it in the table, not only in JSON.
|
|
58
|
+
host.forwardAgent ? 'yes' : '-',
|
|
55
59
|
host.environment ?? '-',
|
|
56
60
|
(host.tags.length > 0 ? host.tags.join(',') : '-'),
|
|
57
61
|
host.description ?? '',
|
|
58
62
|
].join(' | '))
|
|
59
|
-
return ['alias | host | port | user | auth | proxy | environment | tags | description', '--- | --- | --- | --- | --- | --- | --- | --- | ---', ...rows].join('\n')
|
|
63
|
+
return ['alias | host | port | user | auth | proxy | forward | environment | tags | description', '--- | --- | --- | --- | --- | --- | --- | --- | --- | ---', ...rows].join('\n')
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
/** Render one exec result (mirrors the bash-tool exit-code convention). */
|
|
@@ -91,7 +95,7 @@ function renderTunnel(tunnel: TunnelInfo): string {
|
|
|
91
95
|
export function sshListTool(engine: SshEngine) {
|
|
92
96
|
return defineTool({
|
|
93
97
|
name: 'ssh_list',
|
|
94
|
-
description: 'List configured SSH hosts (alias, host, user, auth, environment, tags, description). Use ssh_exec etc. with the alias.',
|
|
98
|
+
description: 'List configured SSH hosts (alias, host, user, auth, agent forwarding, environment, tags, description). Use ssh_exec etc. with the alias.',
|
|
95
99
|
parameters: {
|
|
96
100
|
query: { type: 'string', description: 'Optional fuzzy match against alias, description, host, and tags.' },
|
|
97
101
|
},
|
|
@@ -115,6 +119,7 @@ export function sshListTool(engine: SshEngine) {
|
|
|
115
119
|
keyReady: { type: 'boolean', required: true },
|
|
116
120
|
proxyJump: { type: 'array', items: { type: 'string' }, required: true },
|
|
117
121
|
proxyCommandConfigured: { type: 'boolean', required: true },
|
|
122
|
+
forwardAgent: { type: 'boolean', required: true },
|
|
118
123
|
description: { type: 'string' },
|
|
119
124
|
environment: { type: 'string' },
|
|
120
125
|
tags: { type: 'array', items: { type: 'string' }, required: true },
|