diff --git a/hiddifypanel/panel/commercial/restapi/v2/user/configs_api.py b/hiddifypanel/panel/commercial/restapi/v2/user/configs_api.py index 1dcc3fa6f..438af452f 100644 --- a/hiddifypanel/panel/commercial/restapi/v2/user/configs_api.py +++ b/hiddifypanel/panel/commercial/restapi/v2/user/configs_api.py @@ -46,14 +46,17 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Auto", "ALL", "ALL", "", "", "", - f"{base_url}sub/?asn={c['asn']}") + # f"{base_url}sub/?asn={c['asn']}" + f"{base_url}auto/?asn={c['asn']}" + ) ) # Add Full Singbox items.append( create_item( "Full Singbox", "ALL", "ALL", "", "", "", - f"{base_url}full-singbox.json?asn={c['asn']}" + # f"{base_url}full-singbox.json?asn={c['asn']}" + f"{base_url}singbox/?asn={c['asn']}" ) ) @@ -61,7 +64,8 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Clash Meta", "ALL", "ALL", "", "", "", - f"clashmeta://install-config?url={base_url}clash/meta/all.yml&name=mnormal_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}" + # f"clashmeta://install-config?url={base_url}clash/meta/all.yml&name=mnormal_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}" + f"clash://install-config?url={base_url}clashmeta/?asn={c['asn']}" ) ) @@ -69,7 +73,8 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Clash", "ALL", "Except VLess", "", "", "", - f"clash://install-config?url={base_url}clash/all.yml&name=new_normal_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}" + # f"clash://install-config?url={base_url}clash/all.yml&name=new_normal_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}" + f"clash://install-config?url={base_url}clash/?asn={c['asn']}" ) ) @@ -78,7 +83,8 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Singbox: SSH", "SSH", "SHH", "", "", "", - f"{base_url}singbox.json?name={c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}&asn={c['asn']}&mode={c['mode']}" + # f"{base_url}singbox.json?name={c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}&asn={c['asn']}&mode={c['mode']}" + f"{base_url}singbox-ssh/?asn={c['asn']}" ) ) @@ -86,7 +92,8 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Subscription link", "ALL", "ALL", "", "", "", - f"{base_url}all.txt?name={c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}&asn={c['asn']}&mode={c['mode']}" + # f"{base_url}all.txt?name={c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}&asn={c['asn']}&mode={c['mode']}" + f"{base_url}sub/?asn={c['asn']}" ) ) @@ -94,7 +101,8 @@ def create_item(name, domain, type, protocol, transport, security, link): items.append( create_item( "Subscription link b64", "ALL", "ALL", "", "", "", - f"{base_url}all.txt?name=new_link_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}&base64=True" + # f"{base_url}all.txt?name=new_link_{c['db_domain'].alias or c['db_domain'].domain}-{c['asn']}-{c['mode']}&asn={c['asn']}&mode={c['mode']}&base64=True" + f"{base_url}sub64/?asn={c['asn']}" ) ) diff --git a/hiddifypanel/panel/user/user.py b/hiddifypanel/panel/user/user.py index e4e93e6c2..453e9d7e5 100644 --- a/hiddifypanel/panel/user/user.py +++ b/hiddifypanel/panel/user/user.py @@ -34,12 +34,65 @@ def auto_sub(self): return self.new() return self.get_proper_config() or self.all_configs(base64=True) - @route('/sub') - @route('/sub/') + # former /sub/ or /sub (it was auto actually but we named it as /sub/) + # TODO: @hiddify: check this out + @route('/auto/') + @route('/auto') @login_required(roles={Role.user}) def force_sub(self): return self.get_proper_config() or self.all_configs(base64=False) + # region new endpoints + @route("/sub/") + @route("/sub") + @login_required(roles={Role.user}) + def sub(self): + return self.all_configs(base64=False) + + @route("/sub64/") + @route("/sub64") + @login_required(roles={Role.user}) + def sub64(self): + return self.all_configs(base64=True) + + @route("/singbox/") + @route("/singbox") + @login_required(roles={Role.user}) + def singbox_full(self): + return self.full_singbox() + + @route("/singbox-ssh/") + @route("/singbox-ssh") + @login_required(roles={Role.user}) + def singbox_ssh(self): + return self.singbox() + + @route("/clash/") + @route("/clash") + @login_required(roles={Role.user}) + def clash(self): + return self.clash_config(meta_or_normal="normal") + + @route("/clashmeta/") + @route("/clashmeta") + @login_required(roles={Role.user}) + def clashmeta(self): + return self.clash_config(meta_or_normal="meta") + # endregion + + @ route('/new/') + @ route('/new') + @login_required(roles={Role.user}) + def new(self): + conf = self.get_proper_config() + if conf: + return conf + + c = get_common_data(g.account.uuid, mode="new") + user_agent = user_agents.parse(request.user_agent.string) + # return render_template('home/multi.html', **c, ua=user_agent) + return render_template('new.html', **c, ua=user_agent) + def get_proper_config(self): if g.user_agent['is_browser']: return None @@ -59,20 +112,6 @@ def get_proper_config(self): if re.match('^(Hiddify|FoXray|Fair|v2rayNG|SagerNet|Shadowrocket|V2Box|Loon|Liberty)', ua, re.IGNORECASE): return self.all_configs(base64=True) - @ route('/new/') - @ route('/new') - @login_required(roles={Role.user}) - # @ route('/') - def new(self): - conf = self.get_proper_config() - if conf: - return conf - - c = get_common_data(g.account.uuid, mode="new") - user_agent = user_agents.parse(request.user_agent.string) - # return render_template('home/multi.html', **c, ua=user_agent) - return render_template('new.html', **c, ua=user_agent) - @ route('/clash//proxies.yml') @ route('/clash/proxies.yml') @login_required(roles={Role.user}) @@ -185,8 +224,8 @@ def all_configs(self, base64=False): resp = do_base_64(resp) return add_headers(resp, c) - @login_required(roles={Role.user}) @ route("/offline.html") + @login_required(roles={Role.user}) def offline(): return f"Not Connected click for reload"