C++ FTP Server Library for Windows, Linux & more

Overview

fineFTP Server

FineFTP is a minimal FTP server library for Windows and Unix flavors. The project is CMake based and only depends on asio, which is integrated as git submodule. No boost is required.

You can easily embed this library into your own project in order to create an embedded FTP Server. It was developed and tested on Windows 10 (Visual Studio 2015 / 2019) and Ubuntu 16.04 - 20.10 (gcc 5.4.0 - 10.2.0).

Features

  • FTP Passive mode (the only mode you need nowadays)
  • Listing directories
  • Uploading and downloading files
  • Creating and removing files and directories
  • User authentication (and anonymous user without authentication)
  • Individual local home path for each user
  • Access control on a per-user-basis

fineFTP does not support any kind of encryption. You should only use fineFTP in trusted networks.

Example

Using fineFTP in your application is simple. Just create an FtpServer object, add one or multiple users and start the server.

#include <fineftp/server.h>
#include <thread>
 
int main() {
  // Create an FTP Server on port 2121. We use 2121 instead of the default port
  // 21, as your application would need root privileges to open port 21.
  fineftp::FtpServer ftp_server(2121);
 
  // Add the well known anonymous user. Clients can log in using username
  // "anonymous" or "ftp" with any password. The user will be able to access
  // your C:\ drive and upload, download, create or delete files. On Linux just
  // replace "C:\\" with any valid path. FineFTP is designed to be cross-platform.
  ftp_server.addUserAnonymous("C:\\", fineftp::Permission::All);
  
  // Start the FTP Server with a thread-pool size of 4.
  ftp_server.start(4);
 
  // Prevent the application from exiting immediately
  for (;;) std::this_thread::sleep_for(std::chrono::milliseconds(100));
  return 0;
}

How to checkout and build

There is an example project provided that will create an FTP Server at C:\ (Windows) or / (Unix).

  1. Install cmake and git / git-for-windows

  2. Checkout this repo and the asio submodule

    git clone https://github.com/continental/fineftp-server.git
    cd fineftp-server
    git submodule init
    git submodule update
  3. CMake the project (Building as debug will add some debug output that is helpful so see if everything is working)

    mkdir _build
    cd _build
    cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=_install
  4. Build the project

    • Linux: make
    • Windows: Open _build\fineftp.sln with Visual Studio and build the example project
  5. Start example / example.exe and connect with your favorite FTP Client (e.g. FileZilla) on port 2121 (This port is used so you don't need root privileges to start the FTP server)

Contribute

Awesome, you want to contribute to FineFTP? Here is how you can do that!

  • Leave us a star ⭐️ (That's GitHub money!)
  • Create an issue and write about a feature you would like or a bug you have found (maybe we will find some spare time to implement it 😉 )
  • Fork this repository, implement the feature yourself and create a pull request
Issues
  • LIST sends directory listing before 150 reply

    LIST sends directory listing before 150 reply

    See the screenshot below where the client sends the "LIST" command, but the server is shown sending the directory listing to full completion prior to sending 150 reply code. This seems to almost always cause my java FTPClient to fail the first time it make a directory listing call. Note: I added some debug prints to the sendDirectoryListing() method to print the ec return code as well as the files I have in my FTP directory. image

    opened by hankedan000 11
  • Add usage of generate_export_headers to export public symbols

    Add usage of generate_export_headers to export public symbols

    Fixes #24

    As explained in #24 the purpose of this PR is to only export the public symbols of the library. By using the following CMake settings we can hide all the symbols by default:

    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
    

    After setting that, we need to export only the public symbols we want. For that we use the GenerateExportHeaders feature (which works cross-platform).

    On Linux is possible to check the number of exposed symbols in the library like this:

    # before this PR
    readelf -Ws --dyn-syms fineftp-server/libfineftp-server.so | wc -l
    2396
    
    # After this PR
    readelf -Ws --dyn-syms fineftp-server/libfineftp-server.so | wc -l
    1856
    

    I had to do some "aggressive" changes in the CMake code in order to make this work. I noticed that the CMakeLists.txt files in the folders example and fineftp-server were "self-contained" and with that setup I could not integrate the change I did here. When we use the cmake function:

    generate_export_header(fineftp-server
      EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/fineftp_export.h
      BASE_NAME FINEFTP
    )
    

    It was generating the export file inside the buildDirectory/fineftp-server/ and afterwards the example project would not be able to find the file. Note that this would not happen in normal deployments of fineftp-server, since we are installing the generated export file together to the public headers.

    Anyways, if you feel like the changes I did to the CMake code are breaking some use case (I hope not), we can discuss how to proceed :wink:

    opened by piponazo 6
  • How Make Client?

    How Make Client?

    Hello, how to make a client from this server by an easy way? I know that server and client have almost equal code but I tried so hard and without success.

    opened by PoweredByAndrox 6
  • Support for SIZE command and cross-compilation on Linux to Windows

    Support for SIZE command and cross-compilation on Linux to Windows

    This pull request adds support for the SIZE command. Preliminary support for cross-compilation on Linux to Windows is also added. See the example CMake toolchain file. There are some issues wrt support for wstring in the fstream constructor when cross-compiling with GCC 7.5.0. I've therefore had to disable the UTF8 supporting code in 1 place. The changes have been tested on Windows (based a cross-compiled exe built on Linux), only.

    opened by bjuulp 3
  • New FTP Command: SIZE

    New FTP Command: SIZE

    There is a FTP command (file size) that I needed, and it's not implemented in fineFTP. If this request is eligible, I can implement this command and create a pull request.

    Definition of SIZE command in RFC-3659

    opened by s4asyn 2
  • Question

    Question

    I wrote a client program myself and successfully connected to your FTP server, but failed to create and delete folders on your server. Can you help me find out what went wrong? Grateful.

    void del(char *usr_cmd) { time_t t_time; t_time=time(NULL); struct tm* tv=localtime(&t_time); char *cmd = strchr(usr_cmd,' '); char filename[1024]; if(cmd == NULL) { printf("command error!\n"); cout<<asctime(tv); return; } else { while(*cmd == ' ') cmd++; } if(cmd == NULL||cmd =="\0") { printf("command error!\n"); asctime(tv); return; } else { strncpy(filename,cmd,strlen(cmd)); filename[strlen(cmd)]='\0'; ftp_send_cmd("DELE ",filename,sock_control); ftp_get_reply(sock_control); } }

    int ftp_send_cmd(const char *s1, const char *s2, int sock_fd) { time_t t_time; t_time=time(NULL); struct tm* tv=localtime(&t_time); char send_buf[256]; int send_err, len; if(s1) { strcpy(send_buf,s1); if(s2) { strcat(send_buf, s2); strcat(send_buf,"\r\n"); len = strlen(send_buf); send_err = send(sock_fd, send_buf, len, 0); } else { strcat(send_buf,"\r\n"); len = strlen(send_buf); send_err = send(sock_fd, send_buf, len, 0); } } if(send_err < 0) printf("send() error!\n"); cout<<asctime(tv); return send_err; } error message: FTP << DELE stats FTP >> 450 Unable to delete file

    opened by yangz1998 2
  • Support for MinGW

    Support for MinGW

    I have written this post. After that, I have found some another bug which is related with strftime. So i decided to make changes to fix the issues and create pull request, Now strftime has been omitted and time string generated manually. Now it works with MinGW and tested with FileZilla. I am not sure whether you want to accept the request but I did already anway :)

    opened by OzanCansel 2
  • Binding to a specific IP endpoint

    Binding to a specific IP endpoint

    Currently, the server can only be configured with a port.

    It would be great if we could choose a specific network interface (via IP address) to bind to.

    for example:

    std::string address = "10.1.30.88";
    fineftp::FtpServer server(address, port);
    
    opened by vukovinski 2
  • Export public library symbols with GenerateExportHeader

    Export public library symbols with GenerateExportHeader

    Hi,

    First of all, kudos for this project! I just give it a try to the FTP server and works like a charm. The codebase looks quite clean and the code is easy to read :100:

    While I was trying to integrate your library in my own project, I noticed that you are not exporting the public symbols in the API. Since in my CMake code I have the following lines:

    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
    

    I get "undefined reference" linking errors when trying to use the FtpServer class.

    It would be nice to add the export of public symbols by using the GeneraExportHeader feature in CMake: https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html

    I actually would like to contribute to the project with that addition. I hope I can find sometime to do it in the next days :innocent:

    opened by piponazo 1
  • how build .exe support win7

    how build .exe support win7

    I build fineftp in win10 (Visual Studio 2019), When I running .exe in win7, They say: "The program can't start because MSVCP140D.dll is missing from your computer." how build .exe support win7 ?

    opened by xtcel 1
  • Added Unicode / UFT8 Support

    Added Unicode / UFT8 Support

    Added Unicode / UTF 8 Support for

    • MS Windows
    • Other plattforms that use UTF8 by default (e.g. Linux)

    This lifts the 7-bit ASCII character limitation (telnet characters to be more exact) and enables you to use accents like they exist in most languages, emojies, chinese characters etc.

    opened by FlorianReimold 0
  • Add explicit <cstring> include to build with with GCC 12.

    Add explicit include to build with with GCC 12.

    Hello,

    adding this include makes fineftp build with GCC 12. As this is only making something explicit that was implicit before, it should not have any effects on older platforms and/or compilers.

    Would it be possible to merge this?

    cstring provides strerror().

    opened by Blutkoete 0
  • Upload failure when file size is too big

    Upload failure when file size is too big

    I upload a file(named "FASTSTARTKIT_TRK-MPC5604P_SDK.zip") with size 760 MB (797,657,236 byte) using Ftp Client FileZilla v3.59.0. In fact, it fails to transfer the file and error occurs, but the server responses with "226 Done" Then I check the file uploaded on the server , and its size is only 314 MB (329,515,008 bytes) less than 760MB.

    The following is FileZilla client log:

    Command:	CWD /
    Response:	250 Working directory changed to /
    Command:	TYPE I
    Response:	200 Switching to binary mode
    Command:	PASV
    Response:	227 Entering passive mode (127,0,0,1,14,85)
    Command:	STOR FASTSTARTKIT_TRK-MPC5604P_SDK.zip
    Response:	150 Receiving file
    Error:		Can't read “F:\Documents\FileZillaFTPRoot\linux\FASTSTARTKIT_TRK-MPC5604P_SDK.zip”。
    Response:	226 Done
    Error:		Transfer 329,515,008 bytes (use 4 seconds) , than fatal transfer error occurs.
    
    opened by fortunely 2
  • CMake configuration fails for iOS

    CMake configuration fails for iOS

    $ cmake -B ./iOS_Build -DCMAKE_SYSTEM_NAME=iOS -G Xcode

    CMake Error in fineftp-server/CMakeLists.txt: Imported target "asio::asio" includes non-existent path

    "Asio_INCLUDE_DIR-NOTFOUND"
    

    in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

    • The path was deleted, renamed, or moved to another location.

    • An install or uninstall procedure did not complete successfully.

    • The installation package was faulty and references files it does not provide.

    opened by agioia-nav 3
  • New feature requirements

    New feature requirements

    Can you add some new features in your free time?

    1、Password validation:After the client enters the user password, it encrypts it, and then verifies it with the cipher text of the server. Only after they match each other can they log in to the server.

    2、Log record:The client's request message and connection time as well as the client's operation record and operation time are recorded through the log.

    Thank you very much !

    opened by yangz1998 3
Releases(v1.3.0)
  • v1.3.0(Jan 10, 2022)

    • Added SIZE command (Thanks to @bjuulp)
    • Fixed MinGW build issue (Also thanks to @bjuulp). Unfortunatelly, UTF8 support is broken with MinGW, so you should use Visual Studio for proper Windows builds.
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Dec 8, 2021)

    Added Unicode / UTF 8 Support for

    • MS Windows
    • Other plattforms that use UTF8 by default (e.g. Linux)

    This lifts the 7-bit ASCII character limitation (telnet characters to be more exact) and enables you to use accents like they exist in most languages, emojies, chinese characters etc.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Nov 26, 2021)

    • Added cmake Code to properly manage exported / hidden symbols. Thanks to @piponazo for this improvement!
    • Added FINEFTP_SERVER_VERSION_MAJOR / MINOR / PATCH defines
    • Restructured CMakeLists a little
    Source code(tar.gz)
    Source code(zip)
  • v1.0.13(May 26, 2021)

    • Improved compatibility with FTP Clients that send non-standard parameters along with the LIST command (e.g. ES File Explorer). From now on, fineFTP checkes whether the client sent an ls-like parameter (-a / -l / -al / -la) and ignores it. Thanks to @uu9 for the fix.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.12(Apr 29, 2021)

    • Fixed order of messages sent through the command socket In earlier versions it could occur that e.g. 226 Done would be sent before 150 Sending directory listing has been sent. This may disturb some FTP Clients. Thanks to @hankedan000 for testing.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.11(Apr 9, 2021)

    • Fixed issues with other ASIO versions Added ASIO_DISABLE_VISIBILITY Flag to fix issues when using multiple asion versions in one project. Now ASIO symbols are not exported any more.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.10(Apr 8, 2021)

    • Fixed race condition when closing file The Race condition could cause a file that was sent to the FTP Server not being flushed completely when the server returns "Done". This could cause immediate file operations to fail.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.9(Mar 9, 2021)

    • fineFTP now always returns "UNIX" as SYST response This should increase compatibility with clients that depend on that response (like Mozilla Firefox). Those clients may disconnect when they encounter an unknown OS. But they all should be OK with UNIX.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.8(Feb 19, 2021)

  • v1.0.7(Nov 10, 2020)

  • v1.0.6(Oct 21, 2020)

  • v1.0.5(Oct 16, 2020)

    Fixed race condition (v1.0.4 did not really fix it as expected).

    Before this fix, the server reported "Done" when receiving a file after it has finished receiving. It did not wait until the file was actually written to disk, so a direct renaming of the file would fail. Now the server waits until the file has been written to disk and sends "Done" after that.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Sep 21, 2020)

  • v1.0.3(Jul 27, 2020)

    • MKD return value is now RFC compliant
    • Fixed linking against asio (applications don't need to link against it any more)
    • Fixed version number in CMake
    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jun 16, 2020)

  • v1.0.1(Mar 31, 2020)

Owner
Continental
Imprint - https://www.continental.com/en/site-notice
Continental
Lightway Core is a modern VPN protocol by ExpressVPN, to deliver a VPN experience that’s faster, more secure, and more reliable.

Lightway Core NOTE: This is a preview snapshot of the Lightway repository used for both our client and server. We will be publishing a live, actively

ExpressVPN 22 Feb 17, 2022
Lightway Core is a modern VPN protocol by ExpressVPN, to deliver a VPN experience that’s faster, more secure, and more reliable.

Lightway Core is a modern VPN protocol by ExpressVPN, to deliver a VPN experience that’s faster, more secure, and more reliable.

ExpressVPN 302 Jun 15, 2022
ImmortalWrt is a fork of OpenWrt, with more packages ported, more devices supported, better performance, and special optimizations for mainland China users.

ImmortalWrt is a fork of OpenWrt, with more packages ported, more devices supported, better performance, and special optimizations for mainland China users.

null 4 Jan 31, 2022
Windows named pipe server that forwards connections to given TCP server

PipeTcp An asynchronous Windows named pipe server that forwards connections to given TCP server. Pre-built binaries can be found in Releases. Invocati

Jinoh Kang 4 May 23, 2022
C++ library for creating an embedded Rest HTTP server (and more)

The libhttpserver reference manual Tl;dr libhttpserver is a C++ library for building high performance RESTful web servers. libhttpserver is built upon

Sebastiano Merlino 660 Jun 20, 2022
Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios

Welcome to WSLg WSLg is short for Windows Subsystem for Linux GUI and the purpose of the project is to enable support for running Linux GUI applicatio

Microsoft 7.7k Jun 22, 2022
Cross-platform, single .h file HTTP server (Windows, Linux, Mac OS X)

EWS - Single .h File C Embeddable Web Server Latest Version: 1.1.4 released September 9, 2021 Supported platforms: Linux, Mac OS X, Windows License: B

Forrest Heller 75 May 18, 2022
Event-driven network library for multi-threaded Linux server in C++11

Muduo is a multithreaded C++ network library based on the reactor pattern. http://github.com/chenshuo/muduo Copyright (c) 2010, Shuo Chen. All righ

Shuo Chen 11.5k Jun 29, 2022
LAppS - Lua Application Server for micro-services with default communication over WebSockets. The fastest and most vertically scalable WebSockets server implementation ever. Low latency C++ <-> Lua stack roundtrip.

LAppS - Lua Application Server This is an attempt to provide very easy to use Lua Application Server working over WebSockets protocol (RFC 6455). LApp

null 47 Apr 25, 2022
A project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server.

PS4 Server 9.00 This is a project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server. this is fo

null 13 Jun 7, 2022
web server that will print hello world on the screen only for linux users

a simple http server side lib only for linux users Note: This lib is currently under development you can check the source code and even use it but dn'

notaweeb 11 Mar 14, 2021
Realtime Client/Server app for Linux allowing joystick (and other HID) data to be transferred over a local network

netstick What is it? Netstick enables HID devices to be remotely connected between a "client" and "server" over a network connection. It allows the ke

null 27 Jun 2, 2022
Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Feb 4, 2022
A single-header socket library for both Linux and Windows

COMS What is COMS? COMS is a single-header library designed to be simple to use. It supports TCP and UDP, Server and Client. Available for Windows and

null 5 Dec 23, 2021
Netif - Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Feb 4, 2022
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC or RDP)

Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC)

null 14 Jan 5, 2022
Drogon: A C++14/17 based HTTP web application framework running on Linux/macOS/Unix/Windows

English | 简体中文 | 繁體中文 Overview Drogon is a C++14/17-based HTTP application framework. Drogon can be used to easily build various types of web applicat

An Tao 7.5k Jun 29, 2022
Free Media Player for Windows and Linux with Youtube support.

SMPLAYER SMPlayer is a free media player for Windows and Linux with Youtube support.

Ricardo 251 Jun 26, 2022
Dolphin is an emulator for running GameCube and Wii games on Windows, Linux, macOS, and recent Android devices.

Dolphin is a GameCube / Wii emulator, allowing you to play games for these two platforms on PC with improvements.

Dolphin Emulator 8.7k Jun 21, 2022