0
Windows上のPythonで動作するftpサーバーを構築しようとしています。私はpyftpdlib
の基本的な例を次のように取った。pyftpdlibは動作しますが、ポート上でリッスンしているようには見えませんが、他のftpサーバーアプリケーションが動作します。
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
def main():
# Instantiate a dummy authorizer for managing 'virtual' users
authorizer = DummyAuthorizer()
# Define a new user having full r/w permissions and a read-only
# anonymous user
authorizer.add_user('user', '12345', "c:\\temp", perm='elradfmwM')
authorizer.add_anonymous(os.getcwd())
# Instantiate FTP handler class
handler = FTPHandler
handler.authorizer = authorizer
# Define a customized banner (string returned when client connects)
handler.banner = "pyftpdlib based ftpd ready."
# Specify a masquerade address and the range of ports to use for
# passive connections. Decomment in case you're behind a NAT.
#handler.masquerade_address = '151.25.42.11'
#handler.passive_ports = range(60000, 65535)
# Instantiate FTP server class and listen on 0.0.0.0:2121
address = ('', 21)
server = FTPServer(address, handler)
# set a limit for connections
server.max_cons = 256
server.max_cons_per_ip = 5
# start ftp server
server.serve_forever()
if __name__ == '__main__':
main()
実行/実行すると待機しているようですが、それ以外はポート21を使用していません。そのプロセスから以下の出力を参照してください。
[I 2017-04-17 19:05:55] >>> starting FTP server on :::21, pid=43124 <<<
[I 2017-04-17 19:05:55] concurrency model: async
[I 2017-04-17 19:05:55] masquerade (NAT) address: None
[I 2017-04-17 19:05:55] passive ports: None
しかし、私はpyftpdlib
スクリプトが実行されているホスト上のポート21にtelnetすることはできません、リモートのWindowsホストから。私は別の独立したスタンドアロンのftpサーバー.exeを実行しているWindows上でそれは正常に動作します。リモートWindowsホストからのポート21に私はpyftpdlib
を正しく取得することはできませんので、私はそれが任意のFWまたはネットワークの問題。
私は本当にこのモジュールpyftpdlib
が機能しない理由について私の頭を傷つけています。
「ああ、私の神ベッキー...」申し訳ありませんが、私のサー・ミックス・ア・ロットの引用:):これに
:これを変更してみてください。それは私はIPv6のおかげで忘れる –