Skip to content

Commit

Permalink
add HAPP proxy app custom json (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
iambabyninja authored Dec 29, 2024
1 parent a44327f commit ff66326
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ UVICORN_PORT = 8000
# USE_CUSTOM_JSON_FOR_V2RAYN=False
# USE_CUSTOM_JSON_FOR_V2RAYNG=True
# USE_CUSTOM_JSON_FOR_STREISAND=False
# USE_CUSTOM_JSON_FOR_HAPP=False

## Set headers for subscription
# SUB_PROFILE_TITLE = "Susbcription"
Expand Down
12 changes: 12 additions & 0 deletions app/routers/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
SUB_UPDATE_INTERVAL,
SUBSCRIPTION_PAGE_TEMPLATE,
USE_CUSTOM_JSON_DEFAULT,
USE_CUSTOM_JSON_FOR_HAPP,
USE_CUSTOM_JSON_FOR_STREISAND,
USE_CUSTOM_JSON_FOR_V2RAYN,
USE_CUSTOM_JSON_FOR_V2RAYNG,
Expand Down Expand Up @@ -122,6 +123,17 @@ def user_subscription(
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True, reverse=False)
return Response(content=conf, media_type="text/plain", headers=response_headers)

elif (USE_CUSTOM_JSON_DEFAULT or USE_CUSTOM_JSON_FOR_HAPP) and re.match(r'^Happ/(\d+\.\d+\.\d+)', user_agent):
version_str = re.match(r'^Happ/(\d+\.\d+\.\d+)', user_agent).group(1)
if LooseVersion(version_str) >= LooseVersion("1.63.1"):
conf = generate_subscription(user=user, config_format="v2ray-json", as_base64=False, reverse=False)
return Response(content=conf, media_type="application/json", headers=response_headers)
else:
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True, reverse=False)
return Response(content=conf, media_type="text/plain", headers=response_headers)



else:
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True, reverse=False)
return Response(content=conf, media_type="text/plain", headers=response_headers)
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
USE_CUSTOM_JSON_FOR_V2RAYN = config("USE_CUSTOM_JSON_FOR_V2RAYN", default=False, cast=bool)
USE_CUSTOM_JSON_FOR_V2RAYNG = config("USE_CUSTOM_JSON_FOR_V2RAYNG", default=False, cast=bool)
USE_CUSTOM_JSON_FOR_STREISAND = config("USE_CUSTOM_JSON_FOR_STREISAND", default=False, cast=bool)
USE_CUSTOM_JSON_FOR_HAPP = config("USE_CUSTOM_JSON_FOR_HAPP", default=False, cast=bool)

NOTIFY_STATUS_CHANGE = config("NOTIFY_STATUS_CHANGE", default=True, cast=bool)
NOTIFY_USER_CREATED = config("NOTIFY_USER_CREATED", default=True, cast=bool)
Expand Down

0 comments on commit ff66326

Please sign in to comment.