Click here to Skip to main content
12,454,477 members (54,573 online)
Click here to Skip to main content
Add your own
alternative version

Stats

71.2K views
1.1K downloads
25 bookmarked
Posted

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.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Generalvery slow Pin
Member #160677122-Feb-07 6:29
memberMember #160677122-Feb-07 6:29 
QuestionI want to know how the trasfer rate limit implement in the application? Pin
Jim Cai23-Oct-06 20:34
memberJim Cai23-Oct-06 20:34 
AnswerRe: I want to know how the trasfer rate limit implement in the application? Pin
Moagiz16-Dec-06 6:05
memberMoagiz16-Dec-06 6:05 
GeneralA question. Pin
foreverfenjin2-Apr-06 13:46
memberforeverfenjin2-Apr-06 13:46 
GeneralRe: A question. Pin
Moagiz3-Apr-06 3:51
memberMoagiz3-Apr-06 3:51 
GeneralRe: A question. Pin
foreverfenjin3-Apr-06 6:46
memberforeverfenjin3-Apr-06 6:46 
GeneralRe: A question. Pin
Moagiz3-Apr-06 20:24
memberMoagiz3-Apr-06 20:24 
GeneralRe: A question. Pin
Moagiz4-Apr-06 0:29
memberMoagiz4-Apr-06 0:29 
GeneralRe: A question. Pin
foreverfenjin4-Apr-06 1:23
memberforeverfenjin4-Apr-06 1:23 
GeneralRe: A question. Pin
foreverfenjin4-Apr-06 2:45
memberforeverfenjin4-Apr-06 2:45 
GeneralRe: A question. Pin
Moagiz4-Apr-06 7:31
memberMoagiz4-Apr-06 7:31 
GeneralRe: A question. Pin
foreverfenjin5-Apr-06 4:44
memberforeverfenjin5-Apr-06 4:44 
GeneralCrash Pin
Brad Bruce25-Mar-06 14:21
memberBrad Bruce25-Mar-06 14:21 
GeneralRe: Crash Pin
Moagiz25-Mar-06 19:42
memberMoagiz25-Mar-06 19:42 
GeneralRe: Crash Pin
Brad Bruce26-Mar-06 2:08
memberBrad Bruce26-Mar-06 2:08 
GeneralRe: Crash Pin
Moagiz26-Mar-06 4:12
memberMoagiz26-Mar-06 4:12 
GeneralWelcomeFile field Pin
Piccinano18-Mar-06 0:50
memberPiccinano18-Mar-06 0:50 
GeneralRe: WelcomeFile field Pin
Moagiz18-Mar-06 1:31
memberMoagiz18-Mar-06 1:31 
GeneralRe: WelcomeFile field Pin
Moagiz18-Mar-06 5:43
memberMoagiz18-Mar-06 5:43 
GeneralRe: WelcomeFile field Pin
Piccinano18-Mar-06 22:51
memberPiccinano18-Mar-06 22:51 
GeneralSmall bug in the String class Pin
nkul14-Mar-06 19:28
membernkul14-Mar-06 19:28 
GeneralRe: Small bug in the String class Pin
Moagiz14-Mar-06 19:44
memberMoagiz14-Mar-06 19:44 
Generalmissing file attribute in v6 Pin
whoisthis14-Mar-06 6:13
memberwhoisthis14-Mar-06 6:13 
GeneralRe: missing file attribute in v6 Pin
Moagiz14-Mar-06 6:27
memberMoagiz14-Mar-06 6:27 
GeneralRe: missing file attribute in v6 Pin
whoisthis14-Mar-06 9:54
memberwhoisthis14-Mar-06 9:54 
GeneralGreat work! Pin
Piccinano13-Mar-06 21:16
memberPiccinano13-Mar-06 21:16 
GeneralRe: Great work! Pin
Moagiz14-Mar-06 6:31
memberMoagiz14-Mar-06 6:31 
GeneralGood! How about a SMTP server! Pin
hsujong13-Mar-06 18:20
memberhsujong13-Mar-06 18:20 
GeneralRe: Good! How about a SMTP server! Pin
Moagiz13-Mar-06 19:08
memberMoagiz13-Mar-06 19:08 
GeneralRe: Good! How about a SMTP server! Pin
xircon29-Jan-07 14:03
memberxircon29-Jan-07 14:03 
GeneralRe: Good! How about a SMTP server! Pin
xircon29-Jan-07 14:15
memberxircon29-Jan-07 14:15 
GeneralIt's not bad Pin
AnasMH10-Mar-06 23:02
memberAnasMH10-Mar-06 23:02 
GeneralThis entry should probably Pin
Jörgen Sigvardsson10-Mar-06 11:12
memberJörgen Sigvardsson10-Mar-06 11:12 
GeneralRe: This entry should probably Pin
Moagiz10-Mar-06 21:57
memberMoagiz10-Mar-06 21:57 
GeneralRe: This entry should probably Pin
Teashirt213-Mar-06 4:45
memberTeashirt213-Mar-06 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web01 | 2.8.160826.1 | Last Updated 10 Mar 2006
Article Copyright 2006 by Moagiz
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid