github seregonwar/zftpd v1.4.0

latest releases: v1.7.0, v1.6.0, v1.5.0...
7 months ago

v1.4.0 Release Notes

A major update emphasizing performance enhancements, security fortifications, improved reliability, and a completely redesigned web dashboard featuring real-time transfer management.


⚡ Performance Improvements

  • Zero-copy HTTP file downloads: Leveraged sendfile(2) for HTTP responses, eliminating userspace buffer copies and boosting download throughput.
  • Sendfile burst/cooldown retry: Addressed PS4/PS5 exFAT page cache stalls (~28 MB bursts) by implementing a 1 MB read() cooldown after stalls, retrying sendfile, and falling back to buffered I/O only on immediate retry failure.
  • Filesystem-aware sendfile safety: Automatically detect unsafe filesystems (exfatfs, msdosfs, nullfs, pfsmnt) on PS4/PS5 using fstatfs() to disable sendfile and avoid kernel panics.
  • TCP auto-tuning: Enabled OS-level TCP buffer auto-tuning and optimized chunk sizes for FTP and HTTP downloads.
  • HTTP upload streaming: Introduced dedicated upload buffers and socket tuning for consistent write throughput.
  • Optimized cross-device copies: Performed direct large writes with extended sequential read-ahead hints on PS4/PS5 during file copies.
  • Lazy directory size calculation: Added GET /api/dirsize endpoint for on-demand computation with a 32-level depth limit; UI fetches sizes asynchronously post-rendering.
  • Peak server-side speeds: Achieved maximum peaks of up to 470 MB/s in server-side operations.
  • Gigabit-saturating uploads: Uploads via zhttp can fully saturate gigabit connections, reaching speeds of 113 MB/s.

🔒 Security Enhancements

  • HTTP/FTP path confinement: Implemented http_api_set_root, http_validate_and_confine, and canonical safe-path validation across all API endpoints (list, download, stats, create, upload) to block path traversal and symlink attacks.
  • CSRF hardening: http_csrf_init now fails if entropy is unavailable; enforced CSRF validation on state-changing operations; disabled uploads on CSRF init failure.
  • FTP PORT IP validation: Rejected PORT commands with mismatched IP addresses (configurable via FTP_PORT_ALLOW_FOREIGN_IP).
  • Atomic connection counters: Switched HTTP connection counters and in-use flags to atomic types for thread safety.
  • Buffer pool safety: Added static asserts and bounds checks to prevent undefined behavior with large FTP_MAX_SESSIONS bitmasks.

📂 FTP Protocol Updates

  • CPFR / CPTO / COPY commands: Added full server-side file copy support with async pthread-based background copying, progress tracking, and automatic cross-device fallback.
  • Cross-device move (RNTO): Provided transparent EXDEV fallback with recursive cross-device moves for directories, including safe rollback (removes destination only if created in the current operation).
  • STOR zero-window fix: Fixed ~800 KB upload stalls on PS4/PS5 due to SO_RCVBUF capping; enforced single-buffer mode with conditional buffer increases.
  • Graceful shutdown: Ensured proper session pool cleanup and TCP buffer reset upon server stop.
  • Better error messages: Delivered detailed, human-readable 550 replies for rename/copy errors, enabling clients like FileZilla and WinSCP to display actionable feedback.

🌐 Web Dashboard Redesign

  • Transfer management cards: Displayed real-time progress with speed, elapsed time, percentage, progress bar, and destination path (→ /path).
  • Pause / Resume: Enabled server-side copy pausing/resuming via POST /api/copy_pause; copy thread uses 100 ms sleep-wait granularity during pauses, with cancellation support.
  • Cancel: Allowed immediate cancellation of active copies via POST /api/copy_cancel with instant UI updates.
  • Error diagnostics: Showed specific human-readable error reasons, mapping OS errnos (e.g., ENOSPC → "Disk full", EROFS → "Read-only filesystem").
  • Smart time formatting: Formatted elapsed time dynamically as Xs, Xm Ys, or Xh Ym based on duration.
  • Send To modal: Introduced a folder browser overlay for server-side copies, always starting at root / for comprehensive navigation.
  • Recursive directory deletion: Supported deleting non-empty folders with confirmation via POST /api/delete?recursive=1.
  • Context menu: Added right-click menu with actions like Download, Send To, Rename, Delete for files/folders; background menu includes New File, New Folder, Upload, Refresh.
  • Separate upload inputs: Provided distinct buttons for file and folder uploads.
  • Theme system: Offered multiple color themes with a native dropdown for touch devices.
  • Stats monitor: Included a modal overlay for disk usage, CPU temperature, RAM, process list, and network charts.

🛠 PS5 Platform Support

  • Kernel network filter: Developed ps5_net_filter module with syscall-level network hook installation using kernel R/W primitives.
  • Kernel helpers: Added kernel_get_base(), kernel_get_phys_addr() (via x86-64 4-level page table walk), and kernel_clear_pte_nx() using ps5-payload-sdk primitives (KERNEL_ADDRESS_TEXT_BASE, kernel_copyout, kernel_mprotect).
  • PFS inode lock serialization: Serialized O_CREAT opens on PS4/PS5 with a mutex to avoid inode-allocation lock contention (preventing >20s delays).
  • Extended TCP buffers: Increased FTP_TCP_RCVBUF to 4 MB on PS4 to match PS5 and handle PFS write latency.

🐛 Bug Fixes

  • sendfile EINTR handling: Treated EINTR as partial sends to prevent retransmitting already sent bytes.
  • Temp filename overflow: Resolved buffer overflow in temporary filename generation; now places temp names in the destination directory.
  • fd leak on interrupted close: Adjusted for differing EINTR semantics between FreeBSD/PS consoles and Linux to avoid leaked file descriptors.
  • Passive mode bind/select: Corrected socket binding and select() issues in passive mode on PS4/PS5.
  • Post-delete verification: Verified path removal after unlink/rmdir in DELETE API to detect silent failures.
  • Upload stats display: Enhanced drop zone overlay with real-time upload stats and a close button.
  • POSIX_FADV_DONTNEED disabled on PS4: Prevented unsupported fadvise calls from disrupting operations.

📦 Build & Tooling Updates

  • Unified platform defines: Introduced PLATFORM_PS4 / PLATFORM_PS5 alongside PS4 / PS5 in config headers.
  • HTTP confinement tests: Created test_http_confinement.c suite for validating path traversal and symlink protections.
  • Makefile improvements: Updated test target to include LIB_OBJECTS; raised HTTP sendfile chunk size to 1 MB.

Release Downloads

Full Diff: 38 files changed, ~40,000 insertions, ~15,000 deletions.

Full Changelog: View on GitHub

Don't miss a new zftpd release

NewReleases is sending notifications on new releases.