python ftp server库_Python FTP server library (pyftpdlib) --安装lib方式

狄峻熙
2023-12-01

Python FTP服务器是一个使用异步接口的服务器,基于asyncore模块的pyftpdlib提供Python语言最完整支持RFC959 的FTP服务器。

Python FTP server library provides a high-level portable interface to easily write asynchronous FTP servers with Python. Based on asyncore framework pyftpdlib is actually the most complete RFC959 FTP server implementation available for Python programming language.

Features

High portability:

Entirely written in pure Python, no third party modules are used. It just should work on any system where select( ) or poll( )are available.

Extremely flexible system of "authorizers" able to interact with account and password database of different systems (Windows NT, Unix/Linux, OSx and so on...).

High performance: thanks to asyncore framework it permits multiplexing I/O with various client connections within a single process / thread.

Extremely simple and highly customizable thanks to its simpler Object Oriented API.

Compact: the entire library is distributed in a single file (ftpserver.py).

Support for FXP, site-to-site transfers.

NAT/Firewall support with PASV (passive) mode connections.

Support for resumed transfers.

Per-user messages configurability.

Maximum connections limit.

Per-source-IP limits.

Quick start

>>> from pyftpdlib import ftpserver

>>> authorizer = ftpserver.DummyAuthorizer()

>>> authorizer.add_user('user', '12345', '/home/user', perm=('r', 'w'))

>>> authorizer.add_anonymous('/home/nobody')

>>> ftp_handler = ftpserver.FTPHandler

>>> ftp_handler.authorizer = authorizer

>>> address = ("127.0.0.1", 21)

>>> ftpd = ftpserver.FTPServer(address, ftp_handler)

>>> ftpd.serve_forever()

Serving FTP on 127.0.0.1:21

[]127.0.0.1:2503 connected.

127.0.0.1:2503 ==> 220 Ready.

127.0.0.1:2503 <== USER anonymous

127.0.0.1:2503 ==> 331 Username ok, send password.

127.0.0.1:2503 <== PASS ******

127.0.0.1:2503 ==> 230 Login successful.

[anonymous]@127.0.0.1:2503 User anonymous logged in.

127.0.0.1:2503 <== TYPE A

127.0.0.1:2503 ==> 200 Type set to: ASCII.

127.0.0.1:2503 <== PASV

127.0.0.1:2503 ==> 227 Entering passive mode (127,0,0,1,9,201).

127.0.0.1:2503 <== LIST

127.0.0.1:2503 ==> 150 File status okay. About to open data connection.

[anonymous]@127.0.0.1:2503 OK LIST "/". Transfer starting.

127.0.0.1:2503 ==> 226 Transfer complete.

[anonymous]@127.0.0.1:2503 Transfer complete. 706 bytes transmitted.

127.0.0.1:2503 <== QUIT

127.0.0.1:2503 ==> 221 Goodbye.

[anonymous]@127.0.0.1:2503 Disconnected.

 类似资料: