Copyright: FreeWay FTP 2.0


About FreeWay FTP
About FreeWay FTP 2.0

© 1995-1996 Larry Nezar, B.Eng (Electronics), CNE4

e-mail: lhtn_s@elsburg1.agric.za

FreeWay FTP is FREE! Anyone anywhere can use it freely. The source code is copyrighted by myself and is also distributed freely, all I ask for is credit for writing the original source code. The software was written for Windows95.

Credits owing are as follows:

•	dWinsock 2.0, http://www.cablenet.net/pages/marc/dwinsock/index.htm © 1995-1996 Ulf Söderberg, Marc Palmer and Keith Hawes.

•	Delphi 2.0, http://www.borland.com/delphi/ © 1996 Borland intl.

•	POV-Ray 3.0, http://www.povray.org/ © 1991-1996 POV-Ray Development Team.

The FreeWay FTP home page is at http://www.agric.za/freeway/

If you want to modify the source code you must first download and install dWinsock 2.0 from the Web site listed above, the component is free if used for non-commercial purposes.


Features

A summary of features are given as follows:

The Server:

•	Supports multiple connections

•	Create user accounts for your site

•	Grant Read and Read/Write rights to directories that are inherited upwards

•	Assign a root directory to anonymous users that is invisible to the user

•	Restrict all users on their IP addresses from gaining access

•	Time-out for idle connections

•	Restrict the amount of anonymous users

•	Logging of user events

•	Active monitoring of user status

•	User can change Listening Port

•	Implements Welcome/Goodbye messages

•	Alias directories

•	Hidden from view via a Tray Icon

•	UNIX style server

•	uses DOS/Win ‘/’ as well as UNIX ‘\’ to separate directories in commands

•	context-sensitive help (including the client)

The Client:

•	Supports login to two different/same Servers

•	Create list of sites

•	Configure for different port numbers

•	All FTP commands are done via Point-and-Click

•	Viewing of remote text files

•	Transfer takes place directly between the two servers and not via the Client

•	All dialogues between the Client and Server can be monitored


FTP Server quick-start
FTP Server quick start

Create a directory somewhere that you want others to share, say ‘c:\anon’, within that directory create a sub-directory called ‘incoming’ (thus ‘c:\anon\incoming’). Copy the help file and executable to a program directory (if you haven’t already) and run it. Go to Server|configure , select the Anonymous tab, make sure that the Allow Anonymous option is selected, click in the Root edit section and click on the Browse button, select the directory you originally created for users to share (e.g. ‘c:\anon’)and click OK. In the Read-only edit section do the same. In the Read-Write edit section follow the same procedure but select the ‘c:\anon\incoming’ directory. Select the security tab, make sure that 0.0.0.0 is in the IP filter (This will allow users to log in from anywhere). Save and exit the configuration dialogue box and make sure Server|Enabled is ticked. You have now got a running FTP server that permits access only in the shared directory but allows users to download files to the ‘incoming’ directory - all other directories an drives are inaccessible. To test copy some files to your anonymous directory via windows and follow the procedure in FTP Client quick start, or alternatively use other Client software (like WS_FTP32) to make a connection. If you need context-sensitive help, either press F1 on the specific component, or if you are in the configuration box, click on the ‘?’ icon in the title bar, then the specific component.


FTP Client quick-start
FTP Client quick start

Copy the help file and executable to a program directory, if you haven’t installed it yet, and run it. The first thing you have to do is make sure you have some host’s that you want to connect to configured for your Client, go to Client|Configure and select the Sites tag. You’ll probably want your own FTP server listed here if you want to make local uploads/downloads (Before it will work you must make sure that your FTP Server is set up and working - See the FTP Server quick start for doing just this). If you have enabled your server as an anonymous provider you can set up your Client site configuration as follows: In the Name edit section type ‘My PC’ (or something similar), type in the Address section ‘localhost’ or your Internet address or your IP address (‘localhost’ is used to refer to your own machine), at the User section type ‘anonymous’ (the login user name), at the password section type your e-mail address, click on the Save button to save. Quit out of the Configuration dialogue box, you should have the Client portion in front of you. It is divided into two halves, the left half for attaching to one Server and the right side to another. Try connecting to yourself by selecting ‘My PC’ (or whatever you called yourself) from the Combo-box and wait a moment, the connection should be made automatically and you should see a directory listing, this listing was generated through an FTP connection to yourself. Try doing the same with the other half of the Client, you should have two connections open to the server. Browse around and try to transfer files from one window to another on a different directory (don’t try the same directory, and make sure you have some files in your anonymous directory). You’ll see that you can transfer files from a Read-only or Read/Write directory only to a Read/Write directory. Play around with the controls. For transferring files from a remote site to your site you have to make one connection to your own site and another connection to the remote site. To transfer between two remote sites you have to make one connection to one site and another connection to the other. Unfortunately tracking the progress between a file transfer is very difficult when data does not pass through the Client, so you must wait till the messages show that the transfer is complete. This method of using the Client is awkward at first but is soon mastered, the RFC959 makes provision for a client to have more than one control connection for transfer between Servers as I have done. If you need context-sensitive help, either press F1 on the specific component, or if you are in the configuration box, click on the ‘?’ icon in the title bar, then the specific component.


Users

This is the area where you create users for your FTP Server, you assign their rights in directories and set their passwords. A special user called anonymous is configured in a separate configuration area. See the sections related to specific items in the Users configuration area:

•	User name

•	Password

•	Home Directory

•	Read-Only Directories

•	Read-Write Directories


Anonymous

The anonymous user is a special user that is (in theory) an untrusted, unknown person whom you give limited rights to give access to some of  your shared files. This user is normally associated with anyone on the Internet/Intranet whom you don’t know, but to whom you allow to copy certain public files. Normally the only thing required from him when logging on is his e-mail address as password, so care must be taken as to what file area he has access to. You would usually only give him Read-Only access to certain files, and in certain cases give him Read/Write access to a single ‘incoming’ directory. See the sections related to specific items in the Anonymous configuration area:

•	Allow anonymous

•	Force full e-mail address

•	Anonymous root

•	Read-only Directories

•	Read-Write Directories

•	Maximum anonymous connections


Security

This is the section where you set limits on certain aspects of the Server. The very important IP Filter is here where you can block people on certain networks/addresses from logging in to your server. Besides blocking certain individuals you can also set the maximum amount of users that can log into the system concurrently, and also set a timeout for idle connections. A log file is also maintained and is stored under the windows directory as FWFTP.LOG. See the sections related to specific items in the Security configuration area:

•	Maximum connections

•	Timeout

•	IP Filter

•	Logging Level

•	Test IP Filter

•	Listening Port


Messages

This is where you create the Welcome and Goodbye messages. The Welcome message is displayed once the user logs in successfully. The Goodbye message is displayed once the user requests a close connection (quits). Both these messages are stored in the windows directory as Welcome.FTP and GoodBye.FTP and can be edited using any text-based editor. See the sections related to specific items in the Messages configuration area:

•	Message editing


Miscellaneous

Alias directories are entered here, i.e. a directory can be give a shortened name to represent it. An example would be: download = c:\dump\temp\junk. The same directory can now be accesed as ‘/download’ instead of ‘/dump/temp/junk’. See the sections related to specific items in the Miscellaneous configuration area:

•	Alias name

•	Actual directory


Using the Server

If you want to see who is currently logged in and what they are doing, select Server|Status to see an active list of users. The log-file is kept under your Windows directory and is called FWFTP.LOG and is a standard ASCII file, you will see the time and date of an event, the user who triggered the event and a description of the event (or command) that was logged. As a rule never make the root of your file-system the anonymous root (e.g. ‘c:\’), otherwise the whole world can copy your file-system and view otherwise private files. Try giving users as few Read-Write directories as possible. If you need context-sensitive help, either press F1 on the specific component, or if you are in the configuration box, click on the ‘?’ icon in the title bar, then the specific component.


Optimizing the Server

The server itself is optimized to deliver maximum transfer speed and needs no further optimization. However, make sure your disk-subsystem is reliable to avoid problems. Memory needs are minimal, 4 Megs of memory should be more than adequate. Remember, this program was written for Windows95 and was not tested on other systems.


Sites

These are remote sites that your Client connects to, a list of hosts are kept together with information that the Client needs to know to connect successfully to the site, i.e. what user name to use, what password to use, etc. See the sections related to specific items in the Sites configuration area:

•	Name

•	Address

•	User

•	Password

•	Port


Using the Client

You might be confused as to why there are two areas for connections to a host and only one set of command buttons, well, the command buttons work for both, you must just bring the one host in focus before you use a command on it (i.e. click in the directory list area, then the button you want to use on that specific host associated with the directory list). If you want to see the actual dialogue taking place between the Client and the host, select Client|Dialog and a dual tabbed window will be available for viewing the dialogue, each tab used for each individual connection of the Client to the host. See the descriptions related to specific items in the Client area:

The buttons

•	Rename

•	MkDir

•	Delete

•	ChDir

•	DirList

•	View

•	Close

•	Abort

•	Transfer buttons

Other areas

•	Mode

•	Host select combo-box

•	Current directory display area

•	Directory listing area

•	Reply from host display area

•	Status bar


Problems

If you struggle to get a listing displayed in the Directory listing area after a connection, then your host probably does not list it’s contents according to the UNIX listing standard ( most hosts do comply ). I have not made provision for any other host types to be used, although you are free to modify the source code to enable more host types to be used.


Technical Information
Technical Info

Most of RFC959 is implemented by the Server, except for some rarely used commands. The commands actually implemented are as follows:

USER, PASS, CWD, XPWD, CDUP, QUIT, PORT, PASV, TYPE, MODE, RETR, STOR, RNFR, RNTO, ABOR, DELE, MKD, PWD, LIST, NLST, SYST, STAT, HELP, RMD, NOOP.

The Mode command is not implemented in full here, only stream mode is used. Unfortunately I only had the RFC to work from, so my creation of the Server and Client was mostly trial and error.

The Server configuration file is called FTPS.INI and is found in the Windows directory. The Client configuration file is called FTPC.INI and is found in the same directory.


Programmers Information
Programmers Info

Before you try and modify the source code, you must download dWinsock 2.0 from the URL given in the About section of this help file. Unfortunately I hardly ever use comments in my source code, because tidy, comment-less code is easier for me to read than one riddled full of space-wasting comments. So if you do plan to modify the code, make sure you can read Object-Pascal like you read English. I’m sorry about this but I just have not got the time to add comments to a program. Also you professional programmers will probably criticize my programming, if you do, could you then please re-write it for everyone’s benefit? As I said before, I am not a programmer, I am a network specialist.


Tips

If you plan to use the client part of the package, and you plan to do a lot of downloading/uploading to/from your local PC to/from a remote host, rather use one of the more popular single-hosted FTP Clients to do that because of the transfer progress indicator therein. Also note that if you resize the Client area, the rest of the contents will auto-resize. Use NDS-Lookup if you’re not sure if a host is registered or not. If you need context-sensitive help, either press F1 on the specific component, or if you are in the configuration box, click on the ‘?’ icon in the title bar, then the specific component.


Enable

This enables the FTP Server to start listening for connections, disabling the server means that no connections will be accepted.


Status

This displays the active list of current users (and their IP address) on your Server, also where they are in the directory and what they are doing.


Dialog

This displays all dialogue between your FTP Client and a remote FTP server, the dialogue is raw and given in FTP protocol.


DNS Lookup

You can find the IP number of an Internet address or reverse lookup an IP number to see if there is an associated Internet address. Use this to see whether a host is registered on the Internet.


User Name

This is a login name for a user that you must create to login to your server, a user name must not contain spaces or specail characters. For Example: Larry, John, User1, NetMac1.


Password

This is the password that must be assigned to the user who intends to log on using the user name above, inform the user of the password and ask him to keep it confidential.


Home Directory

This is the default directory the user will be placed in after he logs into your system, do not forget to at least grant him Read rights to his own directory in the following sections, else he wont be able to do anything - even a simple retrieve is impossible. To enter a directory here, either type in the directory, or better, click once in the edit area, then click the Browse button to select a directory.


Read-only directories

These are the directories the specified user can retrieve files from (read), but not write to. Multiple directories are seperated by a semi-colon (‘;’). The easiest way to enter a directory is to click once in the edit area the click on the Browse button to select a directory, repeat this procedure for every directory you want to add (You do not have to type a ‘;’ between directories if you use the Browse button).


Read-Write directories

These are the directories the specified user can retrieve files from (read) and write files to (including creating directories, renaming files, removing empty directories, deleting files, etc. … ). Multiple directories are seperated by a semi-colon (‘;’). The easiest way to enter a directory is to click once in the edit area the click on the Browse button to select a directory, repeat this procedure for every directory you want to add (You do not have to type a ‘;’ between directories if you use the Browse button).


New

The New button clears the edit fields for entry of a new user.


Save

Click on this to save this user information in current focus.


Delete

This removes the user that is in focus from the user list, the user can no longer log in.


Browse

Use this when adding a directory entry to a field edit box that requires a directory entry.


Allow anonymous

Set this if you want anonymous access to your Server, otherwise only users that you created will be able to log in.


Anonymous root

This is the home directory for your anonymous user, this is also the directory that is hidden from the user so that it looks like the root of a file-system (e.g. c:\anon as root looks like c:\ to the user ), the user is given list-only access here by default. ( Read and Read-Write has to be explicitly assigned ).


Maximum anonymous connections

This specifies the maximum amount of anonymous users that can connect at any one time, you use this to specify a value less than the total maximum users (Specified under the Security section ) so that your normal users have priority to connect if the maximum anonymous limit is reached.


Save

Click on this to save this Anonymous user configuration information.


Maximum Connections

This is the maximum amount of users you can allow on your Server (anonymous users + normal users), use this in conjunction with your ‘Maximum anonymous users’ to create a reasonable amount of free connections for your normal users.


Timeout

This is the amount of seconds the server will wait on an idle connection before closing it by itself. (300 seconds = 5 minutes).


IP Filter

This is used to restrict certain users from certain networks/workstations from gaining access to your Server.  IP-numbers are first entered as higher a resolution as possible, IP-networks are used as filters (i.e. 123.23.0.0 and not 123.23.*.* ), disallowed IP-networks are enclosed in brackets '( )'. For example: (123.23.111.10);123.23.111.0;123.23.112.0;(123.23.0.0);123.0.0.0;(0.0.0.0)

This roughly translated means do not allow IP-address 123.23.111.10 through but allow the rest of 123.23.111.* through, also allow the 123.23.112.0 network to use the server, but disallow the rest of 123.23.0.0 networks through. Allow all remaining 123.*.*.* addresses through and disallow the rest of the world (0.0.0.0). read left to right as is normally easier. To allow anyone to use your Server, just enter 0.0.0.0, this means all IP addresses can pass through. To test your IP filter before you think it’s finished, see the section on ‘Test IP Filter’.


Test IP Filter

Use this to check if your IP Filter is working as you think it should. Enter some strategic IP addresses in the edit box, the click the test button. The result (pass or no pass) will be indicated in the result section below. Pass means that the specified IP address will be allowed to make a connection to your Server.


Listening Port

This is the port number your server will listen for connections on. Port numbers are usually identified with IP protocols (i.e. port 21 is for FTP control connections, 20 is for FTP data connections, 23 is for Telnet…). Some ports are available for user defined protocols/services, but in practice you can use any port number you want, as long as it doesn’t conflict with anything you are currently running on your PC. Also remember that if you change your port from the default ( 21 ), your users must configure their clients to attach to that port, otherwise they cannot connect. People normally use this to hide their Server from prying eyes on the net.


Save

Click on this to save this Security configuration information.


Message editing

The editor included with the software is fairly simple, you just select the message you want to edit in the combo-box, then type away. The Save button is used after you have finished editing and want to implement. The standard block-controls have been added ( Copy, Cut, Paste and Delete), these work with the standard clipboard, so pasting from an external editor/document is possible.


Name

This is a descriptive name for a remote site you want to configure for your client, for instance, ftp.is.co.za could be given the name of ‘General files’ or ‘Internet Solutions’, or whatever you want.


Address

This is the actual IP address or Internet address for the actual site you want listed, for example, you could use ‘ftp.is.co.za’ or ‘196.4.160.8’, they are both valid IP/Internet addresses for the same host. ( I use the term Internet address to refer to an Internet host name here). Use ‘localhost’ here if you are referring to your own PC as the host.


User

This is the name of the user account you want to use to log in to the remote site, if it is a site that supports anonymous logins, you can type ‘anonymous’ as the user name, otherwise you must use a registered name.


Password

This is the password associated with the user name of the account you want to use to login. If the user name you want to use is ‘anonymous’ then the password would be your e-mail address.


Port

This is the port that the host is configured to listen for connections on, unless otherwise configured, it should be port 21 by default.


New

The New button clears the edit fields for entry of a new host.


Save

Click on this to save this host information in current focus.


Delete

This removes the host that is in focus from the host list, the host is no longer configured for the Client.


Alias name

This is the ‘made-up’ name that you want to give for an awkward path, e.g. ‘downloads’, ‘uploads’. Do not use slashes or any other special characters in the alias name, treat it as you would a normal directory name.


Actual directory

This is the actual full path for the alias you want to create, e.g. ‘c:\anon\dump\temp’ could be associated with the alias ‘downloads’. The user on the client side would not actually see the alias as an actual directory, but could use it in any path statement e.g. get /downloads/betafile.zip, and this would be internally mapped to c:\anon\dump\temp\betafile.zip.


Rename

Renames an existing file on the remote site ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ). You need write rights on the host to do this.


MkDir

Creates a new directory on the remote site ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ). You need write rights on the host to do this.


Delete

Deletes a file or directory (depends what is selected) on the remote site ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ). You need write rights on the host to do this.


ChDir

Allows you to manually enter a path to go to on the remote host ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ).


DirList

This requests a new listing from the host and re-builds the listing in the Directory list area, you would normally do this if you suspect something changed in the directory you are currently in ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ).


View

If you want to view a text-document on the remote host without saving it for later use, this is useful for small index, contents or readme files that you just want to have a quick peek at. Just click on the file you want to view then click on the view button.


Close

If you want to logout from the host you’re connected to. ( Remember that the last host you brought into focus or clicked on, is the one that the command with be applied to ).


Abort

If you’re in the middle of a file transfer and suddenly realize that you don’t actually need the file, you press this button, it should send the appropriate commands to the hosts and stop the transfer.


Mode

You select the transfer type here (called ‘mode’ here), as a rule you transfer ASCII text file using the ‘asc’ type, and everything else using the ‘bin’ type. Select ‘bin’ if you are not sure.


Host

This is where you select one of the hosts you configured in the Client configuration dialog box, right after selection the Client will automatically try and log onto that host.


Current directory

This will display the current directory you are in at the host.


Directory Listing

This will give you the directory contents of the current directory on the host.


Reply

Look here to see weather commands have succeeded ( Including transfers ), this is the actual servers control connection reply.


Transfer buttons

Use these buttons to transfer a selected file from one host to another, the direction of the pointers will give you an indication of the direction of the transfer, select the right one. Remember that you need Write-rights on the destination host for a transfer to take place. (You need at least Read-rights on the source host).


Logging level

Here you specify what must be logged when a user loggs on to your server, loggs are kept in a file called FWFTP.LOG under the Windows directory.