📄 tftp.doc
字号:
FTP server component for Borland DELPHI 4 (version 1.0, 12/09/1999)
====================================================================
Nobody told you that
it would work.
Author.
My English is still not good enough. So be prepared... Besides I hate to
write any kind of documentation.
TFTP is a freeware component. You can freely use this software during the
test period of 100 years. After that period you must delete this software
and install something more useful.
You don't have to send me anything (I mean money, postcards, automobiles,
photos etc.) in order to use this software. But I will very appreciate
to see at least a small bug report.
I gonna improve this software in case if I will have enough time and
requests. Of course you can do it yourself, because I have included the
full sources with the TFTP distribution.
Rem.: Sorry for interfering with the TFTP standard name - I didn't know
this name when I wrote my TFTP component.
Asscover (disclaimer)
=====================
TFTP component is distributed "As Is". No warranty of any kind is granted.
You use this software at your own risk. Author will not be liable for
data loss, damages, loss of profits or any other kind of loss while using
or misusing this software.
I am sure that there are a lot of bugs in this code. But this it only the
first release.
Introduction
============
TFTP is an FTP server component you can use to create your own FTP server
using the Borland DELPHI 4 compiler. You can try to recompile it in order
to use with another versions of Delphi.
It almost supports the RFC-959 standard. But I never seen any FTP server,
which supports this standard in full.
I have included the example of the FTP server based on TFTP component.
It is included as an example only. I will not support this FTP server
application in any way. By the way, I use this FTP server on my home PC.
It covers all my needs.
Rem: This component needs a TCP/IP protocol to be installed on the PC.
Specification
=============
TFTP component use standard FTP port 21 to listen for the incoming
connections. This port number can be changed (for security purposes).
Initial value of the data port is 20. But usually it changing during
the FTP session according to the behavior of the PORT and PASV
commands.
TFTP component supports following FTP commands:
NOOP No operation
USER User name
PASS Password
CWD Change the work directory
XCWD Change the work directory
CDUP Change the work directory one level up
XCUP Change the work directory one level up
QUIT End session
REIN Start a new session without closing the data connection
PORT Define a data connection parameters
PASV Switch to passive mode
TYPE Choose a type of data to be transmitted
MODE Choose a protocol (limited support)
RETR Retrieve a file
STOR Store a file
STOU Store a file with the unique name
APPE Append a file
RNFR Rename from
RNTO Rename to
ABOR Abort
DELE Delete a file
PWD Print the current work directory
XPWD Print the current work directory
LIST List of files for the current directory
NLST List of files for the current directory
SYST System name
STAT Current status
HELP Command help (very short)
SIZE Size of the specified file
MDTM Get file modification time
In order to use TFTP component you have to set up at least a virtual
directory tree (TDirList object).
Rem.: I don't know any FTP server, which use BLOCK or COMPRESSED
transfers. So I didn't implement this code either.
Detailed description
====================
TFtpSrvr
--------
Unit: FtpSrvr
Properties:
1. property Enabled : Boolean;
Use it to enable/disable the component.
2. property DirRestrict : Boolean read FDirRestrict write FDirRestrict;
3. property ListFormat : TLsFmt read FListFormat write WListFormat;
Defines the directory list format. Can be lf_UNIX, lf_DOS or
lf_CUSTOM (see CustomList property).
4. property CustomList : String read FCustomList write WCustomList;
If the ListFormat property is equal to lf_CUSTOM then contains of
CustomList property defines the directory lis format. Supported
macros are:
%r - attributes (UNIX format)
%R - attributes (uppercase)
%u - owner name
%U - owner name (uppercase)
%g - group name
%G - group name (uppercase)
%I - owners user ID
%i - group id
%f - file name
%F - file name (uppercase)
%d - file date (UNIX format)
You can specify the width of the field. For example %u:8
5. property MaxConn : Integer read FMaxConn write FMaxConn;
Maximum number of concurent connections.
6. property FtpPort : Integer read FFtpPort write FFtpPort;
The default port number for control connection.
7. property DataPort : Integer read FDataPort write FDataPort;
The default port number for data connection.
8. property ShowHidden : Boolean read FShowHidden write FShowHidden;
If this property set to FALSE then no hidden files will shown
in the directory list.
9 .property ShowReadOnly : Boolean read FShowReadonly write FShowReadonly;
10.property Mode : TMode read FMode write FMode;
Current file transfer mode.
11.property AllowRedirect : Boolean read FAllowRedirect write FAllowRedirect;
Enable/disable the PORT command.
12.property AllowAnonymous: Boolean read FAllowAnonymous write FAllowAnonymous;
13.property BannerMsg : TStringList read FBannerMsg write WBannerMsg;
14.property PasswordMsg : string read FPasswordMsg write FPasswordMsg;
15.property FreePasswdMsg : string read FFreePasswdMsg write FFreePasswdMsg;
16.property NoAnonymousMsg: string read FNoAnonymousMsg write FNoAnonymousMsg;
17.property CaseSensitive : Boolean read FCaseSensitive write FCaseSensitive;
Methods:
1. procedure Open;
Make the FtpSrvr object operational. Same as:
FtpSrvr.Enabled:=true;
2. procedure Close;
Make the FtpSrvr object unoperational. Same as:
FtpSrvr.Enabled:=false;
3. function Load : boolean;
Stores all settings into the Windows Registry database.
4. function Save : boolean;
Restores all settings from the Windows Registry database.
Events:
property OnLog : TLogEvent;
property OnLogin : TUserEvent;
property OnLogout : TUserEvent;
property OnChDir : TUserEvent;
property OnDownload : TUserEvent;
property OnUpload : TUserEvent;
property OnCommand : TUserEvent;
property OnError : TErrorEvent;
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Warning: Logging was changed since previous version.
- - - - - - - - - - - - - - - - - - - - - - - - - - -
TLogEvent = procedure (Sender : TFtpThreades; var Event : TEventInfo) of object;
TUserEvent = procedure (Sender : TObject; var Event : TEventInfo) of object;
TErrorEvent = procedure (Sender : TObject; ErrNo : integer) of object;
type
TEventInfo = record
Event : word;
Error : word;
User : string;
Pwd : string;
Group : string;
Home : string;
CDir : string;
Fname : string;
Cmd : string;
Par : string;
IP : array [1..4] of byte;
Done : boolean;
Result : boolean;
end;
If EventInfo.Event is equal to CS_COMMAND then you can set the
field EventInfo.Result to false in case if you do not allow user
to execute the appropriate command.
Objects:
1. UserList : TUserList;
List of users. See the TUserList object.
2. GrpList : TGrpList;
List of groups. See the TGrouList object.
3. DirList : TDirList;
Virtual directory tree. See the TDirList object.
TDirList
--------
Unit: FtpObj
Methods:
1. function AddDir(Path,Alias : string; Attrib : TDirAttrib; UID,GID : word) : integer;
You can use this function to add new or modify existing entry of
the virtual directory tree.
2. function Load : boolean; virtual;
Restores the virtual directory tree from the Windows Registry
database.
3. function Save : boolean; virtual;
Stores the virtual directory tree into the Windows Registry
database.
4. function IndexOf(const S : String) : integer; override;
Returns the index of given directory. Use this index as a
parameter for other TDirList metods.
Properties:
1. property Path[Index : integer] : string; Rd/Wr.
Represents the virtual directory name.
2. property Alias[Index : integer] : string; Rd/Wr.
Points to the real DOS directory.
3. property UID[Index : integer] : word; Rd/Wr.
Stores the owner ID for given virtual directory.
4. property GID[Index : integer] : word; Rd/Wr.
Stores the group ID for given virtual directory.
5. property Attrib[Index : integer] : TDirAttrib; Rd/Wr.
Stores the attributes for given virtual directory.
type
TDirAttrib = set of
(da_ReadList, { Anyone can read the directory }
da_GrReadList, { Directory group members can read the directory }
da_ReadFiles, { Anyone can read the directory files }
da_WriteFiles, { Anyone can write the directory files }
da_GrReadFiles, { Directory group members can read the directory files }
da_GrWriteFiles, { Directory group members can write the directory files }
da_Enter, { Anyone can enter the directory }
da_GrEnter); { Directory group members can enter the directory }
TUserList
--------
Unit: FtpObj
Methods:
1. function AddUser(Name : string; GID : TGroupList; Password : string;
Root : boolean; Home : string) : integer;
You can use this function to add new or modify existing entry of
the user list.
2. function Load : boolean; virtual;
Restores the user list from the Windows Registry database.
3. function Save : boolean; virtual;
Stores the user list into the Windows Registry database.
4. function AddGroup(AUID,AGID : word) : boolean;
5. function GroupsCount(AUID : word) : integer;
6. function UIDByName(AName : string) : word;
7. function GIDByName(AName : string;GIndex : integer) : word;
8. function PassByName(AName : string) : string;
9. function RootByName(AName : string) : boolean;
10.function HomeByName(AName : string) : string;
11.function InGroupByName(AName : string; AGID : word) : boolean;
Properties:
1. property UID[Index : integer] : word; ReadOnly.
2. property GID[Index : integer;GIndex : integer] : word; Rd/Wr.
3. property Name[Index : integer] : string; ReadOnly.
4. property Password[Index : integer] : string; Rd/Wr.
5. property Root[Index : integer] : boolean; Rd/Wr.
6. property Home[Index : integer] : string; Rd/Wr.
7. property GIDByUID[UID : word;GIndex : integer] : word; Rd/Wr.
8. property NameByUID[UID : word] : string; ReadOnly.
9. property PassByUID[UID : word] : string; Rd/Wr.
10.property RootByUID[UID : word] : boolean; Rd/Wr.
11.property HomeByUID[UID : word] : string; Rd/Wr.
TGrpList
--------
Unit: FtpObj
Methods:
1. function AddGrp(Name : string) : integer;
Adds a new group to the list. Do nothing if this
group is exist.
2. function Load : boolean; virtual;
3. function Save : boolean; virtual;
4. function GIDByName(Name : string) : word;
Properties:
1. property Name[Index : integer] : string read RdName;
2. property GID[Index : integer] : word read RdGID;
3. property NameByGID[GID : word] : string read RdNameGID;
ProcessList
-----------
Unit: TrdBase
This array stores a list of pointers. Each entry can be NIL. That
means that this entry does not points to any object. Otherwise this
entry points to the Control Thread object. In this case you can examine
following fields of the Control Thread object:
Usr : string[30]; Contains the current user name.
Can be changed during the session.
CDir : string[130]; Contains the current work directory.
State : integer; Thread state:
st_AUTH, st_LOGIN, st_DIALOG, st_DATA
RAddr : TAddr; Contains the IP address of the caller.
TAddr = array [1..4] of byte;
Rem.: see the TSrvCtrlThread object for information on additional
fields.
============================================================================
Contact information:
Please feel free to send any comments to the addresses below.
E-Mail addresses:
drtinus@yahoo.com (preffered)
dmitriy_drozdov@hilton.com
2:463/68.691
http://drt.lvcm.com - The site is not finished yet. See you there next
millennium.
============================================================================
If you wish to donate me some money then I can accept any amount up to
1000000 USD :-) My children like new toys and my wife likes new cars :-)
============================================================================
姰
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -