From 8aefe96d296a7d0574c9545200ce18b8fbdef912 Mon Sep 17 00:00:00 2001 From: Ehco1996 Date: Fri, 5 Jul 2024 07:47:46 +0800 Subject: [PATCH] feat: Set default sub_client based on User-Agent if not provided --- apps/api/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/api/views.py b/apps/api/views.py index 996020a545..493593d6e7 100644 --- a/apps/api/views.py +++ b/apps/api/views.py @@ -100,6 +100,12 @@ def get(self, request): node_list = node_list.filter(node_type=protocol) sub_client = request.GET.get("client") + if not sub_client: + ua = request.META["HTTP_USER_AGENT"].lower() + if "clash" in ua: + sub_client = UserSubManager.CLIENT_CLASH + else: + sub_client = UserSubManager.CLIENT_SHADOWROCKET try: sub_info = UserSubManager(user, node_list, sub_client).get_sub_info() except ValueError as e: