Skip to content

Commit

Permalink
feat: Set default sub_client based on User-Agent if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Jul 4, 2024
1 parent 2756bd2 commit 8aefe96
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8aefe96

Please # to comment.