예제 #1
0
파일: server.py 프로젝트: afdnlw/pritunl
    def generate_dh_param(self):
        reserved = queue.reserve('pooled_dh_params', svr=self)
        if not reserved:
            reserved = queue.reserve('queued_dh_params', svr=self)

        if reserved:
            queue.start('dh_params', dh_param_bits=self.dh_param_bits,
                priority=LOW)
            return

        self.queue_dh_params()
예제 #2
0
    def generate_dh_param(self):
        reserved = queue.reserve('pooled_dh_params', svr=self)
        if not reserved:
            reserved = queue.reserve('queued_dh_params', svr=self)

        if reserved:
            queue.start('dh_params',
                        dh_param_bits=self.dh_param_bits,
                        priority=LOW)
            return

        self.queue_dh_params()
예제 #3
0
    def new_user(self, type=CERT_CLIENT, block=True, **kwargs):
        # First attempt to get user from pool then attempt to get
        # unfinished queued user in pool then queue a new user init
        if type in (CERT_SERVER, CERT_CLIENT):
            usr = user.reserve_pooled_user(org=self, type=type, **kwargs)

            if not usr:
                usr = queue.reserve('queued_user', org=self, type=type,
                    block=block, **kwargs)

                if usr:
                    logger.debug('Reserved queued user', 'organization',
                        org_id=self.id,
                        user_id=usr.id,
                    )
            else:
                logger.debug('Reserved pooled user', 'organization',
                    org_id=self.id,
                    user_id=usr.id,
                )

            if usr:
                user.new_pooled_user(org=self, type=type)
                return usr

        usr = user.User(org=self, type=type, **kwargs)
        usr.queue_initialize(block=block,
            priority=HIGH if type in (CERT_SERVER, CERT_CLIENT) else None)

        logger.debug('Queued user init', 'organization',
            org_id=self.id,
            user_id=usr.id,
        )

        return usr
예제 #4
0
    def new_user(self, type=CERT_CLIENT, block=True, **kwargs):
        # First attempt to get user from pool then attempt to get
        # unfinished queued user in pool then queue a new user init
        if type in (CERT_SERVER, CERT_CLIENT):
            usr = user.reserve_pooled_user(org=self, type=type, **kwargs)

            if not usr:
                usr = queue.reserve('queued_user', org=self, type=type,
                    block=block, **kwargs)

                if usr:
                    logger.debug('Reserved queued user', 'organization',
                        org_id=self.id,
                        user_id=usr.id,
                    )
            else:
                logger.debug('Reserved pooled user', 'organization',
                    org_id=self.id,
                    user_id=usr.id,
                )

            if usr:
                user.new_pooled_user(org=self, type=type)
                return usr

        usr = user.User(org=self, type=type, **kwargs)
        usr.queue_initialize(block=block,
            priority=HIGH if type in (CERT_SERVER, CERT_CLIENT) else None)

        logger.debug('Queued user init', 'organization',
            org_id=self.id,
            user_id=usr.id,
        )

        return usr
예제 #5
0
    def generate_dh_param(self):
        doc = queue.find({"type": "dh_params", "server_id": self.id})
        if doc:
            if doc["dh_param_bits"] != self.dh_param_bits:
                queue.stop(doc["_id"])
            else:
                return

        reserved = queue.reserve("pooled_dh_params", svr=self)
        if not reserved:
            reserved = queue.reserve("queued_dh_params", svr=self)

        if reserved:
            queue.start("dh_params", dh_param_bits=self.dh_param_bits, priority=LOW)
            return

        self.queue_dh_params()
예제 #6
0
파일: server.py 프로젝트: debraca/pritunl
    def generate_dh_param(self):
        doc = queue.find({
            'type': 'dh_params',
            'server_id': self.id,
        })
        if doc:
            if doc['dh_param_bits'] != self.dh_param_bits:
                queue.stop(doc['_id'])
            else:
                return

        reserved = queue.reserve('pooled_dh_params', svr=self)
        if not reserved:
            reserved = queue.reserve('queued_dh_params', svr=self)

        if reserved:
            queue.start('dh_params', dh_param_bits=self.dh_param_bits,
                priority=LOW)
            return

        self.queue_dh_params()
예제 #7
0
    def generate_dh_param(self):
        doc = queue.find({
            'type': 'dh_params',
            'server_id': self.id,
        })
        if doc:
            if doc['dh_param_bits'] != self.dh_param_bits:
                queue.stop(doc['_id'])
            else:
                return

        reserved = queue.reserve('pooled_dh_params', svr=self)
        if not reserved:
            reserved = queue.reserve('queued_dh_params', svr=self)

        if reserved:
            queue.start('dh_params', dh_param_bits=self.dh_param_bits,
                priority=LOW)
            return

        self.queue_dh_params()
예제 #8
0
파일: utils.py 프로젝트: caojiguang/pritunl
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type, **kwargs)

            if org:
                logger.debug(
                    'Reserved queued org',
                    'organization',
                    org_id=org.id,
                )
        else:
            logger.debug(
                'Reserved pooled org',
                'organization',
                org_id=org.id,
            )

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        logger.debug(
            'Org init',
            'organization',
            org_id=org.id,
        )

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        logger.debug(
            'Queue org init',
            'organization',
            org_id=org.id,
        )

        return org
예제 #9
0
    def new_user(self, type=CERT_CLIENT, block=True, pool=True, **kwargs):
        # First attempt to get user from pool then attempt to get
        # unfinished queued user in pool then queue a new user init
        if type in (CERT_SERVER, CERT_CLIENT) and pool:
            usr = user.reserve_pooled_user(org=self, type=type, **kwargs)

            if not usr:
                usr = queue.reserve('queued_user', org=self, type=type,
                    block=block, **kwargs)

            if usr:
                user.new_pooled_user(org=self, type=type)
                return usr

        usr = user.User(org=self, type=type, **kwargs)
        usr.queue_initialize(block=block,
            priority=HIGH if type in (CERT_SERVER, CERT_CLIENT) else None)

        return usr
예제 #10
0
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type, **kwargs)

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        return org
예제 #11
0
파일: utils.py 프로젝트: pritunl/pritunl
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve("queued_org", block=block, type=type, **kwargs)

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        return org
예제 #12
0
파일: utils.py 프로젝트: lisong521/pritunl
def new_org(type=ORG_DEFAULT, block=True, **kwargs):
    if type == ORG_DEFAULT:
        org = reserve_pooled(type=type, **kwargs)

        if not org:
            org = queue.reserve('queued_org', block=block, type=type,
                **kwargs)

            if org:
                logger.debug('Reserved queued org', 'organization',
                    org_id=org.id,
                )
        else:
            logger.debug('Reserved pooled org', 'organization',
                org_id=org.id,
            )

        if org:
            new_pooled()
            return org

        org = Organization(type=type, **kwargs)
        org.initialize()
        org.commit()

        logger.debug('Org init', 'organization',
            org_id=org.id,
        )

        return org
    else:
        org = Organization(type=type, **kwargs)
        org.queue_initialize(block=block)

        logger.debug('Queue org init', 'organization',
            org_id=org.id,
        )

        return org