2 Commits
Author SHA1 Message Date
Seregon 5e3b38902c Add EPSV/OPTS/SITE/CLNT, MLSD, HTTP stats
Adds several FTP protocol improvements and a new HTTP stats API.

FTP:
- Added EPSV, OPTS, SITE and CLNT command handlers and registered them in the command table.
- Implemented MLSD (machine-readable directory list) and redirected MLST to STAT.
- Changed USER/PASS to accept immediate login for better compatibility with Android clients.
- Relaxed PORT IP validation and added debug logging for PORT targets.
- Open data connections before sending 150 and add short pacing delay to avoid merged 150+226 replies (LIST/NLST/MLSD).
- Implemented EPSV passive socket setup and OPTS handling (UTF8/MLST) and SITE CHMOD no-op.
- Implemented atomic STOR uploads using a temp file and rename on success; cleanup on failure.
- Improved active-mode connect behavior with a short send timeout and logging; simplified data close path to match upstream behavior.
- Accept bare LF line endings from some clients and make command lookup case-insensitive.
- Enabled TCP_NODELAY on control socket and turned on FTP command logging; bumped RELEASE_VERSION to 1.2.3.

HTTP / Server infrastructure:
- Extended http_response to support in-memory streaming, segment splicing, and added APIs (set_body_ref, set_body_splice).
- Modified static serving to use splicing for injected HTML and fall back to body ref for binary assets (PNG); added image/png content-type for .png.
- Added a new /api/stats endpoint providing JSON with disk usage, items in directory, boot/uptime, and CPU temperature where available, plus numerous helper functions for gathering and formatting stats.

Build / repo:
- Updated .gitignore, added web/zftpd-logo.png and bumped embedded web resources (large generated resource changes not detailed here).

Overall these changes improve client compatibility (especially mobile/Android and GoldHEN clients), make uploads atomic, add diagnostics via the HTTP API, and enhance HTTP response streaming.
2026-02-25 23:49:34 +01:00
Seregon d09bde8174 Add pal alloc/scratch, Makefile and safety fixes
Introduce a platform allocator and scratchpad: add pal_alloc.{h,c}, pal_alloc_override.h, and pal_scratch.{h,c} (APIs and a default arena). Integrate them: add sources to the Makefile, change artifact naming and add all-platform build targets, and wire pal_scratch into main for sysctl buffer usage. Improve robustness and safety: enable FTP_LIST_SAFE_MODE in ftp_config.h, add stat-skipping and fallback behavior in directory listings, strengthen file-type checks in RETR, and harden STOR/APPE data-paths (use pool buffers, proper error handling, 64-bit counters, and logging). Fix concurrency/atomic logic in ftp_buffer_pool (use compare_exchange_strong with retry) and update ftp_session to refresh last_activity on I/O. Minor updates: mark fallback buffer as _Thread_local in pal_fileio, update docs to describe the memory strategy, bump release to 1.2.1, add tests and QA scripts, and add license headers and small metadata changes (event_loop author).
2026-02-17 20:02:15 +01:00