dsh-ris-ide 1.8.0 → 1.8.2
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.md +5 -3
- package/bin/risd.mjs +14 -17
- package/lib/client.js +400 -93
- package/lib/debug/vendor/README.md +14 -0
- package/lib/debug/vendor/jdwp/client.js +9 -4
- package/lib/debug/vendor/src/jdwp/client.ts +12 -5
- package/lib/index.js +794 -48
- package/lib/proxybridge-bundle.js +1 -1
- package/lib/proxybridge-health.js +206 -0
- package/lib/redirector.js +1181 -90
- package/lib/risd/lifecycle.js +9 -3
- package/lib/risd/server.js +762 -26
- package/lib/risd/ui.js +419 -98
- package/lib/risd-client.js +4 -1
- package/lib/startup.js +27 -7
- package/package.json +2 -2
- package/test/client-viewer.test.mjs +299 -120
- package/test/clipboard.test.mjs +259 -0
- package/test/debug-engine.test.mjs +3 -1
- package/test/dsh-origin.test.mjs +4 -11
- package/test/dsh-window-refresh.test.mjs +166 -1
- package/test/harness.test.mjs +1 -1
- package/test/helpers/cmd.mjs +29 -0
- package/test/helpers/tgz.mjs +71 -0
- package/test/host-search.test.mjs +18 -11
- package/test/host-tail.test.mjs +119 -24
- package/test/proxy-route.test.mjs +61 -0
- package/test/proxy-window.test.mjs +5 -0
- package/test/proxy.test.mjs +13 -1
- package/test/proxybridge-bundle.test.mjs +1 -59
- package/test/proxybridge-health.test.mjs +116 -0
- package/test/redirector-bundle.test.mjs +21 -67
- package/test/redirector.test.mjs +395 -5
- package/test/risd-api.test.mjs +114 -17
- package/test/risd-bridge-degrade.test.mjs +3 -29
- package/test/risd-engine.test.mjs +13 -50
- package/test/risd-entry.test.mjs +0 -37
- package/test/risd-follow-start.test.mjs +101 -0
- package/test/risd-git.test.mjs +7 -5
- package/test/risd-handoff.test.mjs +6 -50
- package/test/risd-helpers.mjs +150 -3
- package/test/risd-host-p2.test.mjs +2 -30
- package/test/risd-lifecycle.test.mjs +25 -0
- package/test/risd-programs.test.mjs +4 -34
- package/test/risd-restart.test.mjs +104 -0
- package/test/risd-review-p2.test.mjs +0 -13
- package/test/risd-shutdown.test.mjs +5 -38
- package/test/risd-teardown.test.mjs +8 -27
- package/test/risd-ui.test.mjs +322 -4
- package/test/risd-write.test.mjs +2 -1
- package/test/startup-reconcile.test.mjs +44 -8
- package/test/proxy-restart.test.mjs +0 -37
|
@@ -44,7 +44,7 @@ export const MANIFEST_FILENAME = 'manifest.json'
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Where the release asset lives. `ris-proxy.4.0.tgz` (ProxyBridge 4.0 bundle) is
|
|
47
|
-
* attached to the 1.8.
|
|
47
|
+
* attached to the 1.8.1
|
|
48
48
|
* release on BOTH mirrors, so a blocked network on one side still installs:
|
|
49
49
|
* Gitee is the primary repository (the GitHub repo is a mirror), and it is tried
|
|
50
50
|
* first. Both URLs point at the same uploaded bytes.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health check for the downloaded ProxyBridge component (m11828).
|
|
3
|
+
*
|
|
4
|
+
* The maintenance page can say "已安装 · 文件 8 个", but that only proves the files
|
|
5
|
+
* were written once. A component that matters is one that can still RUN: the binary
|
|
6
|
+
* may be missing a sibling DLL, an anti-virus may quarantine it, or the cached
|
|
7
|
+
* `.exe` may be an architecture mismatch. So this module asks both side's CLI for
|
|
8
|
+
* its version — the cheapest proof that the executable loads — and reports file
|
|
9
|
+
* completeness next to it.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately separated from `lib/redirector.js`: that module owns the running
|
|
12
|
+
* bridge; this one answers "is the component itself healthy" without starting,
|
|
13
|
+
* elevating or killing anything. It never blocks the HTTP loop (`execFile`).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { execFile } from 'node:child_process'
|
|
17
|
+
import { existsSync, statSync } from 'node:fs'
|
|
18
|
+
import { join } from 'node:path'
|
|
19
|
+
import { promisify } from 'node:util'
|
|
20
|
+
|
|
21
|
+
import { bundleLayout, installDir } from './proxybridge-bundle.js'
|
|
22
|
+
|
|
23
|
+
const execFileAsync = promisify(execFile)
|
|
24
|
+
|
|
25
|
+
/** Health results are cheap to compute but spawn processes: cache them. */
|
|
26
|
+
export const HEALTH_TTL_MS = 30000
|
|
27
|
+
|
|
28
|
+
/** Files each side's CLI needs before it can start (the licences are not required). */
|
|
29
|
+
export const SIDE_FILES = Object.freeze({
|
|
30
|
+
linux: Object.freeze(['linux/ProxyBridge', 'linux/libproxybridge.so']),
|
|
31
|
+
windows: Object.freeze([
|
|
32
|
+
'windows/ProxyBridge_CLI.exe',
|
|
33
|
+
'windows/ProxyBridgeCore.dll',
|
|
34
|
+
'windows/WinDivert.dll',
|
|
35
|
+
'windows/WinDivert64.sys',
|
|
36
|
+
]),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
/** Run a command and return its output; never throws (a broken CLI is a diagnosis). */
|
|
40
|
+
async function runCommand(command, args, timeoutMs) {
|
|
41
|
+
try {
|
|
42
|
+
const result = await execFileAsync(command, args, { encoding: 'utf8', timeout: timeoutMs, windowsHide: true, maxBuffer: 1024 * 1024 })
|
|
43
|
+
return `${result.stdout ?? ''}${result.stderr ?? ''}`
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return `${error?.stdout ?? ''}${error?.stderr ?? ''}${error?.message ?? ''}`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fileState(bundleDir, relative) {
|
|
50
|
+
const path = join(bundleDir, relative)
|
|
51
|
+
try {
|
|
52
|
+
const stat = statSync(path)
|
|
53
|
+
return { path: `bundle/${relative}`, ok: stat.isFile() && stat.size > 0, size: stat.size }
|
|
54
|
+
} catch {
|
|
55
|
+
return { path: `bundle/${relative}`, ok: false, size: 0 }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function parseVersion(output) {
|
|
60
|
+
const match = /(\d+\.\d+\.\d+)/.exec(String(output ?? ''))
|
|
61
|
+
return match === null ? '' : match[1]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Check one side of the component.
|
|
66
|
+
*
|
|
67
|
+
* @param {{bundleDir: string, side: 'linux'|'windows', run?: Function}} options - which side.
|
|
68
|
+
* @returns {Promise<{side: string, ok: boolean, files: object, version: string, error?: string, checks: object[]}>}
|
|
69
|
+
*/
|
|
70
|
+
async function checkSide({ bundleDir, side, run, windowsExe = '', applicable = true, skippedNote = '' }) {
|
|
71
|
+
const files = SIDE_FILES[side].map((relative) => fileState(bundleDir, relative))
|
|
72
|
+
const missing = files.filter((file) => file.ok !== true).map((file) => file.path)
|
|
73
|
+
if (applicable !== true) {
|
|
74
|
+
// Single-sided hosts are normal, not broken: a native Linux box has no Windows
|
|
75
|
+
// bridge, a native Windows box has no Linux bridge. Skipping keeps the card green
|
|
76
|
+
// (m12019).
|
|
77
|
+
return {
|
|
78
|
+
side,
|
|
79
|
+
applicable: false,
|
|
80
|
+
skipped: true,
|
|
81
|
+
ok: true,
|
|
82
|
+
files: { ok: missing.length === 0, expected: files.length, missing, entries: files },
|
|
83
|
+
version: '',
|
|
84
|
+
note: skippedNote === '' ? '本机无此侧' : skippedNote,
|
|
85
|
+
checks: [],
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const bundleExe = join(bundleDir, side === 'windows' ? 'windows/ProxyBridge_CLI.exe' : 'linux/ProxyBridge')
|
|
89
|
+
// Windows cannot launch an executable from the Linux filesystem: probe the copy
|
|
90
|
+
// materialised under %LOCALAPPDATA% (the one the bridge actually runs). Without it
|
|
91
|
+
// the check honestly says "not prepared yet" instead of "broken".
|
|
92
|
+
const exe = side === 'windows' ? windowsExe : bundleExe
|
|
93
|
+
let version = ''
|
|
94
|
+
let error = ''
|
|
95
|
+
if (skippedNote !== '') {
|
|
96
|
+
// Files are installed but the Windows copy has not been materialised yet: that
|
|
97
|
+
// happens before the first bridge start, so it is "not prepared", not "broken".
|
|
98
|
+
return {
|
|
99
|
+
side,
|
|
100
|
+
applicable: true,
|
|
101
|
+
skipped: true,
|
|
102
|
+
ok: true,
|
|
103
|
+
files: { ok: missing.length === 0, expected: files.length, missing, entries: files },
|
|
104
|
+
version: '',
|
|
105
|
+
note: skippedNote,
|
|
106
|
+
checks: [{ id: 'files', label: '文件完整', ok: missing.length === 0, detail: `${files.length - missing.length}/${files.length}` }],
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (side === 'windows' && exe === '') {
|
|
110
|
+
error = '尚未复制到 Windows 侧(首次启动拦截时准备)'
|
|
111
|
+
} else if (existsSync(side === 'windows' ? bundleExe : exe) === true || side === 'windows') {
|
|
112
|
+
const output = side === 'windows'
|
|
113
|
+
? await run('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', `[Console]::OutputEncoding=[System.Text.Encoding]::UTF8; & '${exe}' --version`], 8000)
|
|
114
|
+
: await run(exe, ['--version'], 6000)
|
|
115
|
+
version = parseVersion(output)
|
|
116
|
+
if (version === '') error = String(output).trim().split(/\r?\n/).filter((line) => line !== '').slice(-1)[0]?.slice(0, 160) ?? ''
|
|
117
|
+
} else {
|
|
118
|
+
error = '可执行文件不存在'
|
|
119
|
+
}
|
|
120
|
+
const checks = [
|
|
121
|
+
{ id: 'files', label: '文件完整', ok: missing.length === 0, detail: missing.length === 0 ? `${files.length}/${files.length}` : `缺 ${missing.join('、')}` },
|
|
122
|
+
{ id: 'runs', label: '可启动', ok: version !== '', detail: version === '' ? (error === '' ? '版本探测无输出' : error) : `v${version}` },
|
|
123
|
+
]
|
|
124
|
+
return {
|
|
125
|
+
side,
|
|
126
|
+
applicable: true,
|
|
127
|
+
skipped: false,
|
|
128
|
+
ok: checks.every((check) => check.ok === true),
|
|
129
|
+
files: { ok: missing.length === 0, expected: files.length, missing, entries: files },
|
|
130
|
+
version,
|
|
131
|
+
...(error === '' ? {} : { error }),
|
|
132
|
+
checks,
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Full component health for both sides.
|
|
138
|
+
*
|
|
139
|
+
* `engineRunning` is reported, not judged: the component can be perfectly healthy
|
|
140
|
+
* while interception is off (the card shows「拦截:未启动」). The maintenance page
|
|
141
|
+
* only *asks* for this check while the proxy engine is running (m11838), because a
|
|
142
|
+
* stopped engine means the component is not in use at all.
|
|
143
|
+
*
|
|
144
|
+
* @param {{home: string, engineRunning?: boolean, run?: Function, timeoutMs?: number}} options - home + dependency seam.
|
|
145
|
+
* @returns {Promise<{at: string, engineRunning: boolean, ok: boolean, sides: object}>} health snapshot.
|
|
146
|
+
*/
|
|
147
|
+
export async function collectProxyBridgeHealth(options = {}) {
|
|
148
|
+
const home = String(options.home ?? '')
|
|
149
|
+
const bundleDir = installDir(home)
|
|
150
|
+
const run = typeof options.run === 'function' ? options.run : runCommand
|
|
151
|
+
const expected = bundleLayout().length
|
|
152
|
+
const installed = existsSync(join(bundleDir, 'linux/ProxyBridge')) === true || existsSync(join(bundleDir, 'windows/ProxyBridge_CLI.exe')) === true
|
|
153
|
+
const windowsExe = typeof options.windowsExe === 'string' ? options.windowsExe : ''
|
|
154
|
+
// Applicability (m12019): a single-sided host must not report a red card. Linux is
|
|
155
|
+
// always a candidate; Windows only when the bridge can be materialised there
|
|
156
|
+
// (WSL with %LOCALAPPDATA% / native Windows).
|
|
157
|
+
const linuxApplicable = options.linuxApplicable !== undefined ? options.linuxApplicable === true : process.platform !== 'win32'
|
|
158
|
+
const windowsApplicable = options.windowsApplicable !== undefined ? options.windowsApplicable === true : windowsExe !== ''
|
|
159
|
+
const windowsPrepared = options.windowsPrepared !== false
|
|
160
|
+
const [linux, windows] = await Promise.all([
|
|
161
|
+
checkSide({ bundleDir, side: 'linux', run, applicable: linuxApplicable, skippedNote: linuxApplicable ? '' : '本机是 Windows,没有 Linux 侧' }),
|
|
162
|
+
checkSide({
|
|
163
|
+
bundleDir,
|
|
164
|
+
side: 'windows',
|
|
165
|
+
run,
|
|
166
|
+
windowsExe,
|
|
167
|
+
applicable: windowsApplicable,
|
|
168
|
+
skippedNote: windowsApplicable === true && windowsPrepared !== true ? '尚未复制到 Windows 侧(首次启动拦截时准备)' : (windowsApplicable === true ? '' : '本机不是 WSL,没有 Windows 侧'),
|
|
169
|
+
}),
|
|
170
|
+
])
|
|
171
|
+
const applicable = [linux, windows].filter((side) => side.applicable === true)
|
|
172
|
+
return {
|
|
173
|
+
at: new Date().toISOString(),
|
|
174
|
+
engineRunning: options.engineRunning === true,
|
|
175
|
+
installed,
|
|
176
|
+
expectedFiles: expected,
|
|
177
|
+
// ok is judged only on sides this host can run; a skipped side is neutral.
|
|
178
|
+
ok: applicable.every((side) => side.ok === true),
|
|
179
|
+
sides: { linux, windows },
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Cached wrapper: version probes cost a process spawn per side.
|
|
185
|
+
*
|
|
186
|
+
* `force:true` (the card's「重新检查」) must always re-probe; everything else can
|
|
187
|
+
* reuse a result younger than {@link HEALTH_TTL_MS}.
|
|
188
|
+
*/
|
|
189
|
+
export function createHealthCache() {
|
|
190
|
+
let cached = { at: 0, key: '', value: null }
|
|
191
|
+
return {
|
|
192
|
+
async get({ home, engineRunning, force = false, run, windowsExe, windowsApplicable, windowsPrepared, linuxApplicable } = {}) {
|
|
193
|
+
const now = Date.now()
|
|
194
|
+
// The applicability inputs decide WHAT is probed (native Windows vs WSL vs
|
|
195
|
+
// Linux), so they belong in the key: a cached "both skipped" result must not
|
|
196
|
+
// be served to a host that now has a side to check (review A4-P1-1).
|
|
197
|
+
const key = [engineRunning === true, windowsApplicable, windowsPrepared, linuxApplicable, windowsExe].join('|')
|
|
198
|
+
if (force !== true && cached.value !== null && now - cached.at < HEALTH_TTL_MS && cached.key === key) {
|
|
199
|
+
return { ...cached.value, cached: true }
|
|
200
|
+
}
|
|
201
|
+
const value = await collectProxyBridgeHealth({ home, engineRunning, run, windowsExe, windowsApplicable, windowsPrepared, linuxApplicable })
|
|
202
|
+
cached = { at: now, key, value }
|
|
203
|
+
return { ...value, cached: false }
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
}
|