mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6830] [MERGED] fix(iplimit): keep recording client IPs with fail2ban disabled #6470
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#6470
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6830
Author: @yudongyouqing
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:fix/ip-tracking-decouple-fail2ban📝 Commits (6)
388d20afix(iplimit): keep recording client IPs with fail2ban disabled (#6722)a3bf389fix(iplimit): address review findings on the #6722 test and commentsbbcb46efix(iplimit): stable tied-timestamp blobs and a zero-value-safe scanbe8d955refactor(iplimit): platform-pure resolveEnforce and review cleanups8f68fddMerge remote-tracking branch 'origin/main' into pr/6830b53caf2refactor(iplimit): drop the nil-source guard and keep Run's comments by their code📊 Changes
4 files changed (+192 additions, -48 deletions)
View changed files
📝
docs/architecture.md(+1 -1)📝
internal/web/job/check_client_ip_job.go(+77 -47)📝
internal/web/job/check_client_ip_job_integration_test.go(+62 -0)📝
internal/web/job/check_client_ip_job_test.go(+52 -0)📄 Description
Fixes #6722
What
XUI_ENABLE_FAIL2BAN=falsemadecheck_client_ip_job.Run()return before any IP was persisted, so the panel's client-IP list went empty on fail2ban-disabled installs even though the online-stats collection had already run that tick. Enforcement is now the only thing the env var gates: the scan always records, andresolveEnforcefolds the flag in so Windows (where the disconnect path needs no fail2ban binary) stops enforcing too when it is disabled.Collection-only runs (no limit on the client, inbound disabled, or fail2ban off) now share the enforcing run's merge + 30-minute window + CAS write instead of overwriting the blob with the current scan: the panel keeps showing recently connected IPs (what #6722 asks for), concurrent node-sync writes into the same blob are no longer lost (#6587), and unchanged scans skip the DB write entirely.
A narrow
onlineUsersSourceinterface replaces the concreteXrayServicefield soRun()can be driven end to end in tests without a live core.Tests (each written red first)
TestRun_RecordsIpsWhenFail2banDisabled— reproduced the reported bug (noinbound_client_ipsrow created with fail2ban disabled); now asserts the observed IP is recorded and no ban lines are written.TestProcessObserved_CollectionOnlyKeepsRecentWindow— pins the 30-minute window for collection-only runs; the old branch dropped an IP seen five minutes earlier.TestResolveEnforce— table test including the Windows-shaped row (disabled env + fail2ban installed → no enforcement), the only row distinguishing the new guard on Linux.internal/web/jobandinternal/web/servicepass with-race -shuffle=on; whole-repogolangci-lintclean.make verifyis green here exceptmsw-worker-check, which fails on currentmainas well and is fixed by #6829 (merge that first).Docs: the
docs/architecture.mdcron-table row for this job now states both duties.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.