Coder Social home page Coder Social logo

ftpserver's Introduction

FTP Project report

This is a simple implementation of a FTP server in Java as a class project for COMP4621 (Computer Communication Networks) at Hong Kong University of Science and Technology (HKUST) in fall semester 2016.

The main features of this implementation are:

  • Works with standard Linux/Mac terminal tools ftp, telnet and curl.
  • Support for both active and passive mode connections
  • Supports binary/image and ASCII transfer mode
  • Multi threaded (multiple users can transfer files at the same time)
  • Standard control port is 1025, standard data port is 1026
  • Standard user name is "comp4621" and password "network". User name and password are not case sensitive.
  • Understands extended FTP arguments (EPSV instead of PASV and EPRT instead of EPRT).

Problems/Todos with this implementation:

  • Not working with GUI ftp clients, because they need to receive directory listings ins /bin/ls format. This implementation only prints names of files and folders, no additional information.
  • File system access is not synchronized. Two clients writing to the same file will result in invalid results.
  • If this is executed within an IDE (like Eclipse or IntelliJ IDEA), the control port likely needs to be a number larger than 1024. Java allows sockets on ports below 1024 only when the JVM is executed in super user mode (which IDEs normally don't do).
  • The number of accepted connections is not limited. This could easily be exploited to crash the server by just opening several thousands of connections until the JVM crashes.
  • This implementation can only run in Passive Mode on the same host as the client. If it needs to run on another host, the external server IP must be manually set as "myIp" in handlePasv(). This is because the Java socket implementation does not reliably return the external IP of the corresponding network device. To overcome this, one would probably have to use some kind of external API.
  • This implementation does not support IPv6.
  • No unit tests.
  • No timeouts.

General Architecture

This implementation consists of two classes: Server and Worker. They implement a basic worker scheme. The Server class is listening for new connections. As soon as it receives a new connection it will hand it of to the Worker class within a new thread. So for every new data connection a new thread will be created, making this a multi-threaded server.

The Worker class takes care of handling all FTP commands. Therefore it uses a central while-loop (line 95). Every iteration of the loop gets a new command from the input stream that is connected to the client socket.

The incoming command is sent of to a central mini-dispatcher function called "executeCommand", which splits the command from the arguments and then dispatches it with a big switch/case statement. Every FTP command has its own handler function.

For implementation details on the handler functions please refer to the comments/javadoc.

Supported FTP commands

  • USER
  • PASS
  • PASV
  • EPASV
  • PORT
  • EPRT
  • MKD
  • RMD
  • CWD
  • PWD
  • TYPE
  • RETR
  • STOR
  • QUIT
  • SYST
  • FEAT

Ressources used

ftpserver's People

Contributors

preya avatar

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.