dsh-server-connector 0.2.3 → 0.3.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/CHANGELOG.md +72 -0
- package/LICENSE +0 -0
- package/README.md +49 -7
- package/cordis.patch.yml +6 -6
- package/icon.svg +15 -15
- package/lib/audit.js +469 -455
- package/lib/client.js +2389 -1728
- package/lib/config.js +89 -0
- package/lib/index.js +316 -266
- package/lib/known-hosts.js +377 -377
- package/lib/pending.js +766 -753
- package/lib/policy.js +590 -590
- package/lib/pool.js +1496 -1464
- package/lib/registry.js +968 -968
- package/lib/routes.js +14 -13
- package/lib/tools.js +1367 -1357
- package/locale/en.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +105 -105
package/lib/routes.js
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { stat } from 'node:fs/promises'
|
|
33
33
|
|
|
34
34
|
import { AuditError } from './audit.js'
|
|
35
|
+
import { readConfig } from './config.js'
|
|
35
36
|
import { PendingError } from './pending.js'
|
|
36
37
|
import { PoolError } from './pool.js'
|
|
37
38
|
import { MAX_CUSTOM_RULES, RULES, RULES_BY_ID, RuleError, check as checkPolicy, effectiveDecision, validateCustomRule } from './policy.js'
|
|
@@ -478,7 +479,17 @@ export function createApi(options) {
|
|
|
478
479
|
const config = options.config ?? {}
|
|
479
480
|
const onChange = typeof options.onChange === 'function' ? options.onChange : null
|
|
480
481
|
const getCredentials = typeof options.getCredentials === 'function' ? options.getCredentials : () => null
|
|
481
|
-
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* The current §10 values. Read per request: a volatile settings edit lands in
|
|
485
|
+
* `options.config` without remounting, so a value captured once here would go
|
|
486
|
+
* stale the first time someone opened the settings form.
|
|
487
|
+
* @returns {import('./index.js').PluginConfig}
|
|
488
|
+
*/
|
|
489
|
+
const settings = () => readConfig(config)
|
|
490
|
+
|
|
491
|
+
/** The probe budget is the command timeout, capped so "Test" stays interactive. */
|
|
492
|
+
const probeTimeoutMs = () => Math.min(Number(settings().commandTimeoutMs), 15000)
|
|
482
493
|
|
|
483
494
|
/**
|
|
484
495
|
* Report one non-fatal failure without changing the request outcome.
|
|
@@ -664,17 +675,7 @@ export function createApi(options) {
|
|
|
664
675
|
body: {
|
|
665
676
|
servers: present,
|
|
666
677
|
rules: ruleCatalog(),
|
|
667
|
-
config:
|
|
668
|
-
connectTimeoutMs: config.connectTimeoutMs ?? 15000,
|
|
669
|
-
commandTimeoutMs: config.commandTimeoutMs ?? 60000,
|
|
670
|
-
syncTimeoutMs: config.syncTimeoutMs ?? 20000,
|
|
671
|
-
maxOutputChars: config.maxOutputChars ?? 200000,
|
|
672
|
-
idleTimeoutMs: config.idleTimeoutMs ?? 600000,
|
|
673
|
-
auditEnabled: config.auditEnabled ?? true,
|
|
674
|
-
auditMaxBytes: config.auditMaxBytes ?? 0,
|
|
675
|
-
pendingTtlHours: config.pendingTtlHours ?? 24,
|
|
676
|
-
maxListedServers: config.maxListedServers ?? 8,
|
|
677
|
-
},
|
|
678
|
+
config: settings(),
|
|
678
679
|
hostKeyModes: [...HOST_KEY_MODES],
|
|
679
680
|
decisions: [...DECISION_VALUES],
|
|
680
681
|
pendingCount: Array.isArray(queued) ? queued.length : 0,
|
|
@@ -1112,7 +1113,7 @@ export function createApi(options) {
|
|
|
1112
1113
|
const probe = async (server) => {
|
|
1113
1114
|
const startedAt = Date.now()
|
|
1114
1115
|
await pool.connect(server)
|
|
1115
|
-
const result = await pool.exec(server, { command: CONNECT_PROBE, timeoutMs: probeTimeoutMs })
|
|
1116
|
+
const result = await pool.exec(server, { command: CONNECT_PROBE, timeoutMs: probeTimeoutMs() })
|
|
1116
1117
|
return { ...parseProbe(String(result.stdout ?? '')), durationMs: Date.now() - startedAt }
|
|
1117
1118
|
}
|
|
1118
1119
|
|