0

通配符支持已从 giampaolo/pyftpdlib 库中删除。通配功能在 r358 之前可用。我们可以回到 r357 来查看删除的内容并重新实现它。 https://github.com/giampaolo/pyftpdlib/issues/106#issuecomment-44425620

不支持通配符的通配符(例如,NLST *.txt将不起作用)。” - 来自合规性文档https://github.com/giampaolo/pyftpdlib/blob/64d629aa480be4340cbab4ced1213211b4eee8db/docs/rfc-compliance.rst

此外,他建议在 NLST 上使用 MLSD 作为可能的解决方案。 https://github.com/giampaolo/pyftpdlib/issues/106#issuecomment-44425620。我的猜测是,通过修改库,可以恢复通配符功能。

有谁知道如何实现这一目标?

额外细节:

我们遵循本教程并使用出色的pyftpdlib Python 库在 Ubuntu 14.04 上创建了一个 FTP 服务器。设置服务器、添加用户和创建挂钩很容易。

一些客户端使用 mget 直接从他们的服务器与我们的 FTP 服务器通信。如果您直接指定文件名,则 mget 命令有效,但传递通配符失败。这是一个示例响应:

ftp> dir
229 Entering extended passive mode (|||26607|).
125 Data connection already open. Transfer starting.
-rw-r--r--   1 serverpilot serverpilot      914 Oct 06 19:05 index.php
226 Transfer complete.
ftp> mget *.php
No such file or directory.
ftp> glob
Globbing off.
ftp> mget *.php
mget *.php [anpqy?]? y
229 Entering extended passive mode (|||60975|).
550 No such file or directory.
ftp> mget index.php
mget index.php [anpqy?]? y
229 Entering extended passive mode (|||17945|).
125 Data connection already open. Transfer starting.
100% |***************************************************************************************************************************************************************|   914      763.53 KiB/s    00:00 ETA
226 Transfer complete.
914 bytes received in 00:00 (692.99 KiB/s)

我们的脚本如下所示:

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer


# The port the FTP server will listen on.
# This must be greater than 1023 unless you run this script as root.
FTP_PORT = 2121

# The name of the FTP user that can log in.
FTP_USER = "myuser"

# The FTP user's password.
FTP_PASSWORD = "change_this_password"

# The directory the FTP user will have full read/write access to.
FTP_DIRECTORY = "/srv/users/serverpilot/apps/APPNAME/public/"


def main():
    authorizer = DummyAuthorizer()

    # Define a new user having full r/w permissions.
    authorizer.add_user(FTP_USER, FTP_PASSWORD, FTP_DIRECTORY, perm='elradfmw')

    handler = FTPHandler
    handler.authorizer = authorizer

    # Define a customized banner (string returned when client connects)
    handler.banner = "pyftpdlib based ftpd ready."

    # Optionally specify range of ports to use for passive connections.
    #handler.passive_ports = range(60000, 65535)

    address = ('', FTP_PORT)
    server = FTPServer(address, handler)

    server.max_cons = 256
    server.max_cons_per_ip = 5

    server.serve_forever()


if __name__ == '__main__':
    main()

基于这个问题,通配符似乎被故意排除在库之外。作为参考,这也是我自己的问题

谁能提供更多见解或指导我重新启用通配符?

4

0 回答 0