ServU is a widely used FTP service.Program. It features simplicity, superior performance, stability, and strong scalability. It can better support FTP applications with large concurrent streams and high bandwidth.
ServU supports extension of its functions in the form of plug-ins (C ++ DLL.
I. ServU Workflow
A) default processing process of ServU
1. The client sends a download request
2. The ServU kernel processes the request.
3. Return the processing result (for example, permission judgment)
4. Return the FTP message to the client.
B) operation process when the ins and ServU are combined
1. The client sends a download request
2. The ServU notifies the DLL plug-in the form of an event to process the request.
3A. The DLL plugin captures and processes the event and returns it directly to the ServU service.
3B. The DLL plug-in ignores this event and transfers it to The ServU kernel for processing.
4. The ServU kernel processes the request.
5. Return the FTP message to the client.
Ii. Plug-in configuration
Add the following content to the servudaemon. ini configuration file:
[External] 'plug-in configuration section
Clientcheckdll1 = cutesuhook. dll 'client event processing plug-in
Eventhookdll1 = cutesuhook. dll 'event processing plug-in |
Iii. public interfaces of plug-ins
There are two types of plug-in events: client events and ftpevent events.
Two types of events are triggered by ServU and passed to the plug-in DLL.
The plug-in needs to capture client events and ftpevent events. The C ++ prototype of the capturing function is:
[Export word callback handleeventhook (rftpeventstr * peventstruc );
Export int _ cdecl handleclientevent (rclienteventstr * peventstruc );# Define export extern "C" _ declspec (dllexport) |
Note: You need to export these functions (Export)
RelatedCode: Cutesuhook. Def
[Library cutesuhook
Exports
Handleeventhook @ 1
Handleclientevent @ 2 |
Iv. Event Description struct prototype(C # description)
Customer Event Structure
[internal sealed class clientevent {// rclienteventstr structure equivalent to C ++ Public int event ; // event code (4) Public int flag ; // flag. The specific meaning depends on the event (4) Public String User ; // User Name (40) Public String aux ; // auxiliary information (512) Public String hostip ; // server IP address (16) Public uint sessionid ; // unique session ID (4) Public int domainid ; // unique domain ID (4) Public int domainport ; // domain port number (4) }; |
FTP Event Structure
[Internal sealed class ftpevent {// equivalent to the rftpeventstr structure of C ++
Public uint Event ; // Event code (4)
Public uint Subevent ; // Subevent code (4)
Public uint Sessionid ; // Unique session ID (4)
Public String User ; // User Name (40)
Public StringClientip ; // Client IP address (16)
Public String Domainip ; // Domain IP (16)
Public uint Duration ; // Event cycle, Run Time (4)
Public uint Size ; // Object size (for example, file) (4)
Public uint Hwindow ; // Send to the window handle (4)
Public uint Message ; // Message to be sent (4)
Public intptr Preplytext ; // Reply message address (4)
Public String Replytext ; // Reply message (this item is not included in the C ++ struct)
Public String Auxone ; // Note 1 (512)
Public String Auxtwo ; // Note 2 (512)
Public int Domainport ; // Domain port number
Public uint Domainid ; // Domain ID
Public uint Hisize ; // Size information
}; |
V. Event code
Customer Event code table
Internal Enum clienteventcode: int {
Connect = 31, // connection event
Close = 32, // close the event
Secureonly = 40 // whether the user must log on through a secure connection
Loginmesfile = 1, // Log On request file
Signonmes = 36, // message file for User Login
Signoffmes = 37, // The message file before the user exits
Password = 3, // verify the User Password
Ipaccess = 4, // verify the IP address
Writefile = 5, // verify the write permission (Note: only when a new file is created)
Readfile = 6, // verify the read permission
Modifyfile = 7, // verify the modification permission
Listdir = 9, // verify the permission of the running File
Changedir = 10, // verify the permission to jump to the specified directory
Deletedir = 11, // verify the permission to delete the Directory
Createdir = 12, // verify the permission to create a directory
Appendfile = 35, // verify the resume permission)
Execprog = 8, // verify the permission of the running File
Homedir = 2, // return the user's home path
Relpaths = 14, // whether to display the relative path relative to the Home Directory
Hidehidden = 13, // verify the permission to view the hidden file
Alwayslogin = 23, // always Allow Logon
Oneloginperip = 24, // whether each IP address allows only one user to log on
Logclientip = 25, // whether to record the log of the specified IP Address
Speedlimit = 26, // speed limit (bandwidth limit)
Maxusers = 29, // maximum number of users (an account)
Maxloginperip = 33, // maximum number of logon users per IP Address
Timeout = 28, // idle time timeout (unit: minute)
Sessiontimeout = 39 // set the user's timeout time (unit: minute)
} |
Note 1: Common events
Connect,Ipaccess,Password,Loginmsgfile,Homedir
NOTE 2: event occurrence Sequence
Connect->Ipaccess(X)->Password->Password->Ipaccess->Event. Login->Event. Close
Note 1: Common events
Login,Close,Hookcommand,Hookreply,Abortdown,Progdown,Enddown,Hookdown
NOTE 2: event occurrence Sequence
Login->Hookcommand/Hookreply/Hookdown->Progdown->Abortdown/Enddown
FTP event encoding table
Internal Enum ftpeventcode: int {
Connect = 2, // when the client connects to the server
Close = 3, // occurs before the client is disconnected
Login = 8, // when the customer successfully logs on
Startup = 9, // when the upload starts
Abortup = 13, // when the upload is terminated
Progup = 20, // This event will occur continuously during the upload Process
Endup = 10, // when the upload is successful
Startdown = 11, // The download starts.
Abortdown = 14, // when the download ends
Progdown = 21, // This event will occur continuously during the download process
Enddown = 12, // when the download is successful
Chgdir = 18, // This occurs when the user changes the directory.
Hookdown = 100, // triggered when the client needs to be downloaded
Hookup = 101, // triggered when the client needs to upload
Hooksite = 108, // triggered when the site XXX command is executed
Hookchgdir = 109, // occurs when the client changes the current directory
Hookcommand = 110, // triggered when the client issues a command
Hookreply = 111 // FTP reply message will trigger this event
} |