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
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
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']
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
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"]