mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 00:20:45 +00:00
* fix(sftp): optimize growing-download verification * fix(sftp): harden growing-download prefix verification Skip unprivileged SSH digest commands for sudo SFTP sessions and reject empty-input digests so root-only sources fall through to the elevated SFTP channel. Hash remote prefixes in concurrency-sized windows so verification keeps a bounded memory footprint instead of retaining the full downloaded prefix. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): fall back when remote digest command times out Treat SSH digest open/run timeouts as a miss for the optional command-path optimization so growing-download verification can still prove the prefix via SFTP ranges instead of failing a completed transfer. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): propagate digest open timeouts after transport invalidation SSH_EXEC_OPEN_TIMEOUT invalidates the physical transport in boundedSshExec, so falling through to SFTP on the same session is unsafe. Keep run-timeout fallback to SFTP, but fail closed on open timeout. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): mark digest open timeouts as noTransferFallback SSH_EXEC_OPEN_TIMEOUT already invalidates the transport. Tag it with noTransferFallback so downloadFile's isolated→shared catch fails closed instead of retrying verification on the poisoned session. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): fail closed on verify timeouts; range-hash checkpoint resumes Mark SFTP verification request/stream timeouts with noTransferFallback so downloadFile does not retry body transfer on a channel that still owns a timed-out request. Allow checkpoint-complete growth verification to use bounded prefix ranges under the session fast-download slot, including sudo paths that skip unprivileged SSH digests. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): drop wedged SFTP channel after verification timeouts Clear and end the cached SFTP channel when prefix verification hits an OPEN/READ/stream watchdog or digest exec-open timeout, so later browse/transfer work cannot reuse a channel that still owns cancelled requests. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): use window inactivity watchdog for prefix range hashing Reset a single per-window READ inactivity timer whenever any range completes, instead of arming independent deadlines that all expire together on slow or serialized SFTP servers. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(sftp): abandon channel on stalled CLOSE; share abort gate Drop the cached SFTP channel when verification CLOSE times out or fails, and fan out concurrent prefix READs through one shared AbortSignal gate so the bounded window does not attach dozens of listeners. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
39 lines
1.9 KiB
JavaScript
39 lines
1.9 KiB
JavaScript
"use strict";
|
|
|
|
// Keep ssh2's default 32KB request size. Some SFTP servers mishandle larger
|
|
// requests and can silently produce truncated/corrupt files (GitHub #2022).
|
|
const TRANSFER_CHUNK_SIZE = 32 * 1024;
|
|
|
|
// Upload fanout: 64 parallel 32KB WRITE requests (~2MB in flight). Matches
|
|
// Electerm transfer.js / ssh2-style defaults (concurrency 64, chunk 32KB) for
|
|
// high-RTT body feel after #2449. Chunk size stays 32KB for server compatibility
|
|
// (#2022 / #2030). Uploads still prefer an isolated SFTP channel / dedicated
|
|
// transfer session so interactive terminal traffic is not starved (#1507).
|
|
const UPLOAD_TRANSFER_CONCURRENCY = 64;
|
|
|
|
// Downloads need a larger request window on high-latency proxy paths. 64 is
|
|
// ssh2's fastGet default and, with the safe 32KB request size, restores the 2MB
|
|
// in-flight window Netcatty used before the shared chunk-size fix in #2030.
|
|
const DOWNLOAD_TRANSFER_CONCURRENCY = 64;
|
|
// Prefix verification must fail closed when a server stops answering, but allow
|
|
// slow links to make progress without imposing a whole-transfer deadline.
|
|
const SFTP_OPEN_TIMEOUT_MS = 15_000;
|
|
const SFTP_REQUEST_TIMEOUT_MS = 30_000;
|
|
// Only one file per SFTP session holds the 64-request concurrent READ fanout
|
|
// (isolated channel or shared/sudo browse path). Additional downloads wait for
|
|
// a free slot rather than degrading to serial createReadStream (#2719 / #2449
|
|
// fail-closed). Folder fan-out is capped in the renderer by
|
|
// runSftpTransferWorkers (settings transfer concurrency). Multi-select
|
|
// top-level downloads enqueue in parallel and share the same host scheduler /
|
|
// channel pool caps - they must never fall back to serial body streams.
|
|
const FAST_DOWNLOAD_CHANNELS_PER_SESSION = 1;
|
|
|
|
module.exports = {
|
|
DOWNLOAD_TRANSFER_CONCURRENCY,
|
|
FAST_DOWNLOAD_CHANNELS_PER_SESSION,
|
|
SFTP_OPEN_TIMEOUT_MS,
|
|
SFTP_REQUEST_TIMEOUT_MS,
|
|
TRANSFER_CHUNK_SIZE,
|
|
UPLOAD_TRANSFER_CONCURRENCY,
|
|
};
|