mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-18 05:43:38 +00:00
Keep only the confirmed product fixes for 奇安信-style auto-login: 1. Seed startup screen from viewport or live buffer so on-screen menus stay waitable (never mark the whole buffer consumed at script start). 2. sendLine emits body then CR separately, matching real keyboard input. 3. After sendLine, consume only pre-send buffer length so peer prompts that arrive between body and Enter remain matchable for the next step.
This commit is contained in:
6 files changed
+244
-56
No files matched your search
@@ -629,7 +629,25 @@ function createScriptRuntime(deps) {
|
||||
await trackStep(`sendLine: ${truncateActivityLabel(line, 60)}`);
|
||||
if (deps.isAborted?.()) return;
|
||||
appendLog(runId, `→ ${line}`);
|
||||
writeToSession(sessionId, `${line}\r`, { automated: true });
|
||||
// Bastion menus can ignore a single "line\r" packet even when
|
||||
// stream.write succeeds. Match xterm: body, then Enter (#1960).
|
||||
// Consume only pre-send buffer length so prompts that arrive between
|
||||
// body and CR stay waitable for the next step.
|
||||
const buffer = getOutputBuffer(sessionId);
|
||||
const lengthBeforeSend = buffer.getText().length;
|
||||
if (line.length > 0) {
|
||||
writeToSession(sessionId, line, {
|
||||
automated: true,
|
||||
invalidateStartupSeed: false,
|
||||
});
|
||||
await interruptibleSleep(30, deps.isAborted);
|
||||
if (deps.isAborted?.()) return;
|
||||
}
|
||||
writeToSession(sessionId, "\r", {
|
||||
automated: true,
|
||||
invalidateStartupSeed: false,
|
||||
});
|
||||
buffer.consumeThroughAbsolute(lengthBeforeSend);
|
||||
}));
|
||||
},
|
||||
waitFor(pattern, timeoutMs = 30000) {
|
||||
|
||||
Reference in new issue
Block a user