mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-29 16:39:35 +00:00
Legacy clients (and any API consumer that POSTs to AddInboundClient
without a subId) ended up with an empty SubID, which breaks the panel's
sub-link generation. Backfill them once at startup and stop the gap at
the write path so new clients can't reintroduce it.
- util/random: add NumLower(n) — 16-char [0-9a-z] generator that matches
the frontend's RandomUtil.randomLowerAndNum convention.
- database/db.go: new InboundClientSubIdFix seeder, modeled on
InboundClientTgIdFix. Loops every inbound, parses settings.clients,
fills empty/missing subId with random.NumLower(16), persists via the
same transaction-wrapped Update("settings", …) path, then records in
HistoryOfSeeders so it runs at most once.
- web/service/client.go: defense-in-depth in AddInboundClient and
UpdateInboundClient — fill subId on the persisted settings map when
the payload omits it (Update prefers the previous value before
generating a fresh one).
- database/db_seed_test: cover empty subId, missing-key subId, and
preserved-existing subId; assert exactly one HistoryOfSeeders row.