feat(sftp): add macOS and Windows platform support (#3372)

The session watchdog now selects its detection method per
platform. It previously probed kernel TCP state through a
Linux-only procfs path, so on macOS every healthy idle session
was killed within a minute, and on Windows the watchdog never
spawned at all, leaving wedged sessions with no cleanup. Linux
keeps its fast-kill watchdog unchanged. Other platforms get a
silence-only backstop that kills a session only at the
documented 30-minute idle ceiling.

The host-key loader now has a Windows arm. It loads OpenSSH
format host keys from the configured directory and logs a
one-time warning to restrict NTFS ACLs on the key directory,
the same operator-managed approach FTPS, WebDAV, KMS, and IAM
already use on Windows. Startup previously aborted with
UnsupportedPlatform because the Unix mode-bit permission check
has no Windows equivalent. tokio's io-uring feature is now
enabled only in Linux builds. io-uring is a Linux kernel
interface and enabling it unconditionally broke the Windows
build.

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
escapecode
2026-06-12 11:08:23 +01:00
committed by GitHub
parent e80b72ae79
commit 7a8514bdfa
17 changed files with 513 additions and 159 deletions
+15 -10
View File
@@ -31,8 +31,11 @@
//! or more S3 calls on the supplied storage backend.
//! - lifecycle: per-session activity record, the registry the accept loop
//! walks, and the kernel TCP-state probe used by the watchdog.
//! - wedge_watchdog: per-session liveness watchdog that observes both the
//! SFTP-handler activity stamp and the TCP socket state.
//! - wedge_watchdog and fallback_watchdog: the per-session liveness
//! watchdog. On target_os = "linux" wedge_watchdog observes both the
//! SFTP-handler activity stamp and the TCP socket state. On other
//! targets fallback_watchdog provides a silence-only backstop without
//! the TCP-state probe.
//! - read_cache: per-handle in-memory read-ahead cache with a process-wide
//! memory ceiling.
//!
@@ -49,14 +52,13 @@
//! and read throughput:
//!
//! - Session-liveness watchdog. Every accepted connection runs under a
//! per-session watchdog that observes the SFTP-handler activity stamp
//! and the kernel TCP state for the connection. Sessions that fall
//! silent at the SFTP layer while the kernel reports CLOSE_WAIT are
//! canceled on a bounded schedule. The watchdog backstops resource
//! accumulation regardless of which layer stalled. On Linux the
//! detection latency is on the order of 45 seconds; on non-Linux
//! targets the watchdog falls back to an inactivity ceiling on the
//! order of 30 minutes.
//! per-session watchdog. On Linux the watchdog observes both the
//! SFTP-handler activity stamp and the kernel TCP state for the
//! connection. Sessions silent at the SFTP layer while the kernel
//! reports CLOSE_WAIT are cancelled in approximately 45 to 60
//! seconds. On non-Linux targets the watchdog observes only the
//! activity stamp and cancels at an inactivity ceiling on the order
//! of 30 minutes.
//!
//! - Per-handle read cache. Each open File handle holds an in-memory
//! buffer. On a cache miss the driver fetches a configurable byte
@@ -95,11 +97,14 @@ mod attrs;
mod dir;
mod driver;
mod errors;
#[cfg(not(target_os = "linux"))]
mod fallback_watchdog;
mod lifecycle;
mod paths;
mod read;
mod read_cache;
mod state;
#[cfg(target_os = "linux")]
mod wedge_watchdog;
mod write;