Skip to content

A simple partial implementation of the file transfer protocol, with client gui in pyqt.

Notifications You must be signed in to change notification settings

nasen23/simple-ftp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Implementation of FTP Server and Client

A simple implementation of the rfc file transfer protocol. This is just for homework.

Requirements

  • Server should be running on linux system.
  • Client require python3 and PyQt5 to work.
pip install -r client/requirements.txt

Should work just fine.

Usage

Server

First compile the source code. You can do this simply by running make. A binary file will be created at ./server/server.

Run the server with following command.

server/server [-port N] [-root DIR]

Server would be running on port N with working directory at DIR.

Client

Move into client directory.

python3 main.py

Implementation Detail

Server

The main process of server runs on a infinite loop waiting for connection from any client. If a connection is accepted, the main process create a subprocess for handling commands sent from the client. So the server supports talking to multiple clients.

Subprocesses also run on a loop receiving instructions from the client, gettings the job done and sending messages back to the client.

The subprocess receives commands from clients and parses them into a struct called CommandList. After parsing the command, the subprocess goes to ftp_{cmd} to get the job done.

States for the server/client are stored in struct server_ctx, and passed to every ftp function as a argument. So ftp functions can know whether the client has already logged in or the client has sent a PASV before a data transfer command.

Client

The FtpClient class is a wrapper around socket. It provides useful ftp functions such as login, throw errors on every bad response from server, works pretty much like ftplib from python standard library.

Uploading and Downloading file would be running in another thread, so the ui will not be freezed.

Available Server Commands

  • user
  • pass
  • port
  • pasv
  • retr
  • stor
  • quit
  • syst
  • type
  • mkd
  • cwd
  • cdup
  • pwd
  • list (partial support, does not accept any argument)
  • rmd
  • dele
  • rnfr
  • rnto
  • abor (cannot interrupt data transfer, this is actually same as quit)
  • rest

Note that server could only perform data transfer in binary mode.

Client

The client works out of the box. You don’t need to know about ftp commands to use it.

Note that it does not support user custom commands.

./screenshot/client.png

About

A simple partial implementation of the file transfer protocol, with client gui in pyqt.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published