diff --git a/.env.example b/.env.example index bcef7fc6..9c932365 100644 --- a/.env.example +++ b/.env.example @@ -37,6 +37,9 @@ UVICORN_PORT = 8000 # SINGBOX_SUBSCRIPTION_TEMPLATE="singbox/default.json" # MUX_TEMPLATE="mux/default.json" +## Enable JSON support for compatible clients to use mux, fragment, etc. Default is null, meaning false. +# USE_CUSTOM_JSON_DEFAULT="True" + ## Set headers for subscription # SUB_PROFILE_TITLE = "Susbcription" # SUB_SUPPORT_URL = "https://t.me/support" diff --git a/app/views/subscription.py b/app/views/subscription.py index 844d9535..8c1d21d9 100644 --- a/app/views/subscription.py +++ b/app/views/subscription.py @@ -16,7 +16,8 @@ SUB_SUPPORT_URL, SUB_UPDATE_INTERVAL, SUBSCRIPTION_PAGE_TEMPLATE, - XRAY_SUBSCRIPTION_PATH + XRAY_SUBSCRIPTION_PATH, + USE_CUSTOM_JSON_DEFAULT ) @@ -93,7 +94,7 @@ def get_subscription_user_info(user: UserResponse) -> dict: elif re.match('^v2rayNG/(\d+\.\d+\.\d+)', user_agent): version_str = re.match('^v2rayNG/(\d+\.\d+\.\d+)', user_agent).group(1) - if LooseVersion(version_str) >= LooseVersion("1.8.16"): + if LooseVersion(version_str) >= LooseVersion("1.8.16") and USE_CUSTOM_JSON_DEFAULT: conf = generate_subscription(user=user, config_format="v2ray-json", as_base64=False) return Response(content=conf, media_type="application/json", headers=response_headers) else: diff --git a/config.py b/config.py index fcfc8cc1..ec415b1a 100755 --- a/config.py +++ b/config.py @@ -50,6 +50,7 @@ SINGBOX_SUBSCRIPTION_TEMPLATE = config("SINGBOX_SUBSCRIPTION_TEMPLATE", default="singbox/default.json") MUX_TEMPLATE = config("MUX_TEMPLATE", default="mux/default.json") V2RAY_SUBSCRIPTION_TEMPLATE = config("V2RAY_SUBSCRIPTION_TEMPLATE", default="v2ray/default.json") +USE_CUSTOM_JSON_DEFAULT = config("USE_CUSTOM_JSON_DEFAULT", default="") ACTIVE_STATUS_TEXT = config("ACTIVE_STATUS_TEXT", default="Active") EXPIRED_STATUS_TEXT = config("EXPIRED_STATUS_TEXT", default="Expired")