mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #4581] [MERGED] Prevent executing fail2ban if it is disabled by env to prevent small CPU spikes every 10s, because python in fail2ban is slow #5720
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#5720
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/4581
Author: @Mayurifag
Created: 5/26/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @MHSanaei
Base:
main← Head:fix/fail2ban-disabled-ip-limit📝 Commits (3)
cb2d7dbfix(job): skip fail2ban IP limit when disabled0b39087Merge branch 'main' into fix/fail2ban-disabled-ip-limit54d444dMerge branch 'main' into fix/fail2ban-disabled-ip-limit📊 Changes
3 files changed (+134 additions, -5 deletions)
View changed files
📝
web/job/check_client_ip_job.go(+16 -5)📝
web/job/check_client_ip_job_integration_test.go(+43 -0)📝
web/job/check_client_ip_job_test.go(+75 -0)📄 Description
Summary
Fix
CheckClientIpJobsoXUI_ENABLE_FAIL2BAN=falsedisables fail2ban-dependent IP-limit work inside the Go app, not only inDockerEntrypoint.sh.Why
Observed on
ghcr.io/mhsanaei/3x-ui:v3.1.0: the Docker image always installs fail2ban, so/usr/bin/fail2ban-clientexists even when fail2ban is intentionally disabled withXUI_ENABLE_FAIL2BAN=false.DockerEntrypoint.shonly starts/configures fail2ban whenXUI_ENABLE_FAIL2BAN=true, but the Go app still scheduledCheckClientIpJobevery 10 seconds. When IP-limit logic was active, that job calledfail2ban-client -hevery run to check whether fail2ban was installed. Becausefail2ban-clientis Python, live sampling caught short-lived/usr/bin/python3 /usr/bin/fail2ban-client -hprocesses during small idle CPU spikes.When fail2ban is disabled by env, the app should also skip fail2ban-dependent IP-limit behavior and avoid writing ban entries that no fail2ban daemon will consume.
Type of change
Areas affected
How was this tested?
go test ./web/jobgo test ./...with localweb/dist/.gitkeepstub matching the CI workflowgo build ./...with localweb/dist/.gitkeepstub matching the CI workflowgit diff --checkScreenshots / recordings
N/A
Breaking changes
None.
XUI_ENABLE_FAIL2BAN=truekeeps the existing behavior, and an unset env var still defaults to enabled for non-Docker/manual installs. The Dockerfile already defaultsXUI_ENABLE_FAIL2BAN=true.Checklist
go build ./...and the test suite pass locally.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.