3x-ui/internal/sub
n0ctal aef35ee0de
fix(sync): mark node dirty inside the mutation transaction (atomic ConfigDirty) (#5611)
* fix(sync): mark node dirty inside the mutation transaction

ConfigDirty is currently set by MarkNodeDirty AFTER the mutation, on a
separate DB handle outside the mutation's transaction. A crash or error
between the committed change and the mark leaves a committed config
change that never reconciles to the node (silent drift). Add
MarkNodeDirtyTx(tx, id) and call it inside each mutation's transaction so
the dirty mark commits atomically with the change.

* fix(test): initialize DB in TestResolveInboundAddress and group gorm import

Two CI failures on this branch:

- race (-shuffle=on): TestResolveInboundAddress reaches resolveInboundAddress -> configuredPublicHost -> GetSubDomain, which reads the global DB. The test never initialized one, relying on another sub-package test to do so first; under shuffle it ran first and nil-dereferenced gorm. Call initSubDB(t) so it is self-sufficient (empty DB yields an empty subDomain, so the subscriber-host fallback still holds).

- golangci goimports: gorm.io/gorm was grouped with the github.com/mhsanaei/3x-ui local imports in node_dirty_test.go. Move it into the third-party group.
2026-06-28 15:18:28 +02:00
..
build_urls_test.go
characterization_test.go
clash_external.go
clash_service.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
clash_service_test.go
controller.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
controller_test.go
default.json
dist.go
endpoint.go
endpoint_test.go
export_all_links_test.go
external_config.go
external_config_test.go
external_only_sub_test.go
external_subscription.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
external_subscription_test.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
host_sub.go
host_sub_test.go
json_service.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
json_service_test.go
links.go
links_test.go
mutation_audit_test.go
page_data_test.go
remark_vars.go
remark_vars_test.go test(sub): align identity-token test with first-link-only EMAIL 2026-06-27 13:56:45 +02:00
service.go feat(wireguard): multi-client support 2026-06-28 00:44:38 +02:00
service_dedup_test.go
service_flow_test.go
service_orphaned_stats_test.go
service_property_test.go
service_sharelink_test.go
service_sort_test.go
service_test.go fix(sync): mark node dirty inside the mutation transaction (atomic ConfigDirty) (#5611) 2026-06-28 15:18:28 +02:00
service_userinfo_test.go
service_wireguard_test.go feat(wireguard): multi-client support 2026-06-28 00:44:38 +02:00
sub.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00