root/trunk/twisted/tap/ftp.py

Revision 25168, 1.4 KB (checked in by exarkun, 22 months ago)

Merge remove-mktap-3393

Author: kehander1, exarkun
Reviewer: ralphm, itamar
Fixes: #3393

Remove almost all references to mktap(1) from the Twisted documentation.

The finger tutorial still refers to mktap since it also contains an
old-style plugin which will not work with twistd.

Line 
1
2# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3# See LICENSE for details.
4
5
6"""
7I am the support module for making a ftp server with twistd.
8"""
9
10from twisted.protocols import ftp
11from twisted.python import usage
12from twisted.application import internet
13from twisted.cred import error, portal, checkers, credentials
14
15import os.path
16
17
18class Options(usage.Options):
19    synopsis = """[options].
20    WARNING: This FTP server is probably INSECURE do not use it.
21    """
22    optParameters = [
23        ["port", "p", "2121",                 "set the port number"],
24        ["root", "r", "/usr/local/ftp",       "define the root of the ftp-site."],
25        ["userAnonymous", "", "anonymous",    "Name of the anonymous user."],
26        ["password-file", "", None,           "username:password-style credentials database"],
27    ]
28
29    longdesc = ''
30
31
32def makeService(config):
33    f = ftp.FTPFactory()
34
35    r = ftp.FTPRealm(config['root'])
36    p = portal.Portal(r)
37    p.registerChecker(checkers.AllowAnonymousAccess(), credentials.IAnonymous)
38
39    if config['password-file'] is not None:
40        p.registerChecker(checkers.FilePasswordDB(config['password-file'], cache=True))
41
42    f.tld = config['root']
43    f.userAnonymous = config['userAnonymous']
44    f.portal = p
45    f.protocol = ftp.FTP
46   
47    try:
48        portno = int(config['port'])
49    except KeyError:
50        portno = 2121
51    return internet.TCPServer(portno, f)
Note: See TracBrowser for help on using the browser.