Click here to Skip to main content
Click here to Skip to main content

WSTD-Ftp, A neat FTP server

, 10 Mar 2006
Rate this:
Please Sign up or sign in to vote.
An article about a neat FTP server I've written, called WSTD-Ftp.

Introduction

As far as I know, there's a lack of free Windows FTP servers available for download on the Internet. This seemed to me a bit weird since I think that writing a decent FTP server is not such hard a task. To prove my point, I've written this FTP server which implements all the necessary abilities I could think of. It supports multiple users, per-directory permissions, data transfer rate limiting, and it also prints out a nice log file! The only downside is that due to severe laziness, I've never written a Settings dialog for the application, which means that settings should be modified manually using regedit (but it's a great deal of fun, believe me! Smile | :) .

Also, please use WSTD-Ftp without any warranty, I guess that there might be some bugs inside the code (which I would like to hear about) that could make this server vulnerable!

Using the code

First, let's start with the tricky part, the configuration. When you first run the server, it would load the default configuration into the registry (HKCU\Software\WSTD\WSTDFtp). This is the server configuration (which includes things like server port etc.), the default configuration is OK. What you need to do is, configure a user or two, so people would be able to log on to your server. Use the "users.reg" file from the ZIP, it would load into the registry the configurations of two users: Anonymous and Admin. They both require the existence of the following tree on your hard drive:

C:\ftproot (home directory)
C:\ftproot\pub (where Anonymous can only read files)
C:\ftproot\incoming (where Anonymous can only write files)
C:\ftproot\junk (where Anonymous can do anything)

Admin can do anything anywhere (under C:\ftproot). Anonymous requires no password and has a limit of 5 Kb per second for transfers. Admin's password is "12345" and its data transfer rate is unlimited.

Use regedit and take a look at HKCU\Software\WSTD\WSTDFtp, you'd figure out in a minute how it's all done.

Now for the code structure, it is pretty much straightforward. I tried to use as many classes as possible to make it all nice and clear.

The code includes a Path class which knows how to do important stuff like combining paths and canonicalizing paths. From the moment a user logs on, all file system operations are done by the FtpFS class. It opens files, directories for listing, and more using the logical FTP paths (where "/" means the home directory) and while validating directory permissions.

A directory's permissions are defined to be the permissions of the closest ancestor directory for which permissions were manually declared. So, for instance, if we disallow write inside "pub" but we don't declare permissions for "pub/sub" then writing is disallowed in "pub/sub" as well. If permissions aren't declared for a directory and also for none of its ancestor directories, then the default permissions are used.

All actual FTP commands handling is done in ftpclient_cmds.cpp, each command has a function of its own.

Well that's about it, it might sound a bit frightening but the code is honestly simple: just start in main.cpp and follow the code...

Points of Interest

Writing FTP servers is not that difficult and so there should be many free Windows FTP servers available for download on the Internet!

P.S.: This is my first post on CodeProject, so please be easy on me... :$

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Moagiz
Web Developer
Israel Israel
An Israeli C++ programmer.

Comments and Discussions

 
Generalvery slow PinmemberMember #160677122-Feb-07 7:29 
QuestionI want to know how the trasfer rate limit implement in the application? PinmemberJim Cai23-Oct-06 21:34 
AnswerRe: I want to know how the trasfer rate limit implement in the application? PinmemberMoagiz16-Dec-06 7:05 
GeneralA question. Pinmemberforeverfenjin2-Apr-06 14:46 
GeneralRe: A question. PinmemberMoagiz3-Apr-06 4:51 
GeneralRe: A question. Pinmemberforeverfenjin3-Apr-06 7:46 
GeneralRe: A question. PinmemberMoagiz3-Apr-06 21:24 
GeneralRe: A question. PinmemberMoagiz4-Apr-06 1:29 
GeneralRe: A question. Pinmemberforeverfenjin4-Apr-06 2:23 
GeneralRe: A question. Pinmemberforeverfenjin4-Apr-06 3:45 
GeneralRe: A question. PinmemberMoagiz4-Apr-06 8:31 
GeneralRe: A question. Pinmemberforeverfenjin5-Apr-06 5:44 
GeneralCrash PinmemberBrad Bruce25-Mar-06 15:21 
GeneralRe: Crash PinmemberMoagiz25-Mar-06 20:42 
GeneralRe: Crash PinmemberBrad Bruce26-Mar-06 3:08 
GeneralRe: Crash PinmemberMoagiz26-Mar-06 5:12 
GeneralWelcomeFile field PinmemberPiccinano18-Mar-06 1:50 
GeneralRe: WelcomeFile field PinmemberMoagiz18-Mar-06 2:31 
GeneralRe: WelcomeFile field PinmemberMoagiz18-Mar-06 6:43 
GeneralRe: WelcomeFile field PinmemberPiccinano18-Mar-06 23:51 
GeneralSmall bug in the String class Pinmembernkul14-Mar-06 20:28 
GeneralRe: Small bug in the String class PinmemberMoagiz14-Mar-06 20:44 
Generalmissing file attribute in v6 Pinmemberwhoisthis14-Mar-06 7:13 
GeneralRe: missing file attribute in v6 PinmemberMoagiz14-Mar-06 7:27 
GeneralRe: missing file attribute in v6 Pinmemberwhoisthis14-Mar-06 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 10 Mar 2006
Article Copyright 2006 by Moagiz
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid