def reset_server_opts(): # Since all pyftpdlib configurable "options" are class attributes # we reset them at module.class level. import pyftpdlib.handlers import pyftpdlib.servers from pyftpdlib.handlers import _import_sendfile # Control handlers. tls_handler = getattr(pyftpdlib.handlers, "TLS_FTPHandler", pyftpdlib.handlers.FTPHandler) for klass in (pyftpdlib.handlers.FTPHandler, tls_handler): klass.auth_failed_timeout = 0.001 klass.authorizer = DummyAuthorizer() klass.banner = "pyftpdlib ready." klass.masquerade_address = None klass.masquerade_address_map = {} klass.max_login_attempts = 3 klass.passive_ports = None klass.permit_foreign_addresses = False klass.permit_privileged_ports = False klass.tcp_no_delay = hasattr(socket, 'TCP_NODELAY') klass.timeout = 300 klass.unicode_errors = "replace" klass.use_gmt_times = True klass.use_sendfile = _import_sendfile() is not None klass.ac_in_buffer_size = 4096 klass.ac_out_buffer_size = 4096 if klass.__name__ == 'TLS_FTPHandler': klass.tls_control_required = False klass.tls_data_required = False # Data handlers. tls_handler = getattr(pyftpdlib.handlers, "TLS_DTPHandler", pyftpdlib.handlers.DTPHandler) for klass in (pyftpdlib.handlers.DTPHandler, tls_handler): klass.timeout = 300 klass.ac_in_buffer_size = 4096 klass.ac_out_buffer_size = 4096 pyftpdlib.handlers.ThrottledDTPHandler.read_limit = 0 pyftpdlib.handlers.ThrottledDTPHandler.write_limit = 0 pyftpdlib.handlers.ThrottledDTPHandler.auto_sized_buffers = True # Acceptors. ls = [pyftpdlib.servers.FTPServer, pyftpdlib.servers.ThreadedFTPServer] if os.name == 'posix': ls.append(pyftpdlib.servers.MultiprocessFTPServer) for klass in ls: klass.max_cons = 0 klass.max_cons_per_ip = 0
from pyftpdlib._compat import getcwdu from pyftpdlib._compat import FileNotFoundError from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import _import_sendfile from pyftpdlib.handlers import FTPHandler from pyftpdlib.ioloop import IOLoop from pyftpdlib.servers import FTPServer import psutil if sys.version_info < (2, 7): import unittest2 as unittest # pip install unittest2 else: import unittest sendfile = _import_sendfile() # Attempt to use IP rather than hostname (test suite will run a lot faster) try: HOST = socket.gethostbyname('localhost') except socket.error: HOST = 'localhost' USER = '******' PASSWD = '12345' HOME = getcwdu() # Disambiguate TESTFN for parallel testing. if os.name == 'java': # Jython disallows @ in module names TESTFN_PREFIX = '$pyftpd-%s-' % os.getpid() else: TESTFN_PREFIX = '@pyftpd-%s-' % os.getpid()