Giter Club home page Giter Club logo

minimalftp's People

Contributors

guichaguri avatar kyze8439690 avatar sealedtx avatar stashymane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minimalftp's Issues

Read Only FTP

Hi, I would like to implement a read only FTP server. How to do this? Do I need to disable some default command or other things?

Thank you.

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.

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);

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

Disabling PASV command & features

I am currently trying to run a custom FTP implementation via Docker, and I am not able to expose all ports for PASV to work properly.
Specifying a port range would more or less resolve this issue, however just disabling PASV would be a great solution as well.

Currently, I re-register the PASV command on each connection to return 502 not implemented as a workaround, however this still trips up many FTP clients and gets the connection stuck.

An alternative solution would be to allow us to unregister commands & features on the fly.

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

Improper connection closing. CPU usage 100%

Improper closing by client causes infinite handling exception SocketException inside IOException catch block produced by reader.readline():

try {
line = reader.readLine();
} catch(SocketTimeoutException ex) {
// Check if the socket has timed out
if(!dataConnections.isEmpty() && (System.currentTimeMillis() - lastUpdate) >= timeout) {
Utils.closeQuietly(this);
}
return;
} catch(IOException ex) {
return;
}

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

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

The commands of "List" and "NLST" get wrong arg, and they should can be applied to not only directories but also files

Dear developer, I may find some problems in the program, please consider:

In your code, you use the function "com.guichaguri.minimalftp.handler.FileHandler.list(String args[]) ,line 230" to handle a receiving LIST command . But line 236

Object dir = args.length > 0 && !args[0].equals("-l") && !args[0].equals("-a") ? getFile(args[0]) : cwd;

may gets wrong dir.
In my opinion, if args[0] equals "-a", we should use arg[1] to get file rather than cwd. In this case, ftp client may use a Path as arg[1] to represent the directory, or "." to represent cwd.

And the second problem is that the function response wrong code to client when the path is not directory. Actually, some ftp client would use LIST command to get information of a file. So, ftp servers so response information in this case. When receiving a LIST command whith a path arg representing a file, just response like that the file is a directory than only has a file (itself) . I have read the source code of "org.apache.ftpserver.command.impl.LIST", which handles the LIST command in a Apache FTP server, and I find it do so.

The similar function nlst(String args[]) that handles NLST command may have same problems.

java.lang.IllegalArgumentException: Unknown pattern character 'Y'

Crash log:

Caused by java.lang.IllegalArgumentException: Unknown pattern character 'Y'
       at java.text.SimpleDateFormat.validatePatternCharacter(SimpleDateFormat.java:314)
       at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:289)
       at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:356)
       at com.guichaguri.minimalftp.Utils.<clinit>(Utils.java:49)
       at com.guichaguri.minimalftp.FTPServer.listen(FTPServer.java:201)

Problem line:

private static final SimpleDateFormat mdtmFormat = new SimpleDateFormat("YYYYMMddHHmmss", Locale.ENGLISH);

private static final long sixMonths = 183L * 24L * 60L * 60L * 1000L;

Crash platform:

  • Android 5
  • Android 5.1
  • Android 6

According to Java SimpleDateFormat document, Year can be represented by lower case 'y', Upper case 'Y' represent Week year, which is not supported in lower version of Android. Maybe you can change to lower case y to improve compatibility on Android platform?

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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.