mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
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#5595
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/4083
Author: @pwnnex
Created: 4/22/2026
Status: ✅ Merged
Merged: 4/22/2026
Merged by: @pwnnex
Base:
main← Head:fix/iplimit-stale-db-evict📝 Commits (1)
eef2d31Fix IP Limit continuous ban loop from stale DB entries (#4077)📊 Changes
2 files changed (+124 additions, -10 deletions)
View changed files
📝
web/job/check_client_ip_job.go(+47 -10)➕
web/job/check_client_ip_job_test.go(+77 -0)📄 Description
Closes #4077.
What users see
/var/log/x-ui/3xipl.logkeeps filling with[LIMIT_IP] … Disconnecting OLD IP =lines for the same honest IP.Works fine on v2.8.11, starts looping on v2.9.1.
Root cause
web/job/check_client_ip_job.go → updateInboundClientIpsmerges two lists:inbound_client_ips.ipsblob (what we've seen historically).Then it sorts ascending by timestamp and keeps the first
limitIpentries. The intent (from60abeaa) is "protect the original/current connections, ban new excess ones".The hole: nothing ever evicts an IP that simply stopped connecting. Its timestamp from the last time it was logged stays there forever. On the next run that stale IP is still "the oldest", so it wins the protected slot, and whichever IP is actually active right now is classified as "new excess" and gets re-banned. Every. Single. Run.
Fix
Drop entries whose last-seen timestamp is older than
ipStaleAfterSeconds(30 minutes) from the merge. An IP that is actually still active refreshes its timestamp any time xray emits a newacceptedlog line for a fresh TCP, which is well inside 30 minutes even for idle streaming. A client that has really gone away falls out of the table in bounded time and frees its slot.The merge logic was extracted into a pure
mergeClientIps(old, new, staleCutoff) → maphelper so the policy can be exercised without the DB-backed job.Tests
5 subtests in
check_client_ip_job_test.go, all pass.go build ./...+go vet ./web/job/...+gofmt -l .clean.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.