ftphs-1.0.3: FTP Client and Server LibraryContentsIndex
Network.FTP.Server
Portabilitysystems with networking
Stabilityexperimental
MaintainerJohn Goerzen <jgoerzen@complete.org>
Description

This module provides a server-side interface to the File Transfer Protocol as defined by:

  • RFC959, basic protocol
  • RFC1123, clarifications
  • RFC1579, passive mode discussion

Written by John Goerzen, jgoerzen@complete.org

This is a modular FTP server implementation in pure Haskell. It is highly adaptable to many different tasks, and can serve up not only real files and directories, but also virtually any data structure you could represent as a filesystem. It does this by using the System.IO.HVFS and System.IO.HVIO modules.

In addition, basic networking and multitasking configuration is handled via Network.SocketServer and logging via System.Log.Logger.

This module is believed to be secure, but it not believed to be robust enough for use on a public FTP server. In particular, it may be vulnerable to denial of service attacks due to no timeouts or restrictions on data size, and error catching is not yet completely pervasive. These will be fixed in time. Your patches would also be welcomed.

Here is an example server that serves up the entire local filesystem in a read-only manner:

import Network.FTP.Server
import Network.SocketServer
import System.Log.Logger
import System.IO.HVFS
import System.IO.HVFS.Combinators

main = do
       updateGlobalLogger "" (setLevel DEBUG)
       updateGlobalLogger "Network.FTP.Server" (setLevel DEBUG)
       let opts = (simpleTCPOptions 12345) {reuse = True}
       serveTCPforever opts $
            threadedHandler $
            loggingHandler "" INFO $
            handleHandler $
            anonFtpHandler (HVFSReadOnly SystemFS)

Hint: if you wantto serve up only part of a filesystem, see newHVFSChroot.

Synopsis
anonFtpHandler :: forall a . HVFSOpenable a => a -> Handle -> SockAddr -> SockAddr -> IO ()
Documentation
anonFtpHandler :: forall a . HVFSOpenable a => a -> Handle -> SockAddr -> SockAddr -> IO ()
Main FTP handler; pass the result of applying this to one argument to handleHandler
Produced by Haddock version 0.8