示例#1
0
文件: local.py 项目: wujcheng/pritunl
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()
    settings.local.iptables_wait = utils.check_iptables_wait()

    if settings.conf.host_id:
        settings.local.host_id = settings.conf.host_id
    elif os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    if os.path.isfile(settings.conf.setup_key_path):
        with open(settings.conf.setup_key_path, 'r') as setup_key_file:
            settings.local.setup_key = setup_key_file.read().strip()
    else:
        settings.local.setup_key = uuid.uuid4().hex

        with open(settings.conf.setup_key_path, 'w') as setup_key_file:
            os.chmod(settings.conf.setup_key_path, 0600)
            setup_key_file.write(settings.local.setup_key)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)
示例#2
0
文件: local.py 项目: rchicoli/pritunl
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()
    settings.local.iptables_wait = utils.check_iptables_wait()

    if settings.conf.host_id:
        settings.local.host_id = settings.conf.host_id
    elif os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, "r") as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, "w") as uuid_file:
            uuid_file.write(settings.local.host_id)

    if os.path.isfile(settings.conf.setup_key_path):
        with open(settings.conf.setup_key_path, "r") as setup_key_file:
            settings.local.setup_key = setup_key_file.read().strip()
    else:
        settings.local.setup_key = uuid.uuid4().hex

        with open(settings.conf.setup_key_path, "w") as setup_key_file:
            os.chmod(settings.conf.setup_key_path, 0600)
            setup_key_file.write(settings.local.setup_key)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)
示例#3
0
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()

    if os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)
示例#4
0
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()

    if os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    settings.local.version = __version__
    settings.local.version_int = int(''.join(
        [x.zfill(2) for x in settings.local.version.split('.')]))