示例#1
0
def init_db(update=False):
    add_if_not_exist(Setting(
        'port', '面板网页端口', '65432', 'int',
        '', True), update)
    add_if_not_exist(Setting(
        'base_path', '面板网页根路径', '', 'text',
        '谨慎修改!!!可以填写你的个性网页根路径,例如 /v2-ui,默认为空。若填写则必须以 / 开头,不能以 / 结尾,填错会导致无法访问面板', True), update)
    add_if_not_exist(Setting(
        'cert_file', '面板ssl证书路径', '', 'text',
        '谨慎修改!!!需填写一个绝对路径,修改错误会导致无法启动面板', True), update)
    add_if_not_exist(Setting(
        'key_file', '面板ssl密钥路径', '', 'text',
        '谨慎修改!!!需填写一个绝对路径,修改错误会导致无法启动面板', True), update)
    add_if_not_exist(Setting(
        'login_title', '登录页标题', '登录', 'text',
        '', False), update)
    add_if_not_exist(Setting(
        'v2_config_path', 'v2ray配置文件路径', '/etc/v2ray/config.json', 'text',
        '谨慎修改!!!生成的v2ray配置会写入此项配置的文件中,一般无需修改', False), update)
    add_if_not_exist(Setting(
        'v2_template_config', 'v2ray配置文件模板', __read_v2_template_config(), 'textarea',
        '谨慎修改!!!请确保你对v2ray的配置非常熟悉,请不要删除关于api的配置', False), update)
    add_if_not_exist(Setting(
        'v2_config_check_interval', '账号生效时间(秒)', '60', 'int',
        '数值过小会导致CPU使用率上升,填0或负数后果自负', True), update)
    add_if_not_exist(Setting(
        'v2_restart_cmd', '重启v2ray命令', 'systemctl restart v2ray', 'text',
        '当v2ray需重启时,面板会自动运行此命令来重启v2ray,一般无需修改', False), update)
    add_if_not_exist(Setting(
        'traffic_job_interval', '统计流量间隔时间(秒)', '60', 'int',
        '数值过小会导致CPU使用率上升,填0或负数后果自负', True), update)
    db.session.commit()
示例#2
0
文件: config.py 项目: quniu/v2ui
def update_setting(setting_id, key, name, value, value_type='text'):
    if setting_id and contains_id(setting_id):
        Setting.query.filter_by(id=setting_id).update({'name': name, 'value': value, 'value_type': value_type})
    else:
        setting = Setting(key, name, value, value_type)
        db.session.add(setting)
    db.session.commit()
示例#3
0
def update_setting(setting_id, key, name, value, value_type="text"):
    if setting_id and __contains_id(setting_id):
        Setting.query.filter_by(id=setting_id).update({
            "name": name,
            "value": value,
            "value_type": value_type
        })
    else:
        setting = Setting(key, name, value, value_type)
        db.session.add(setting)
    db.session.commit()
示例#4
0
def render_header(context):
    company_name = Setting.get_val('company_name')
    
    street1 = Setting.get_val('street1')
    street2 = Setting.get_val('street2')
    city = Setting.get_val('city')
    state = Setting.get_val('state')
    postcode = Setting.get_val('postcode')
    
    company_address = '%s %s, %s, %s %s' %(street1, street2, city, state, postcode)
    
    context.update({'company_name': company_name, 'company_address': company_address})
    return context
示例#5
0
文件: config.py 项目: nerozhu/v2-ui
def init_db(update=False):
    add_if_not_exist(Setting('address', 'address', '', 'text', '', True),
                     update)
    add_if_not_exist(Setting('port', 'port', '65432', 'int', '', True), update)
    add_if_not_exist(Setting('base_path', 'base_path', '', 'text', '', True),
                     update)
    add_if_not_exist(Setting('cert_file', 'cert_file', '', 'text', '', True),
                     update)
    add_if_not_exist(Setting('key_file', 'key_file', '', 'text', '', True),
                     update)
    add_if_not_exist(
        Setting('login_title', 'login_title', 'Sign in', 'text', '', False),
        update)
    add_if_not_exist(
        Setting('v2_config_path', 'v2_config_path', '/etc/v2ray/config.json',
                'text', '', False), update)
    add_if_not_exist(
        Setting('v2_template_config', 'v2_template_config',
                __read_v2_template_config(), 'textarea', '', False), update)
    add_if_not_exist(
        Setting('v2_config_check_interval', 'v2_config_check_interval', '10',
                'int', '', True), update)
    add_if_not_exist(
        Setting('v2_restart_cmd', 'v2_restart_cmd', 'systemctl restart v2ray',
                'text', '', False), update)
    add_if_not_exist(
        Setting('traffic_job_interval', 'traffic_job_interval', '30', 'int',
                '', True), update)
    add_if_not_exist(
        Setting('v2ctl_cmd_path', 'v2ctl_cmd_path', '/usr/bin/v2ray/v2ctl',
                'text', '', True), update)
    add_if_not_exist(
        Setting('secret_key', '', os.urandom(24), 'text', '', True), False)
    db.session.commit()
示例#6
0
def init_db(update=False):
    add_if_not_exist(Setting("address", "address", "", "text", "", True),
                     update)
    add_if_not_exist(Setting("port", "port", "65432", "int", "", True), update)
    add_if_not_exist(Setting("base_path", "base_path", "", "text", "", True),
                     update)
    add_if_not_exist(Setting("cert_file", "cert_file", "", "text", "", True),
                     update)
    add_if_not_exist(Setting("key_file", "key_file", "", "text", "", True),
                     update)
    add_if_not_exist(
        Setting("login_title", "login_title", "Sign in", "text", "", False),
        update)
    add_if_not_exist(
        Setting("v2_core_xray", "v2_core_xray", "false", "bool", "", True),
        update)
    add_if_not_exist(
        Setting("v2ray_cmd_path", "v2ray_cmd_path", "", "text", "", True),
        update)
    add_if_not_exist(
        Setting("v2ctl_cmd_path", "v2ctl_cmd_path", "", "text", "", True),
        update)
    add_if_not_exist(
        Setting("v2_ext_tls", "v2_ext_tls", "false", "bool", "", False),
        update)
    add_if_not_exist(
        Setting("v2_ext_port", "v2_ext_port", "", "text", "", False), update)
    add_if_not_exist(
        Setting("v2_config_path", "v2_config_path", "", "text", "", True),
        update)
    add_if_not_exist(
        Setting("v2_start_cmd", "v2_start_cmd", "", "text", "", False), update)
    add_if_not_exist(
        Setting("v2_stop_cmd", "v2_stop_cmd", "", "text", "", False), update)
    add_if_not_exist(
        Setting("v2_restart_cmd", "v2_restart_cmd", "", "text", "", False),
        update)
    add_if_not_exist(
        Setting(
            "v2_template_config",
            "v2_template_config",
            __read_v2_template_config(),
            "textarea",
            "",
            False,
        ),
        update,
    )
    add_if_not_exist(
        Setting("v2_config_check_interval", "v2_config_check_interval", "10",
                "int", "", True),
        update,
    )
    add_if_not_exist(
        Setting("traffic_job_interval", "traffic_job_interval", "30", "int",
                "", True), update)
    add_if_not_exist(
        Setting("is_traffic_reset", "is_traffic_reset", "False", "bool", "",
                True), update)
    add_if_not_exist(
        Setting("reset_traffic_day", "reset_traffic_day", "0", "int", "",
                True), update)
    add_if_not_exist(
        Setting("secret_key", "", os.urandom(24), "text", "", True), False)
    db.session.commit()