ftphs-1.0.9.2: FTP Client and Server Library

Copyright Copyright (C) 2004 John Goerzen GNU LGPL, version 2.1 or above John Goerzen experimental systems with networking None Haskell98

Network.FTP.Server

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

# Documentation

anonFtpHandler :: forall a. HVFSOpenable a => a -> Handle -> SockAddr -> SockAddr -> IO () Source #

Main FTP handler; pass the result of applying this to one argument to handleHandler