mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5852] [Bug]: LDAP default total traffic is saved as bytes instead of GB #4063
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4063
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rty813 on GitHub (Jul 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5852
Describe the bug
When LDAP sync auto-creates clients, the "Default total (GB)" setting is written directly into the client
totalGBfield without converting from GB to bytes.For example, if
ldapDefaultTotalGBis set to10, the created client getstotalGB: 10, which is treated as 10 bytes, not 10 GB. The client becomes depleted almost immediately.This looks inconsistent with the rest of the UI/API, where
totalGBis stored in bytes and the frontend converts GB input to bytes before saving.How to reproduce
10.Actual behavior
The created client has:
The quota is interpreted as 10 bytes.
Expected behavior
The created client should have:
for a 10 GB setting.
Code reference
In
internal/web/job/ldap_sync_job.go, LDAP auto-create currently sets:but
defGBcomes fromldapDefaultTotalGB, and the UI label says "Default total (GB)".Other client creation paths convert GB to bytes before saving, for example
gbToBytes(form.totalGB)in the client form andtotalGB * 1024 * 1024 * 1024inResetClientTrafficLimitByEmail.A possible fix would be to convert the LDAP default before assigning it:
with
0still meaning unlimited.@github-actions[bot] commented on GitHub (Jul 7, 2026):
Confirmed in the source.
internal/web/job/ldap_sync_job.go:187-198(buildClient) sets:where
defGBcomes fromGetLdapDefaultTotalGB()(internal/web/service/setting.go:984-986), backed by theldapDefaultTotalGBsetting labeled"Default total (GB)"(internal/web/translation/en-US.json:1397, UI input infrontend/src/pages/settings/GeneralTab.tsx:389-390). This value is entered and stored in GB, butbuildClientassigns it straight intoClient.TotalGBwith no conversion, andClient.TotalGBis documented and used as a byte count everywhere else:internal/database/model/model.go:704—TotalGB int64 ... // Total traffic limit in GB(comment describes the unit the field is derived from, but the stored value is bytes).frontend/src/pages/clients/ClientFormModal.tsx:170-173—gbToBytesmultiplies by1024*1024*1024before saving a client from the panel.internal/web/service/client_inbound_apply.go:1298-1305—ResetClientTrafficLimitByEmaildoesc["totalGB"] = totalGB * 1024 * 1024 * 1024.So a client auto-created by LDAP sync with
ldapDefaultTotalGB = 10ends up withtotalGB: 10(10 bytes), which is effectively an immediate quota exhaustion, matching the reported behavior. SettingldapDefaultTotalGB = 0is unaffected since0means unlimited on both sides.The fix suggested in the report is correct and consistent with the rest of the codebase: convert in
buildClient(internal/web/job/ldap_sync_job.go:192), e.g.TotalGB: int64(defGB) * 1024 * 1024 * 1024,while continuing to treat0as unlimited.Workaround until fixed: leave
ldapDefaultTotalGBat0(unlimited) for LDAP auto-created clients, or manually correct thetotal_gbvalue in the database / edit the client's traffic limit from the panel after creation.This reply was generated automatically; a maintainer may follow up.