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


Python FTPServer.max_cons_per_ip方法代码示例

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


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

示例1: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main(profiles):
    authorizer = DummyAuthorizer()
    # 将每个profile映射为一个用户
    uploadTmpRoot = tempfile.gettempdir()
    for p, c in profiles.items():
        # perm权限定义说明:
        # Read permissions:
        # "e" = change directory (CWD, CDUP commands)
        # "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands)
        # "r" = retrieve file from the server (RETR command)
        # Write permissions:

        # "a" = append data to an existing file (APPE command)
        # "d" = delete file or directory (DELE, RMD commands)
        # "f" = rename file or directory (RNFR, RNTO commands)
        # "m" = create directory (MKD command)
        # "w" = store a file to the server (STOR, STOU commands)
        # "M" = change mode/permission (SITE CHMOD command) New in 0.7.0
        # 注意:投产时权限似乎应限制为只写,即:'w'
        uploadTmp = path.join(uploadTmpRoot, p)
        print uploadTmp
        if not path.isdir(uploadTmp):
            mkdir(uploadTmp)

        authorizer.add_user(p, c["upload"].get("password", ""), uploadTmp, perm="ledw")

    handler = UploadHandler
    handler.authorizer = authorizer
    handler.banner = "OSO fileserv"
    address = ("", int(getenv("FTP_PORT", "2121")))
    logging.basicConfig(filename="logs/ftp.log", level=logging.INFO)
    server = FTPServer(address, handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()
开发者ID:chenchen0,项目名称:fileserv,代码行数:37,代码来源:server.py

示例2: custom_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
 def custom_server(self, start=1):
     # TODO: finish me
     from pyftpdlib.authorizers import DummyAuthorizer
     from pyftpdlib.handlers import FTPHandler
     from pyftpdlib.servers import FTPServer
     # Generate random username and password for ftp session
     logging.debug('generating arguments')
     if not os.path.isdir(self.path):
         logging.info('%s create directory: %s' %
                      ('device.name', self.path))
         os.makedirs(self.path)
     # Add ftp user
     authorizer = DummyAuthorizer()
     logging.debug('generated args: user=%s password=%s path=%s perm=%s' %
                   (self.user, self.password, self.path, self.password))
     authorizer.add_user(self.user, self.password, self.path,
                         perm=self.perm)
     handler = FTPHandler
     handler.authorizer = authorizer
     # Instantiate FTP server class and listen
     logging.debug('%s ftp server listen on: %s %s' %
                   ('device.name', self.address, self.port))
     addr = (self.address, self.port)
     server = FTPServer(addr, handler)
     # Set a limit for connections
     server.max_cons = 32
     server.max_cons_per_ip = 5
     # Start ftp server
     logging.debug('starting disposable ftp server')
     server.serve_forever(timeout=600, blocking=False)
开发者ID:drunkard,项目名称:lazycat,代码行数:32,代码来源:ftp.py

示例3: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
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(konf.ftp_username,
                        konf.ftp_password,
                        'ftp/',
                        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."

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    address = ('', 2121)
    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()
开发者ID:jpf,项目名称:ftp-to-s3,代码行数:31,代码来源:server.py

示例4: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()
    # Define a new user having full r/w permissions
    authorizer.add_user("user_name", "pass_word", "./", perm="elradfmwM", msg_login="welcome", msg_quit="bye")
    # Define a read-only anonymous user
    authorizer.add_anonymous("./")

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.max_login_attempts = 3
    handler.permit_foreign_addresses = True
    handler.tcp_no_delay = True

    # Define a customized banner (string returned when client connects)
    handler.banner = "Welcome to my FTP."

    # Instantiate FTP server class and listen on 127.0.0.1:21
    address = ("0.0.0.0", 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 128
    server.max_cons_per_ip = 2

    absfs = AbstractedFS(u"./", handler)
    absfs.cwd = u"/bbb/ss/"
    # start ftp server
    server.serve_forever()
开发者ID:oska874,项目名称:py-study-code,代码行数:32,代码来源:ftp0.py

示例5: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
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', os.getcwd(), 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 = ('', 2121)
    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()
开发者ID:070499,项目名称:service.lan.ftp,代码行数:33,代码来源:basic_ftpd.py

示例6: start_ftp_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def start_ftp_server():
    cs.CSClient().log(APP_NAME, 'start_ftp_server()...')
    try:
        authorizer = DummyAuthorizer()
        # Define a new user having full r/w permissions and a read-only
        # anonymous user
        authorizer.add_user('user', '12345', FTP_DIR, perm='elradfmwM')
        authorizer.add_anonymous(FTP_DIR)

        # Instantiate FTP handler class
        handler = FTPHandler
        handler.authorizer = authorizer

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

        # Instantiate FTP server class and listen on 0.0.0.0:2121.
        # Application can only use ports higher that 1024 and the port
        # will need to be allowed in the router firewall
        address = ('', 2121)
        server = FTPServer(address, handler)

        # set a limit for connections
        server.max_cons = 256
        server.max_cons_per_ip = 5

        # start ftp server
        cs.CSClient().log(APP_NAME, 'Starting FTP server...')
        server.serve_forever()
        # This will run the server in another thread
        # t = Thread(target=server.serve_forever())
        # t.start()

    except Exception as e:
        cs.CSClient().log(APP_NAME, 'Exception occurred! exception: {}'.format(e))
开发者ID:cradlepoint,项目名称:sdk-samples,代码行数:37,代码来源:ftp_server.py

示例7: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()
    # Define a new user having full r/w permissions
    authorizer.add_user('test', 'test','./', perm='elradfmwM')
    # Define a read-only anonymous user
    authorizer.add_anonymous('./')
 
    # Instantiate TLS FTP handler class
    handler = TLS_FTPHandler
    handler.authorizer = authorizer
    handler.certfile = './server.crt'
    handler.keyfile = './server.key'
 
    # Define a customized banner (string returned when client connects)
    handler.banner = "Welcome to test's FTPS."
 
    # Instantiate FTP server class and listen on 127.0.0.1:21
    address = ('127.0.0.1', 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()
开发者ID:oska874,项目名称:py-study-code,代码行数:29,代码来源:ftp1.py

示例8: run

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def run(ns):
	"""starts the server."""
	auth = DummyAuthorizer()
	if ns.user is not None:
		auth.add_user(ns.user, ns.pswd, ns.path, perm=ns.perm)
	else:
		auth.add_anonymous(ns.path, perm=ns.perm)
	handler = FTPHandler
	handler.authorizer = auth
	handler.banner = "StaSh v{v} FTP-Server".format(v=_stash.__version__)
	address = ("0.0.0.0", ns.port)
	server = FTPServer(address, handler)
	server.max_cons = 128
	server.max_cons_per_ip = 128
	# setup logging
	logger = logging.getLogger("pyftpdlib")
	logger.setLevel(logging.CRITICAL)
	logger.propagate = False
	# server needs to run in a thread to be killable
	thr = threading.Thread(
		name="FTP-Server Thread", target=server.serve_forever
		)
	thr.daemon = True
	thr.start()
	print("FTP-Server started on {h}:{p}".format(h=address[0], p=str(address[1])))
	try:
		while True:
			time.sleep(0.2)
	except KeyboardInterrupt:
		print("Stopping Server...")
		server.close_all()
开发者ID:BBOOXX,项目名称:stash,代码行数:33,代码来源:ftpserver.py

示例9: run

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
    def run(self):
        """Start the FTP Server for pulsar search."""
        self._log.info('Starting Pulsar Search Interface')
        # 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(self._config['login']['user'],
                            self._config['login']['psswd'], '.',
                            perm=self._config['login']['perm'])
        authorizer.add_anonymous(os.getcwd())

        # Instantiate FTP handler class
        handler = FTPHandler
        handler.authorizer = authorizer
        handler.abstracted_fs = PulsarFileSystem

        # Define a customized banner (string returned when client connects)
        handler.banner = "SKA SDP pulsar search interface."

        # Instantiate FTP server class and listen on 0.0.0.0:7878
        address = (self._config['address']['listen'],
                   self._config['address']['port'])
        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()
开发者ID:SKA-ScienceDataProcessor,项目名称:integration-prototype,代码行数:34,代码来源:pulsar_search.py

示例10: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    ##
    #authorizer = WindowsAuthorizer()
    ## Use Guest user with empty password to handle anonymous sessions.
    ## Guest user must be enabled first, empty password set and profile
    ## directory specified.
    ##authorizer = WindowsAuthorizer(anonymous_user="Guest", anonymous_password="")
    #handler = FTPHandler
    #handler.authorizer = authorizer
    #ftpd = FTPServer(('', 21), handler)
    #ftpd.serve_forever()
    #return
    
    ####################
    
    # 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', os.getcwd(), perm='elradfmwM')
    #authorizer.add_anonymous(os.getcwd())
    #authorizer.add_user('addons', 'road', os.getcwd(), perm='elradfmwM')
    #authorizer.add_user('addons', 'road', xbmc.translatePath("F:\zzz__AppData\XBMC\portable_data\addons"), perm='elradfmwM')
    #authorizer.add_anonymous(xbmc.translatePath("F:\zzz__AppData\XBMC\portable_data\addons"))
    #path01=xbmc.translatePath("F:\\zzz__AppData\\XBMC\\portable_data\\addons\\")
    path01=xbmc.translatePath("F:\\zzz__AppData\\XBMC\\portable_data\\addons\\")
    path01=path01.replace("\\","|tag|").replace("|tag|","\\\\")
    #path01=path01.replace(os.sep,"|tag|").replace("|tag|","\\\\")
    #authorizer.add_anonymous(path01)
    authorizer.add_user('addons', 'xbmchub', path01, perm='elradfmwM')
    
    

    # 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 = ('', 2121)
    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()
开发者ID:070499,项目名称:service.lan.ftp,代码行数:58,代码来源:FTPtest.py

示例11: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    # Parse cmdline
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("-c", "--conf", help="configuration file", default="config.json")
    parser.add_argument("-r", "--root", help="root dir", default="./")
    parser.add_argument("-p", "--port", help="listen port", type=int)
    flag = parser.parse_args()
    print flag

    # Load configuration
    cfg = json.load(open(flag.conf, "rb"))

    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Define a new user having full r/w permissions and a read-only
    perm = "elradfmwM"
    for acl in cfg.get("acls", []):
        print flag.root
        base_dir = os.path.join(flag.root, acl.get("directory", "./").lstrip("/"))
        print base_dir
        authorizer.add_user(acl["username"], acl["password"], base_dir, perm=perm)

    # anonymous user
    if cfg.get("anonymous"):
        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 = cfg.get("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 = ("", flag.port or cfg.get("port", 2121))
    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()
开发者ID:raceli,项目名称:gohttp,代码行数:51,代码来源:ftp_server.py

示例12: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user('admin', 'admin123', '/srv/ftp', perm='elradfmwM')
    authorizer.add_user('student', 'student123', '/srv/ftp/student', perm='elr')
    #authorizer.add_anonymous('/tmp')

    handler = FTPHandler
    handler.authorizer = authorizer
    handler.passive_ports = range(44400, 44499)
    handler.banner = "welcome to chenfy's ftp server~"

    server = FTPServer(('0.0.0.0', 8888), handler)
    server.max_cons = 10
    server.max_cons_per_ip = 5
    server.serve_forever()
开发者ID:boyfaceone,项目名称:codebase,代码行数:17,代码来源:myftpserver.py

示例13: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    """Usually is not need, run() is called automatically when do:
      $ python -m unittest discover <SOME DIR>
    Used only for special purpose.
    """
    USAGE = \
'''Simple ftp server for testing purpose only.
Syntax: [-h] [--host=HOST] [--port=PORT] [--login=LOGIN] [--password=PASSWORD]
[--dir=DIR]
Options:
    -h                   this help
    --host=HOST          bind  to this host name or IP (localhost default)
    --port=PORT          bind to this port number (21 default)
    --login=LOGIN        user name to login (anonymous default)
    --password=PASSWORD  user password
    --dir=DIR            browse directory (current dir default)
'''
    opts = parse_cmdline()
    if opts is None:
        sys.stdout.write(USAGE)
        sys.exit(0)
    # processing other options
    host = opts.get('host', '')
    port = int(opts.get('port', 21))
    login = opts.get('login', None)
    password = opts.get('password', None)
    dir_ = opts.get('dir', os.getcwd())

    ftp_handler = FTPHandler
    authorizer = DummyAuthorizer()
    ftp_handler.authorizer = authorizer
    if login and password:
        # Define a new user having full r/w permissions
        authorizer.add_user(login, password, dir_, perm='elradfmw')
    else:
        sys.stdout.write('Run as anonymous!\n')
        authorizer.add_anonymous(dir_)

    # Define a customized banner (string returned when client connects)
    ftp_handler.banner = "Test FTP server"
    address = (host, port)
    ftpd = FTPServer(address, ftp_handler)
    # set a limit for connections
    ftpd.max_cons = 256
    ftpd.max_cons_per_ip = 256
    # start ftp server
    ftpd.serve_forever()
开发者ID:kalkin,项目名称:nanolp,代码行数:49,代码来源:ftpserver.py

示例14: ftp_server

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def ftp_server():
    # 实例化虚拟用户,这是FTP验证首要条件
    authorizer = DummyAuthorizer()

    # 添加用户权限和路径,括号内的参数是(用户名, 密码, 用户目录, 权限)
    # authorizer.add_user('user', '12345', '/home/', perm='elradfmw')
    user_list = get_user('conf/user.py')
    for user in user_list:
        name, passwd, permit, homedir = user
        try:
            authorizer.add_user(name, passwd, homedir, perm=permit)
        except Exception as e:
            print(e)

    # 添加匿名用户 只需要路径
    if settings.enable_anonymous == 'on':
        authorizer.add_anonymous(settings.anonymous_path)

    # 下载上传速度设置
    dtp_handler = ThrottledDTPHandler
    dtp_handler.read_limit = settings.max_download
    dtp_handler.write_limit = settings.max_upload

    # 初始化ftp句柄
    handler = FTPHandler
    handler.authorizer = authorizer

    # 日志记录
    if settings.enable_logging == 'on':
        logging.basicConfig(filename=settings.loging_name, level=logging.INFO)

    # 欢迎信息
    handler.banner = settings.welcome_msg

    # 添加被动端口范围
    handler.passive_ports = range(settings.passive_ports[0], settings.passive_ports[1])

    # 监听ip 和 端口
    server = FTPServer((settings.ip, settings.port), handler)

    # 最大连接数
    server.max_cons = settings.max_cons
    server.max_cons_per_ip = settings.max_per_ip

    # 开始服务
    print('开始服务')
    server.serve_forever()
开发者ID:gswyhq,项目名称:hello-world,代码行数:49,代码来源:使用pyftpdlib实现FTP服务器.py

示例15: main

# 需要导入模块: from pyftpdlib.servers import FTPServer [as 别名]
# 或者: from pyftpdlib.servers.FTPServer import max_cons_per_ip [as 别名]
def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Creates a pass.dat file if it does not exist
    # Creates a root/admin user's folder and gives it full r/w permissions
    try:
        for line in open('pass.dat'):
            info = line.split(':')
            if len(info) < 2:
                continue
            try:
                os.mkdir(os.path.join(os.getcwd(), info[0]))
            except:
                pass
            authorizer.add_user(info[0], info[1].strip(), os.path.join(os.getcwd(), info[0]), perm='elradfmwM')
            try:
                os.mkdir(os.path.join(os.getcwd(), 'root'))
            except:
                pass
    except:
        f = open('pass.dat', 'w')
        f.close()
    authorizer.add_user('root', 'd63dc919e201d7bc4c825630d2cf25fdc93d4b2f0d46706d29038d01', os.path.join(os.getcwd()), perm='elradfmwM')

    # Instantiate FTP handler class
    handler = Handler
    handler.authorizer = authorizer

    # Define a customized banner (string returned when client connects)
    handler.banner = "OneDir Ready"

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(("gmail.com",80))
    ip = str(s.getsockname()[0])
    s.close()
    address = (ip, 2121)
    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()
开发者ID:aj9ms,项目名称:OneDir-Public,代码行数:48,代码来源:server_ftpd.py


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