A lightweight, simple FTP server. Pure Java, no dependencies.

Overview

MinimalFTP Build Status

A lightweight, simple FTP server. Pure Java, no libraries.

Features

Although it's named "minimal", it supports a bunch of features:

  • 100% Java, no libraries
  • Lightweight
  • Supports 57 FTP commands
  • TLS/SSL support
  • Custom File System support
  • Custom User Authentication support
  • Custom Commands support
  • Support to obsolete commands (some FTP clients might still use them)

Specification Support

The required minimum implementation is already done, however, there are still commands that can be implemented.

  • RFC 959 - File Transfer Protocol (33/33)
  • RFC 697 - CWD Command of FTP (1/1) (Obsolete)
  • RFC 737 - FTP Extension: XSEN (0/3) (Obsolete)
  • RFC 743 - FTP extension: XRSQ/XRCP (0/4) (Obsolete)
  • RFC 775 - Directory oriented FTP commands (5/5) (Obsolete)
  • RFC 1123 - Requirements for Internet Hosts
  • RFC 1639 - FTP Operation Over Big Address Records (2/2) (Obsolete)
  • RFC 2228 - FTP Security Extensions (3/8)
  • RFC 2389 - Feature negotiation mechanism for the File Transfer Protocol (2/2)
  • RFC 2428 - FTP Extensions for IPv6 and NATs (2/2)
  • RFC 2640 - Internationalization of the File Transfer Protocol (0/1)
  • RFC 2773 - Encryption using KEA and SKIPJACK (0/1)
  • RFC 3659 - Extensions to FTP (4/4)
  • RFC 4217 - Securing FTP with TLS
  • RFC 5797 - FTP Command and Extension Registry
  • RFC 7151 - File Transfer Protocol HOST Command for Virtual Hosts (1/1)
  • draft-twine-ftpmd5-00 - The "MD5" and "MMD5" FTP Command Extensions (2/2) (Obsolete)
  • draft-somers-ftp-mfxx-04 - The "MFMT", "MFCT", and "MFF" Command Extensions for FTP (1/3)
  • draft-bryan-ftpext-hash-02 - File Transfer Protocol HASH Command for Cryptographic Hashes (1/1)
  • draft-bryan-ftp-range-08 - File Transfer Protocol RANG Command for Octet Ranges (0/1)

Usage

Dependency

MinimalFTP is published on JCenter and Maven Central

Maven

<dependency>
  <groupId>com.guichaguri</groupId>
  <artifactId>minimalftp</artifactId>
  <version>1.0.6</version>
  <type>pom</type>
</dependency>

Gradle

compile 'com.guichaguri:minimalftp:1.0.6'

Ivy

<dependency org='com.guichaguri' name='minimalftp' rev='1.0.6'>
  <artifact name='minimalftp' ext='pom' />
</dependency>

API

Check out more examples here :)

// Uses the current working directory as the root
File root = new File(System.getProperty("user.dir"));

// Creates a native file system
NativeFileSystem fs = new NativeFileSystem(root);

// Creates a noop authenticator, which allows anonymous authentication
NoOpAuthenticator auth = new NoOpAuthenticator(fs);

// Creates the server with the authenticator
FTPServer server = new FTPServer(auth);

// Start listening synchronously
server.listenSync(21);
Comments
  • Error on MLSD when using filezilla client

    Error on MLSD when using filezilla client

    Hello, first of all, thanks for sharing your work. I imported the sources and called it with the suggested code:

    public static void main(String[] argv) throws IOException { File root = new File(System.getProperty("user.dir")); NativeFileSystem fs = new NativeFileSystem(root); NoOpAuthenticator auth = new NoOpAuthenticator(fs); FTPServer server = new FTPServer(auth); server.listenSync(21); }

    When connecting to localhost:21 from Filezilla client, it fails almost immediately:

    Comando: PWD Risposta: 257 "/" CWD Name Comando: TYPE I Risposta: 200 Type set to I Comando: EPSV Risposta: 229 Enabled Passive Mode (|||52773|) Comando: MLSD Risposta: 501 Missing parameters Errore: Non è stato possibile leggere il contenuto della cartella

    Sorry for the italian, the last line means "it wasn't possible to read the contents of the folder". Am I missing something?

    Cheers, and thanks again,

      Germano
    
    bug 
    opened by proofrock 7
  • Bug of LIST -a command!

    Bug of LIST -a command!

    Hi! I have found a bug! You have to replace one line in your code: FileHandler.list:236: Object dir = args.length > 0 && !args[0].equals("-l") && !args[0].equals("-a") ? getFile(args[0]) : cwd; Instead of: Object dir = args.length > 0 && !args[0].equals("-l") ? getFile(args[0]) : cwd; It doesn't work when client sends LIST -a. "-a" interprets as file that not exists. Client will have con.sendResponse(550, "Not a directory"); error. After bug having been fixed you may do things like this: sudo curlftpfs 127.0.0.1:2121 ~/mnt Than you may exec command line commands like ls, cd, cat, rm -rf and so on this ftp server being mounted on local filesystem.

    bug 
    opened by Niky4000 4
  • Server on Linux not working when accessing from Filezilla on Windows

    Server on Linux not working when accessing from Filezilla on Windows

    Hi, I'm testing MinimalFTP under Linux (x86-64, Arch Linux, JVM 10.0.2) and it doesn't seem to work when accessing it from Filezilla. I thought it was my app, but the minimal code example in your README doesn't work either.

    Please note that:

    • it doesn't work with Filezilla (remote), but the standard linux "ftp" commandline client (localhost) works fine
    • running the server under windows and accessing it with Filezilla (locahost) works
    • running the server under windows and accessing it with the linux "ftp" util (remote) works, as well
    • either server works accessing it from Firefox (both remote and localhost; read only, of course)
    • it doesn't seems to be the case that "localhost works, and everything else don't" (also: no firewall, local LAN)
    • no errors on the console (is there a way to "step up" the logging level?)

    This is the Filezilla log:

    Command: PWD Response: 257 "/" CWD Name Command: TYPE I Response: 200 Type set to I Command: PASV Response: 227 Enabled Passive Mode (127,0,0,1,146,245) Command: MLSD Response: 150 Sending file information list... Error: Data connection can't be estabilished. ECONNREFUSED - Connection refused by the server

    (I translated from italian, sorry for any imprecision).

    Thanks,

    --Germano

    opened by proofrock 4
  • IFileSystem: when delete() is called on a dir, should I delete its contents as well?

    IFileSystem: when delete() is called on a dir, should I delete its contents as well?

    Hi, when delete() is called on a directory, is it called also recursively on its contents? In Filezilla it seems so, but I don't know if it's true in general.

    I know that in a filesystem, deleting a directory deletes its contents, but I need to release resources for files.

    Thanks again,

    --Germano

    PS: I don't use links, neither hard nor symbolic

    opened by proofrock 4
  • Multithread requirements of IFileSystem.java implementations

    Multithread requirements of IFileSystem.java implementations

    Hi, the class that implements IFileSystem must be thread safe, right? Are there methods that are called by one thread only? Is there a way to make everything "one thread only"?

    Also, is it possible that two clients write on the same file, at the same time, so that the two OutputStream(s) must be "coordinated" (i.e., the second call to write() doesn't return until the close() method on the first OutputStream is called)? It's important for me to know this because the implementation is quite difficult, as it must take into account what happens when close() is not called because the client crashes.

    I'm developing a project in which FTP is not backed by a filesystem, and so I can't use the out-of-the-box locking primitives of the "real" filesystem as you seem to do in the "reference" implementation.

    Cheers, and thanks, and you did an excellent (excellent!) work,

    --Germano

    opened by proofrock 2
  • Exception NullPointerException

    Exception NullPointerException

    Exception in thread "Thread-97" java.lang.NullPointerException
       at com.guichaguri.minimalftp.FTPConnection.sendResponse(FTPConnection.java:198)
       at com.guichaguri.minimalftp.FTPConnection.processCommand(FTPConnection.java:519)
       at com.guichaguri.minimalftp.FTPConnection.process(FTPConnection.java:444)
       at com.guichaguri.minimalftp.FTPConnection.update(FTPConnection.java:556)
       at com.guichaguri.minimalftp.FTPConnection$ConnectionThread.run(FTPConnection.java:603)
    
    bug 
    opened by DevSrSouza 1
  • Improper connection closing. CPU usage 100%

    Improper connection closing. CPU usage 100%

    Improper closing by client causes infinite handling exception SocketException inside IOException catch block produced by reader.readline(): https://github.com/Guichaguri/MinimalFTP/blob/801754d65cf2005446e85cdfec16ffcb6efbbce1/src/main/java/com/guichaguri/minimalftp/FTPConnection.java#L558-L568

    Due to simple return the thread ConnectionThread hangs forever and consume a lot of CPU because of handling exceptions and filling stacktraces.

    opened by sealedtx 0
  • Q: Can you provide an example for an SSL enabled server?

    Q: Can you provide an example for an SSL enabled server?

    Specifically, how do we create a simple SSLContext to pass in?

    
    // Creates a native file system
    File ftpRootDir = getFtpRootDir();
    NativeFileSystem fs = new NativeFileSystem(ftpRootDir);
    
    // Creates a noop authenticator, which allows anonymous authentication
    NoOpAuthenticator auth1 = new NoOpAuthenticator(fs);
    
    // Creates a secure SSL server with the noop authenticator
    server3 = new FTPServer(auth1);
    server3.setExplicitSSL(false); // support SSL connections
    
    SSLContext sslContext = howDoWeBuildSimpleSSLContext(); // ???
    server3.setSSLContext(sslContext);
    
    // Start listening asynchronously
    server3.listen(InetAddress.getLoopbackAddress(), 3333);
    
    
    opened by bseib 1
Releases(1.0.6)
Owner
Guilherme Chaguri
Guilherme Chaguri
Discord IPC - Pure Java 16 library

Pure Java 16 library for interacting with locally running Discord instance without the use of JNI.

Meteor Development 8 Nov 14, 2022
Simple, server side api for drawing on maps with runtime only state and no id collisions

Simple, server side api for drawing on maps with runtime only state and no id collisions! It can be used in non-main/server threads for better performance/more fps.

null 7 Sep 2, 2022
A lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your Java awesome app.

PipelinR PipelinR is a lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your awesome Java app. PipelinR has been battle-proven on production, as

Eduards Sizovs 288 Jan 8, 2023
A lightweight staff chat plugin for BungeeCord and Spigot.

A lightweight staff chat plugin for BungeeCord and Spigot with 2-way Discord chat support and many other great features.

null 4 Mar 30, 2022
Lightweight and easy-to-use SkinChangerAPI for Bukkit plugin

Lightweight and easy-to-use SkinChangerAPI for Bukkit plugin

Gabriel MERCIER 6 Jul 1, 2022
BitBase is a Client-Server based Crypto trading platform which offers live pricing, dynamic charts, user portfolio, account settings... and much more!

BitBase-Crypto-Trading-Platform BitBase is a Client-Server based Crypto trading platform which offers live pricing, dynamic charts, user portfolio, ac

null 4 Feb 11, 2022
SpringBoot Micro Services, Discovery Server, Discovery Client, API-Gateway

SpringBoot Micro Services, Discovery Server, Discovery Client, API-Gateway

null 2 Jan 26, 2022
Spigot plugin featuring a wide variety of features for a server based on modules.

CTSNC, standing for Custom Chat, Tablist, Scoreboard, NameTag & Chat, is a all-round solution based on multiple modules each featuring a dedicated function while CTSNC acts as the core. Here all configuration files are housed for easy management and customization.

null 2 Dec 30, 2022
A simple music player bot for Discord in Java

Delete Discord A simple music player bot for Discord in Java Usage Let's start by running the .jar

Fenix 2 Sep 30, 2021
Gleam is a simple Scheme language interpreter written in Java.

Gleam Scheme Interpreter (c) 2001-2020 Guglielmo Nigri (guglielmonigri at yahoo.it, googlielmo at gmail.com) Gleam comes with ABSOLUTELY NO WARRANTY.

Guglielmo Nigri 2 Jun 6, 2022
Simple API, Complex Emails (JavaMail smtp wrapper)

Simple Java Mail Simple Java Mail is the simplest to use lightweight mailing library for Java, while being able to send complex emails including CLI s

Benny Bottema 1k Jan 5, 2023
TChart Simple and fast charts

TChart Simple and fast charts. Current version Beta 0.9.1 Preview Import jitpack.io gradle allprojects

null 30 Sep 20, 2022
A simple file sharing program

FileSharing A simple file sharing program How to use Place all the files to be shared in /html/files (symbolic links work).

AK 3 May 13, 2021
A super simple system for easily creating messages and putting them in in a file, whilst also being able to add replacements without struggle.

A super simple system for easily creating messages and putting them in in a file, whilst also being able to add replacement values without struggle. Please remember: Give constructive feedback, not negative feedback. There are probably a million things to improve, and I am aware of that.

Solyze 2 Sep 21, 2021
A simple ping plugin for amazing people.

SimplisticPing Download: https://github.com/LoJoSho/SimplisticPing/releases Paper Forum Post: https://forums.papermc.io/threads/simplisticping-a-ping-

null 3 Jan 9, 2022
⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations

⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Android UI library made by @Ramotion

Ramotion 1.9k Dec 27, 2022
Simple way of causing a bsod using the native api implemented into a 1.12.2 Forge mod

Simple-BSOD-Mod Simple way of causing a bsod using the native api implemented into a 1.12.2 Forge mod. Dowload It HERE To make your own you can go to

INZO_Technologies 5 Dec 28, 2022
A simple fabric mod which allows deepslate to be instamined

InstantDeepslate An extremely simple mod that allows you to instantly mine deepslate. This works by changing the blast resistance and break time value

null 3 Jan 31, 2022
Modern Java - A Guide to Java 8

Modern Java - A Guide to Java 8 This article was originally posted on my blog. You should also read my Java 11 Tutorial (including new language and AP

Benjamin Winterberg 16.1k Jan 5, 2023