Handling custom SITE commands over FTP(E/S)

This article refers to a new feature that will be introduced in the upcoming Syncplify.me Server! version 4.0.

As many of you know, the FTP protocol (and therefore also both its encrypted versions FTPS and FTPES) feature a very simple way for clients to send custom commands to the server: the SITE command (RFC 959).

Some servers implement a fixed set of site-specific commands through it, but Syncplify.me Server! v4 goes beyond that and gives the server’s administrator total control over the SITE command handler behavior and response.

Thanks to a new event (OnCustomSITECommand) intercepted by the event-handling subsystem, it is now possible to run an arbitrary number of scripts upon receipt of a SITE command; such scripts have access to the parameters that were passed in the SITE command itself, and can execute custom code as well as set the response code and message.

Look at the following (trivial) example:

The above example script checks the parameter (which regardless of the command is always accessible through the Session.CurURIStem property) sent along with the SITE command. If the parameter is “hello” then it sets a custom reply and allows the execution of the site command (which simply returns the custom reply, nothing else). Instead, if the parameter is not “hello” is just disallows the execution of the SITE command, which will return an error code to the client.

Since the SITE command can be called by the client asynchronously, and at any stage of the FTP session (after login), then you now have a way to send commands to the server that will trigger the execution of your custom scripts at any time.

In the screenshot here below you can see the session log of SmartFTP sending a custom “SITE hello” to Syncplify.me Server! v4, and the server’s reply generated by the above script:

sitecmd2

Print Friendly, PDF & Email
Bookmark the permalink.

Comments are closed