当前位置: 首页>>代码示例>>Python>>正文


Python FTPServer.maxcons_per_ip方法代码示例

本文整理汇总了Python中pyftpdlib.servers.FTPServer.maxcons_per_ip方法的典型用法代码示例。如果您正苦于以下问题:Python FTPServer.maxcons_per_ip方法的具体用法?Python FTPServer.maxcons_per_ip怎么用?Python FTPServer.maxcons_per_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyftpdlib.servers.FTPServer的用法示例。


在下文中一共展示了FTPServer.maxcons_per_ip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: server_start

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import maxcons_per_ip [as 别名]
def server_start(is_verbose=False, port=None):
    if not os.path.isfile('conf.json'):
        print 'Conf file not found, please run setup.'
        sys.exit(1)
    with open('conf.json') as jd:
        template = json.load(jd)
    container.set_acc_db(str(template['user_db']), str(template['user_table']))
    container.set_shares_db(str(template['user_logs']))
    container.set_root_dir(str(template['root']))
    container.set_log_file(str(template['root']) + '/pyftpd.log')
    auth = authorizer()
    handle = handler
    handle.user_sendfile = True
    handle.timeout = None
    handle.authorizer = auth
    handle.banner = 'this is the banner'
    if port:  # untested
        address = ('', 1024)
    else:
        address = ('', 21)
    server = FTPServer(address, handle)
    server.max_cons = 256
    server.maxcons_per_ip = 1000000
    if not is_verbose:
        logging.basicConfig(filename=container.get_log_file(), level=logging.INFO)
    server.serve_forever()
开发者ID:Devon-Peroutky,项目名称:OneDir,代码行数:28,代码来源:onedir_runner.py

示例2: server_start_testing

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import maxcons_per_ip [as 别名]
def server_start_testing(is_verbose=False, port=None):
    user_db = 'test_users.db'
    user_table = 'users'
    shares_db = 'test_shares.db'
    username = 'admin'
    password = 'admin'
    root = os.getcwd() + '/test_server'
    if os.path.isfile(user_db):
        os.remove(user_db)
    if os.path.isfile(shares_db):
        os.remove(shares_db)
    if os.path.isdir(root):
        rmtree(root)
    os.mkdir(root)
    ta = TableAdder(user_db, user_table)
    cols = ['name', 'status', 'password', 'salt', 'welcome', 'goodbye']
    for col in cols:
        if col == 'status':
            ta.add_column(col, 'integer')
        else:
            ta.add_column(col)
    ta.commit()
    del ta
    with TableManager(user_db, user_table) as tm:
        salt = gen_salt()
        password = gen_hash(password, salt)
        row = [username, 1, password, salt, 'welcome', 'goodbye']
        tm.quick_push(row)
    ta = TableAdder(shares_db, username)
    cols = ['time', 'ip', 'cmd', 'line', 'arg']
    for col in cols:
        ta.add_column(col)
    ta.commit()
    del ta
    container.set_acc_db(user_db, user_table)
    container.set_shares_db(shares_db)
    container.set_root_dir(root)
    container.set_log_file(root + '/pyftpd.log')
    auth = authorizer()
    handle = handler
    handle.user_sendfile = True
    handle.timeout = None
    handle.authorizer = auth
    handle.banner = 'this is the banner'
    if port:  # untested
        address = ('', port)
    else:
        address = ('', 21)
    server = FTPServer(address, handle)
    server.max_cons = 256
    server.maxcons_per_ip = 5
    if not is_verbose:
        logging.basicConfig(filename=container.get_log_file(), level=logging.INFO)
    server.serve_forever()
开发者ID:Devon-Peroutky,项目名称:OneDir,代码行数:56,代码来源:onedir_runner.py


注:本文中的pyftpdlib.servers.FTPServer.maxcons_per_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。