# -*- Mode: Python -*- import asyncore from medusa import ftp_server # create a 'dummy' authorizer (one that lets everyone in) that returns # a read-only filesystem rooted at '/home/ftp' authorizer = ftp_server.dummy_authorizer('/home/ftp') # Create an ftp server using this authorizer, running on port 8021 # [the standard port is 21, but you are probably already running # a server there] fs = ftp_server.ftp_server(authorizer, port=8021) # Run the async main loop asyncore.loop() # to test this server, try # $ ftp myhost 8021 # when using the standard bsd ftp client, # $ ncftp -p 8021 myhost # when using ncftp, and # ftp://myhost:8021/ # from a web browser.
# -*- Mode: Python -*- # This is something you might want to use on a machine running Windows # NT or Windows 95 - simultaneously publish the directory 'd:/public' # via http and ftp, on the standard ports. import asyncore from medusa import http_server from medusa import ftp_server # Change this path to publish a different directory DIRECTORY = 'd:/public' hs = http_server.http_server(DIRECTORY, 80) fs = ftp_server.ftp_server(ftp_server.dummy_authorizer(DIRECTORY), port = 21 ) # Run the async main loop asyncore.loop()
def start_Server(): # ftpServ = ftp_server.ftp_server( ftp_server.anon_authorizer( "D:\MyDocuments\MyDownloads"), port=21 ) ftpServ = ftp_server.ftp_server(Win32Authorizer(), port=21) asyncore.loop()
uh = unix_user_handler.unix_user_handler ('public_html') hs.install_handler (uh) # =========================================================================== # FTP Server # =========================================================================== # Here we create an 'anonymous' ftp server. # Note: the ftp server is read-only by default. [in this mode, all # 'write-capable' commands are unavailable] ftp = ftp_server.ftp_server ( ftp_server.anon_authorizer ( PUBLISHING_ROOT ), ip=IP_ADDRESS, port=FTP_PORT, resolver=rs, logger_object=lg ) # =========================================================================== # Monitor Server: # =========================================================================== # This creates a secure monitor server, binding to the loopback # address on port 9999, with password 'fnord'. The monitor server # can be used to examine and control the server while it is running. # If you wish to access the server from another machine, you will # need to use '' or some other IP instead of '127.0.0.1'. ms = monitor.secure_monitor_server ('fnord', '127.0.0.1', MONITOR_PORT)
#!/usr/bin/env python #$Id: ftpsrv.py,v 1.1 2004-08-23 17:01:51 sdobrev Exp $ from medusa.ftp_server import ftp_server, dummy_authorizer, asyncore class any_authorizer(dummy_authorizer): def authorize (self, channel, username, password): r = dummy_authorizer.authorize( self, channel, username, password) channel.read_only = 0 return r import sys if not sys.argv[1:]: print 'ftps host port root' else: fs = ftp_server( any_authorizer( sys.argv[3] ), ip=sys.argv[1], port=int( sys.argv[2]), ) try: asyncore.loop() except KeyboardInterrupt: fs.log_info('FTP server shutting down. (received SIGINT)', 'warning') # close everything down on SIGINT. # of course this should be a cleaner shutdown. asyncore.close_all() # vim:ts=4:sw=4:expandtab