[PR #5854] [MERGED] fix(ldap): convert default total GB to bytes when auto-creating clients #6008

Closed
opened 2026-11-02 04:05:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5854
Author: @mrnickson-hue
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei

Base: main ← Head: fix/ldap-sync-totalgb-bytes-conversion


📝 Commits (2)

  • 5e38afb fix(ldap): convert default total GB to bytes when auto-creating clients
  • 70f3b08 test(ldap): pin the GB-to-bytes conversion in buildClient

📊 Changes

2 files changed (+9 additions, -1 deletions)

View changed files

📝 internal/web/job/ldap_sync_job.go (+1 -1)
📝 internal/web/job/ldap_sync_job_test.go (+8 -0)

📄 Description

Summary

LdapSyncJob.buildClient (internal/web/job/ldap_sync_job.go) stored ldapDefaultTotalGB directly into Client.TotalGB with no unit conversion:

TotalGB: int64(defGB),

Every other place that takes a GB-denominated input and persists it into this byte-denominated field converts first:

  • ClientFormModal.tsx → gbToBytes(form.totalGB)
  • tgbot_router.go → limitTraffic * 1024 * 1024 * 1024
  • client_inbound_apply.go → totalGB * 1024 * 1024 * 1024

So a "Default total (GB)" setting of 10 was persisted as 10 bytes instead of 10737418240 bytes — the auto-created client hits its quota almost immediately.

Fix

TotalGB: int64(defGB) * 1024 * 1024 * 1024,

0 still means unlimited (0 * anything = 0), consistent with every other path.

Test plan

  • go build ./internal/web/job/...
  • go test ./internal/web/job/... — existing TestLdapCreateClients_AttachesToAllConfiguredInbounds passes (uses defGB=0, unaffected by the conversion)

Closes #5852


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5854 **Author:** [@mrnickson-hue](https://github.com/mrnickson-hue) **Created:** 7/7/2026 **Status:** ✅ Merged **Merged:** 7/8/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/ldap-sync-totalgb-bytes-conversion` --- ### 📝 Commits (2) - [`5e38afb`](https://github.com/MHSanaei/3x-ui/commit/5e38afb95d2ee50a72c80ba03725109629df415d) fix(ldap): convert default total GB to bytes when auto-creating clients - [`70f3b08`](https://github.com/MHSanaei/3x-ui/commit/70f3b08ae4b475543e3be626185e845ec3cf92c9) test(ldap): pin the GB-to-bytes conversion in buildClient ### 📊 Changes **2 files changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/job/ldap_sync_job.go` (+1 -1) 📝 `internal/web/job/ldap_sync_job_test.go` (+8 -0) </details> ### 📄 Description ## Summary `LdapSyncJob.buildClient` (`internal/web/job/ldap_sync_job.go`) stored `ldapDefaultTotalGB` directly into `Client.TotalGB` with no unit conversion: ```go TotalGB: int64(defGB), ``` Every other place that takes a GB-denominated input and persists it into this byte-denominated field converts first: - `ClientFormModal.tsx` → `gbToBytes(form.totalGB)` - `tgbot_router.go` → `limitTraffic * 1024 * 1024 * 1024` - `client_inbound_apply.go` → `totalGB * 1024 * 1024 * 1024` So a "Default total (GB)" setting of `10` was persisted as `10` bytes instead of `10737418240` bytes — the auto-created client hits its quota almost immediately. ## Fix ```go TotalGB: int64(defGB) * 1024 * 1024 * 1024, ``` `0` still means unlimited (0 * anything = 0), consistent with every other path. ## Test plan - [x] `go build ./internal/web/job/...` - [x] `go test ./internal/web/job/...` — existing `TestLdapCreateClients_AttachesToAllConfiguredInbounds` passes (uses `defGB=0`, unaffected by the conversion) Closes #5852 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6008
No description provided.