示例#1
0
文件: v2_util.py 项目: libohe/v2-ui
def gen_v2_config_from_db():
    inbounds = Inbound.query.filter_by(enable=True).all()
    inbounds = [inbound.to_v2_json() for inbound in inbounds]
    v2_config = json.loads(config.get_v2_template_config())
    v2_config['inbounds'] += inbounds
    for conf_key in V2_CONF_KEYS:
        if conf_key not in v2_config:
            v2_config[conf_key] = {}
    return v2_config
示例#2
0
def gen_v2_config_from_db():
    inbounds = Inbound.query.filter_by(enable=True).all()
    clients = [
        ctm.to_v2_json() for ctm in Customers.query.all() if not ctm.is_expired
    ]
    inbounds = [inbound.to_v2_json() for inbound in inbounds]
    v2_config = json.loads(config.get_v2_template_config())
    v2_config['inbounds'] += inbounds
    for _ in v2_config['inbounds']:
        if _['protocol'] == 'vmess':
            _['settings']['clients'] = clients
    return v2_config
示例#3
0
def __get_api_address_port():
    template_config = json.loads(config.get_v2_template_config(),
                                 encoding='utf-8')
    inbounds = template_config['inbounds']
    api_inbound = list_util.get(inbounds, 'tag', 'api')
    return api_inbound['listen'], api_inbound['port']
示例#4
0
def gen_v2_config_from_db():
    inbounds = Inbound.query.filter_by(enable=True).all()
    inbounds = [inbound.to_v2_json() for inbound in inbounds]
    v2_config = json.loads(config.get_v2_template_config())
    v2_config['inbounds'] += inbounds
    return v2_config
示例#5
0
def __get_api_address_port():
    template_config = json.loads(config.get_v2_template_config())
    inbounds = template_config["inbounds"]
    api_inbound = list_util.get(inbounds, "tag", "api")
    return api_inbound["listen"], api_inbound["port"]