3x-ui/web
Bug Fix Bot 0404fce020 fix: comprehensive bug fixes across the codebase
## Critical Fixes

### 1. DATA LOSS: 5 functions discard all other clients when updating one
Functions affected:
- SetClientTelegramUserID
- ToggleClientEnableByEmail
- ResetClientIpLimitByEmail
- ResetClientExpiryTimeByEmail
- ResetClientTrafficLimitByEmail

All five built a `newClients` slice by only appending the client
matching the target email, then replaced the entire client list.
Every other client in the inbound was silently deleted.
Fix: update client in-place with break instead of building new slice.

### 2. DATA LOSS: ResetSettings never deletes user credentials
ResetSettings() called `.Where("1 = 1").Error` instead of
`.Delete(model.User{}).Error`. The reset command did nothing to users.

### 3. SECURITY: WebSocket CheckOrigin allows cross-origin hijacking
The fallback `(originHost == "" || requestHost == "")` accepted
any origin with a missing host component. Removed the fallback and
added proper host normalization for IPv6/ports.

### 4. GRACEFUL SHUTDOWN: Server.Stop() uses cancelled context
s.cancel() was called before s.httpServer.Shutdown(s.ctx), making
the context already-done. Shutdown returned immediately (forced kill)
instead of waiting 10 seconds. Moved s.cancel() to end and used
context.WithTimeout(10s) for shutdown. Same fix applied to sub.go.

## Medium Fixes

### 5. Wrong success messages on error paths (~11 endpoints)
When validation failed, endpoints returned messages like
"inboundUpdateSuccess" alongside the error. Fixed to use
"somethingWentWrong" for all error paths.

### 6. resetAllTraffics/resetAllClientTraffics trigger restart on error
SetToNeedRestart() was called in else branch that ran even on failure.
Restructured to only call after confirming success.

### 7. disableInvalidClients has duplicate unreachable error check
Same "User %s not found" string check was nested twice.
Removed the inner duplicate.

### 8. DelInbound logs uninitialized tag variable
The else branch logged empty tag variable instead of actual inbound id.

### 9. check_cpu_usage.go index-out-of-range panic
cpu.Percent() can return empty slice. Added len(percent) > 0 guard.

### 10. Dead code: cron.Remove(entry) on never-added entry
var entry cron.EntryID defaults to 0; cron.Remove(0) is a no-op.

### 11. checkEmailExistForInbound duplicates checkEmailsExistForClients
Refactored to delegate to existing function instead of reimplementing.
2026-03-28 14:12:49 +08:00
..
assets Fix DeepLink for Happ, remove encoding URL (#3863) 2026-03-04 12:29:46 +01:00
controller fix: comprehensive bug fixes across the codebase 2026-03-28 14:12:49 +08:00
entity feat: more subscription information fields (#3701) 2026-01-26 23:06:01 +01:00
global Refactor code and fix linter warnings (#3627) 2026-01-05 05:54:56 +01:00
html Adjust KCP MTU when selecting xDNS mask 2026-03-04 13:39:14 +01:00
job fix: comprehensive bug fixes across the codebase 2026-03-28 14:12:49 +08:00
locale update dependencies 2026-03-04 13:05:29 +01:00
middleware docs: add comments for all functions 2025-09-20 09:35:50 +02:00
network docs: add comments for all functions 2025-09-20 09:35:50 +02:00
service fix: comprehensive bug fixes across the codebase 2026-03-28 14:12:49 +08:00
session docs: add comments for all functions 2025-09-20 09:35:50 +02:00
translation Update translate.ru_RU.toml (#3889) 2026-03-17 21:24:09 +01:00
websocket Add url speed test for outbound (#3767) 2026-02-09 21:43:17 +01:00
web.go fix: comprehensive bug fixes across the codebase 2026-03-28 14:12:49 +08:00