Skip to content

Commit

Permalink
feat: custom config for streisand
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintShit committed Jun 27, 2024
1 parent 16ed7ec commit c585b05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ UVICORN_PORT = 8000
## If USE_CUSTOM_JSON_DEFAULT is set True, all following programs will use the JSON config
# USE_CUSTOM_JSON_FOR_V2RAYN=False
# USE_CUSTOM_JSON_FOR_V2RAYNG=True
# USE_CUSTOM_JSON_FOR_STREISAND=False

## Set headers for subscription
# SUB_PROFILE_TITLE = "Susbcription"
Expand Down
11 changes: 10 additions & 1 deletion app/views/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
XRAY_SUBSCRIPTION_PATH,
USE_CUSTOM_JSON_DEFAULT,
USE_CUSTOM_JSON_FOR_V2RAYN,
USE_CUSTOM_JSON_FOR_V2RAYNG
USE_CUSTOM_JSON_FOR_V2RAYNG,
USE_CUSTOM_JSON_FOR_STREISAND
)


Expand Down Expand Up @@ -114,6 +115,14 @@ def get_subscription_user_info(user: UserResponse) -> dict:
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True)
return Response(content=conf, media_type="text/plain", headers=response_headers)

elif re.match('^[Ss]treisand', user_agent):
if USE_CUSTOM_JSON_DEFAULT or USE_CUSTOM_JSON_FOR_STREISAND:
conf = generate_subscription(user=user, config_format="v2ray-json", as_base64=False)
return Response(content=conf, media_type="application/json", headers=response_headers)
else:
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True)
return Response(content=conf, media_type="text/plain", headers=response_headers)

else:
conf = generate_subscription(user=user, config_format="v2ray", as_base64=True)
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 @@ -54,6 +54,7 @@
USE_CUSTOM_JSON_DEFAULT = config("USE_CUSTOM_JSON_DEFAULT", default=False, cast=bool)
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)

ACTIVE_STATUS_TEXT = config("ACTIVE_STATUS_TEXT", default="Active")
EXPIRED_STATUS_TEXT = config("EXPIRED_STATUS_TEXT", default="Expired")
Expand Down

0 comments on commit c585b05

Please sign in to comment.