Skip to content

Commit

Permalink
*: fix sub for clash
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Mar 4, 2024
1 parent 2e4d662 commit eaf0b8a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def get(self, request):
return HttpResponse(
sub_info,
content_type="text/plain; charset=utf-8",
headers=user.get_sub_info_header(),
headers=user.get_sub_info_header(
for_android=sub_client != UserSubManager.CLIENT_SHADOWROCKET
),
)


Expand Down
7 changes: 5 additions & 2 deletions apps/sspanel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,14 @@ def reset_to_fresh(self):
self.reset_traffic(settings.DEFAULT_TRAFFIC)
self.save()

def get_sub_info_header(self):
def get_sub_info_header(self, for_android=False):
"""
https://github.com/crossutility/Quantumult/blob/master/extra-subscription-feature.md
"""
expire = self.level_expire_time.date().strftime("%Y-%m-%d")
if for_android:
expire = self.level_expire_time.timestamp()
else:
expire = self.level_expire_time.date().strftime("%Y-%m-%d")
info = f"u={traffic_format(self.upload_traffic)}; d={traffic_format(self.download_traffic)}; t={traffic_format(self.total_traffic)}; expire={expire}"
return {"Subscription-Userinfo": info}

Expand Down
4 changes: 3 additions & 1 deletion apps/sspanel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ def post(self, request, pk):
"""添加回复"""
ticket: Ticket = Ticket.objects.get(pk=pk)
if ticket.status == -1:
messages.error(request, "工单已经关闭,请开启新的工单", extra_tags="回复失败")
messages.error(
request, "工单已经关闭,请开启新的工单", extra_tags="回复失败"
)
return HttpResponseRedirect(reverse("sspanel:ticket_detail", args=(pk,)))
ticket.updated_at = get_current_datetime()
ticket.save()
Expand Down
2 changes: 2 additions & 0 deletions templates/clash/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ proxy-providers:
{% include "clash/rules.yaml" %}
{% else %}
{% include "clash/rule_sets.yaml" %}
{% endif %}


0 comments on commit eaf0b8a

Please sign in to comment.