ITotalJustice has created a new lightweight, fast, and single-threaded FTP server written in C-language, compatible with several systems, including Nintendo Wii, 3DS, DS and Switch.

This project was developed to learn the FTP protocol and implements a server with low memory usage, no dynamic allocation and reduced overhead thanks to the use of functions such as poll()or, in the absence of this, select(). .
The FTP server is configurable, with a configuration file located in /config/ftpsrv/config.ini. . Each release includes a template to avoid overwriting existing configurations during updates.
On the Nintendo Switch, for security reasons, it is mandatory to set a user name and password, unless the anonymous option is enabled (anon=1).
This is especially important when used with ldn-mitm, which could otherwise allow unauthorized modifications to the SD card.
Supported platforms
The server was ported to the following platforms:
- Nintendo Switch : Both as an application and as a sys-module.
- The Nintendo Wii.
- Nintendo 3DS : Needs optimizations, as it currently uses I/O POSIX with overhead.
- Nintendo DS: The build solves a problem with dswifi and WPS support, which is not currently officially supported by devkitPro.
Also planed a port for PlayStation 4 consoles, but requires additional expertise in creating services in the background (daemon).
Problematic notes and workarounds
- Bug with Dolphin (KDE): A specific problem with the command
LISTand file.jpg/.pngin directory. The workaround consists of not sending the pathname in the command responseLIST. . - Compatibility with ffmpeg/mpv : Clients as ffmpeg use command
ABORDuring transfers, causing blockages. The implemented solution separates commands and arguments using the delimiter\r\n. .
Supported Commands Without Authentication
Standard FTP commands as well as USER, PASS, QUIT, ABORand and HELP. . However, the command PWD, according to the RFC959, it should be available without authentication, but in this implementation requires authentication and returns an error 530if not satisfied.
Future functionality
Among the features in the program are support for TLS, the addition of advanced FTP commands such as ACCT, STOUand and SITE, in addition to the validation of the sequence of commands as RNTOAfter that RNFR. .
Changelog
Fix “vfs-unistd close” and non-blocking sockets
- Previously, many sockets were blockers, causing potential locks on some platforms like Nintendo Switch. Now, control sockets are polled for outgoing data, improving responsiveness.
- Fixed a serious bug in unistd sockets that incorrectly closed
STDIN(fd-0) during the commandLIST. .
Remove of the sscanfand improvements in error messages
- Replace the uses of
sscanfwithsnprintfand andstrtolto improve performance. - Fixed a polling error on the command
PORT. . - Improved error messages for commands
RETRand andSTOR, including the full path.
asynchronous messages of control
- Messages to clients are now sent in asynchronous mode. Added an additional buffer to handle sending errors.
Session timeout and removal of sendfile
- Added a timeout for inactive sessions to prevent the consumption of all available resources.
- Temporarily removed support for
sendfile(Linux), which offered high speeds, but was not supported on other platforms.
New features and fix for Nintendo Switch (Nx)
- Support for separate options for ports between application and sys-module.
- Mounting and displaying saves, firmware dumps, and improved transfer speeds in the sys-module.
- The LED flashes during data transfers.
- New mounting options for
bis,hdd, and rescue systems. - Fixed a bug with the sysmod that ran out of socket memory.
- Added support for mounting “gc”,
romfs, and zip storage for saves.
Timeout in the data transfer cycle
- Inserted a 1ms timeout to manage situations where the disk speed is lower than that of the network, such as in the case of transfers from HDD.
General Optimizations and Updates
- Improvements in code style and add version and commit information in the build system with CMake.
- Added UTF-8 support for commands
OPTS. . - The VFS backend now handles virtual devices.
Download: ftpsrv v1.0.0 (3DS)
Download: ftpsrv v1.0.0 (NDS)
Download: ftpsrv v1.0.0 (Wii)
Download: ftpsrv v1.0.0 (Switch app) (Switch sysmodule)
Download: Source code ftpsrv v1.0.0
Source: gbatemp.net
