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


Python server.Server类代码示例

本文整理汇总了Python中pritunl.server.Server的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: server_client_connect_post

def server_client_connect_post(server_id):
    org_id = flask.request.json['org_id']
    user_id = flask.request.json['user_id']

    server = Server(server_id)
    if not server:
        return utils.jsonify({
            'error': SERVER_INVALID,
            'error_msg': SERVER_INVALID_MSG,
        }, 401)
    org = server.get_org(org_id)
    if not org:
        return utils.jsonify({
            'error': ORG_INVALID,
            'error_msg': ORG_INVALID_MSG,
        }, 401)
    user = org.get_user(user_id)
    if not user:
        return utils.jsonify({
            'error': USER_INVALID,
            'error_msg': USER_INVALID_MSG,
        }, 401)

    return utils.jsonify({
        'client_conf': None,
    })
开发者ID:ogrishman,项目名称:pritunl,代码行数:26,代码来源:server.py

示例2: server_tls_verify_post

def server_tls_verify_post(server_id):
    org_id = flask.request.json['org_id']
    user_id = flask.request.json['user_id']

    server = Server(server_id)
    if not server:
        return utils.jsonify({
            'error': SERVER_INVALID,
            'error_msg': SERVER_INVALID_MSG,
        }, 401)
    org = server.get_org(org_id)
    if not org:
        LogEntry(message='User failed authentication, ' +
            'invalid organization "%s".' % server.name)
        return utils.jsonify({
            'error': ORG_INVALID,
            'error_msg': ORG_INVALID_MSG,
        }, 401)
    user = org.get_user(user_id)
    if not user:
        LogEntry(message='User failed authentication, ' +
            'invalid user "%s".' % server.name)
        return utils.jsonify({
            'error': USER_INVALID,
            'error_msg': USER_INVALID_MSG,
        }, 401)

    return utils.jsonify({
        'authenticated': True,
    })
开发者ID:ogrishman,项目名称:pritunl,代码行数:30,代码来源:server.py

示例3: server_org_put

def server_org_put(server_id, org_id):
    server = Server(server_id)
    if server.status:
        return utils.jsonify({
            'error': SERVER_NOT_OFFLINE,
            'error_msg': SERVER_NOT_OFFLINE_MSG,
        }, 400)
    server.add_org(org_id)
    return utils.jsonify({})
开发者ID:cDoru,项目名称:pritunl,代码行数:9,代码来源:server.py

示例4: server_get

def server_get(server_id=None):
    if server_id:
        return utils.jsonify(Server.get_server(server_id).dict())
    else:
        servers = []
        servers_dict = {}
        servers_sort = []

        for server in Server.iter_servers():
            servers.append(server.dict())

        return utils.jsonify(servers)
开发者ID:bitland,项目名称:pritunl,代码行数:12,代码来源:server.py

示例5: server_client_disconnect_post

def server_client_disconnect_post(server_id):
    org_id = flask.request.json["org_id"]
    user_id = flask.request.json["user_id"]

    server = Server(server_id)
    if not server:
        return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
    org = server.get_org(org_id)
    if not org:
        return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
    user = org.get_user(user_id)
    if not user:
        return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)

    return utils.jsonify({})
开发者ID:WrongChao,项目名称:pritunl,代码行数:15,代码来源:server.py

示例6: _run_wsgi

    def _run_wsgi(self):
        self._setup_server_cert()
        import cherrypy.wsgiserver
        import cherrypy.wsgiserver.ssl_builtin
        from log_entry import LogEntry
        logger.info('Starting server...')

        if self.auto_start_servers != False:
            from pritunl.server import Server
            for server in Server.get_servers():
                if server.get_orgs():
                    server.start()

        server = cherrypy.wsgiserver.CherryPyWSGIServer(
            (self.bind_addr, self.port), self.app)
        server.ssl_adapter = cherrypy.wsgiserver.ssl_builtin.BuiltinSSLAdapter(
            self._server_cert_path, self._server_key_path)
        try:
            server.start()
        except (KeyboardInterrupt, SystemExit), exc:
            signal.signal(signal.SIGINT, signal.SIG_IGN)
            LogEntry(message='Web server stopped.')
            self.interrupt = True
            logger.info('Stopping server...')
            server.stop()
            self._close_db()
开发者ID:cDoru,项目名称:pritunl,代码行数:26,代码来源:app_server.py

示例7: status_get

def status_get():
    orgs_count = 0
    servers_count = 0
    servers_online_count = 0
    clients_count = 0

    for server in Server.iter_servers():
        servers_count += 1
        if server.status:
            servers_online_count += 1
        clients_count += len(server.clients)

    user_count = 0
    for org in Organization.iter_orgs():
        orgs_count += 1
        user_count += org.user_count

    local_networks = utils.get_local_networks()

    return utils.jsonify({
        'org_count': orgs_count,
        'users_online': clients_count,
        'user_count': user_count,
        'servers_online': servers_online_count,
        'server_count': servers_count,
        'server_version': __version__,
        'public_ip': app_server.public_ip,
        'local_networks': local_networks,
    })
开发者ID:ogrishman,项目名称:pritunl,代码行数:29,代码来源:status.py

示例8: _run_wsgi

    def _run_wsgi(self):
        if self.ssl:
            self._setup_server_cert()
        logger.info('Starting server...')

        if self.auto_start_servers:
            from pritunl.server import Server
            for server in Server.iter_servers():
                if server.org_count:
                    try:
                        server.start()
                    except:
                        logger.exception('Failed to auto start server. %r' % {
                            'server_id': server.id,
                        })

        server = cherrypy.wsgiserver.CherryPyWSGIServer(
            (self.bind_addr, self.port), self.app,
            request_queue_size=SERVER_REQUEST_QUEUE_SIZE,
            server_name=cherrypy.wsgiserver.CherryPyWSGIServer.version)
        if self.ssl:
            server.ConnectionClass = HTTPConnectionPatch
            server.ssl_adapter = SSLAdapter(
                self._server_cert_path, self._server_key_path)
        try:
            server.start()
        except (KeyboardInterrupt, SystemExit):
            pass
        except:
            logger.exception('Server error occurred')
            raise
        finally:
            signal.signal(signal.SIGINT, signal.SIG_IGN)
            logger.info('Stopping server...')
            self._on_exit()
开发者ID:bitland,项目名称:pritunl,代码行数:35,代码来源:app_server.py

示例9: status_get

def status_get():
    orgs = Organization.get_orgs()
    orgs_count = len(orgs)

    servers_count = 0
    servers_online_count = 0
    clients_count = 0
    for server in Server.get_servers():
        servers_count += 1
        if server.status:
            servers_online_count += 1
        clients_count += len(server.get_clients())

    users_count = 0
    for org in orgs:
        for user in org.get_users():
            if user.type != CERT_CLIENT:
                continue
            users_count += 1

    if not app_server.public_ip:
        app_server.load_public_ip()

    return utils.jsonify({
        'orgs_available': orgs_count,
        'orgs_total': orgs_count,
        'users_online': clients_count,
        'users_total': users_count,
        'servers_online': servers_online_count,
        'servers_total': servers_count,
        'server_version': __version__,
        'public_ip': app_server.public_ip,
    })
开发者ID:CorbettBaker-Company,项目名称:pritunl,代码行数:33,代码来源:status.py

示例10: server_delete

def server_delete(server_id):
    server = Server.get_server(id=server_id)
    server.remove()
    LogEntry(message='Deleted server "%s".' % server.name)
    Event(type=SERVERS_UPDATED)
    for org in server.iter_orgs():
        Event(type=USERS_UPDATED, resource_id=org.id)
    return utils.jsonify({})
开发者ID:bitland,项目名称:pritunl,代码行数:8,代码来源:server.py

示例11: server_org_delete

def server_org_delete(server_id, org_id):
    server = Server.get_server(id=server_id)
    if server.status:
        return utils.jsonify({
            'error': SERVER_NOT_OFFLINE,
            'error_msg': SERVER_NOT_OFFLINE_DETACH_ORG_MSG,
        }, 400)
    server.remove_org(org_id)
    return utils.jsonify({})
开发者ID:ogrishman,项目名称:pritunl,代码行数:9,代码来源:server.py

示例12: server_org_get

def server_org_get(server_id):
    orgs = []
    server = Server.get_server(id=server_id)
    for org in server.iter_orgs():
        orgs.append({
            'id': org.id,
            'server': server.id,
            'name': org.name,
        })
    return utils.jsonify(orgs)
开发者ID:bitland,项目名称:pritunl,代码行数:10,代码来源:server.py

示例13: server_org_get

def server_org_get(server_id):
    orgs = []
    orgs_dict = {}
    orgs_sort = []
    server = Server(server_id)

    for org in server.get_orgs():
        name_id = '%s_%s' % (org.name, org.id)
        orgs_sort.append(name_id)
        orgs_dict[name_id] = {
            'id': org.id,
            'server': server.id,
            'name': org.name,
        }

    for name_id in sorted(orgs_sort):
        orgs.append(orgs_dict[name_id])

    return utils.jsonify(orgs)
开发者ID:cDoru,项目名称:pritunl,代码行数:19,代码来源:server.py

示例14: server_operation_put

def server_operation_put(server_id, operation):
    server = Server(server_id)
    if operation == START:
        server.start()
    if operation == STOP:
        server.stop()
    elif operation == RESTART:
        server.restart()
    return utils.jsonify({})
开发者ID:cDoru,项目名称:pritunl,代码行数:9,代码来源:server.py

示例15: server_tls_verify_post

def server_tls_verify_post(server_id):
    org_id = flask.request.json["org_id"]
    user_id = flask.request.json["user_id"]

    server = Server(server_id)
    if not server:
        return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
    org = server.get_org(org_id)
    if not org:
        LogEntry(message="User failed authentication, " + 'invalid organization "%s".' % server.name)
        return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
    user = org.get_user(user_id)
    if not user:
        LogEntry(message="User failed authentication, " + 'invalid user "%s".' % server.name)
        return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
    if user.disabled:
        LogEntry(message="User failed authentication, " + 'disabled user "%s".' % server.name)
        return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)

    return utils.jsonify({"authenticated": True})
开发者ID:WrongChao,项目名称:pritunl,代码行数:20,代码来源:server.py


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