3x-ui/internal/sub
n0ctal ac8cb505d1
fix(subscriptions): avoid shared mutable state during generation (#5270)
* fix(subscriptions): avoid shared mutable state during generation

* fix(subscriptions): serve external-link-only subs in JSON/Clash; load remark settings per request

The ForRequest refactor added an early `len(inbounds) == 0` return to
GetJson/GetClash that fired before external links were fetched, so a
subscription whose only entries are external links (or whose inbounds are
all disabled) rendered empty in the JSON and Clash formats. Drop the
premature check — the existing inbounds+externalLinks empty guard already
covers the truly-empty case.

Also load datepicker/emailInRemark in PrepareForRequest rather than only in
getSubs, so JSON and Clash remarks honor these settings instead of seeing
the zero values (emailInRemark previously depended on the shared-state leak
this PR fixes).

Add a regression test covering an external-link-only sub across both formats.

---------

Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
2026-06-15 16:23:47 +02:00
..
build_urls_test.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
clash_external.go feat(sub): per-client external links and remote subscriptions 2026-06-14 20:57:14 +02:00
clash_service.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
clash_service_test.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
controller.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
controller_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
default.json refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
dist.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
external_config.go feat(sub): per-client external links and remote subscriptions 2026-06-14 20:57:14 +02:00
external_config_test.go feat(sub): per-client external links and remote subscriptions 2026-06-14 20:57:14 +02:00
external_only_sub_test.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
external_subscription.go feat(sub): per-client external links and remote subscriptions 2026-06-14 20:57:14 +02:00
json_service.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
json_service_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
links.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
links_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
mutation_audit_test.go Test-quality audit: fix 2 prod bugs, strengthen weak tests, add mutation/fuzz/CI tooling (#5345) 2026-06-15 15:17:03 +02:00
service.go fix(subscriptions): avoid shared mutable state during generation (#5270) 2026-06-15 16:23:47 +02:00
service_dedup_test.go Test-quality audit: fix 2 prod bugs, strengthen weak tests, add mutation/fuzz/CI tooling (#5345) 2026-06-15 15:17:03 +02:00
service_flow_test.go fix(sub): deliver vision flow for VLESS+XHTTP+REALITY in share links and Clash (#5232) 2026-06-12 22:25:04 +02:00
service_property_test.go Test-quality audit: fix 2 prod bugs, strengthen weak tests, add mutation/fuzz/CI tooling (#5345) 2026-06-15 15:17:03 +02:00
service_sharelink_test.go Test-quality audit: fix 2 prod bugs, strengthen weak tests, add mutation/fuzz/CI tooling (#5345) 2026-06-15 15:17:03 +02:00
service_sort_test.go feat(sub): per-inbound sort order for subscription links 2026-06-12 12:03:22 +02:00
service_test.go fix(links): bracket ipv6 hosts in share links and qr codes (#5310) 2026-06-14 23:38:58 +02:00
service_userinfo_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
sub.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00