3x-ui/web
WatchDogsDev bef6b45848 fix: prevent multi-GB traffic overages after bandwidth limit is reached
Three layered fixes targeting the distinct causes of overage:

Bucket C (catastrophic): flush pending Xray stats to DB before every
scheduled Xray restart so in-memory counters are never silently zeroed.
- web/service/xray.go: add FlushTrafficToDB()
- web/web.go: call FlushTrafficToDB() in the 30 s restart cron before
  RestartXray(false)

Bucket A (in-flight gap): drain per-user Xray stats counters immediately
after RemoveUser() succeeds, capturing bytes accumulated since the last
bulk GetTraffic(reset=true) cycle.
- xray/api.go: add DrainUserTraffic(email) using GetStats gRPC with reset
- web/service/inbound.go: call DrainUserTraffic and persist delta in
  disableInvalidClients()

Bucket B (active TCP connections survive removal): insert iptables DROP
rules for each known client IP on the inbound port so established
connections are killed immediately, not just new ones.
- util/iptables/iptables.go: new package managing the 3X-UI-BLOCK chain
  (EnsureChain, FlushChain, BlockIP, UnblockIP, ListRules); gracefully
  degrades when iptables is unavailable
- web/job/unblock_ips_job.go: @every 5m cleanup job removes rules older
  than maxBlockAgeSecs
- web/service/inbound.go: blockClientIPs() called after successful
  RemoveUser(); unblockClientIPs() called after successful AddUser() in
  autoRenewClients() so renewed clients can reconnect
- web/web.go: EnsureChain + FlushChain on startup; register unblock job
2026-03-22 06:21:05 +03:30
..
assets Fix DeepLink for Happ, remove encoding URL (#3863) 2026-03-04 12:29:46 +01:00
controller Add Go code analyzer workflow 2026-03-17 23:01:15 +01: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: prevent multi-GB traffic overages after bandwidth limit is reached 2026-03-22 06:21:05 +03:30
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: prevent multi-GB traffic overages after bandwidth limit is reached 2026-03-22 06:21:05 +03:30
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: prevent multi-GB traffic overages after bandwidth limit is reached 2026-03-22 06:21:05 +03:30