[PR #580] [MERGED] Removed ipLimit from the panel, changed the code to work with fail2ban #4775

Closed
opened 2026-10-31 20:42:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/580
Author: @somebodywashere
Created: 6/9/2023
Status: ✅ Merged
Merged: 6/15/2023
Merged by: @MHSanaei

Base: main ← Head: main


📝 Commits (9)

  • 61a2e6d Logging for fail2ban service
  • eb27951 Logging for fail2ban service
  • f84897e fixed shouldCleanLog
  • 29d854e last fix
  • eb1bf11 reduced ip limit detection frequency to 30 sec (less logging, more precise)
  • 411cf30 fixed check delay
  • b1cd912 Merge branch 'MHSanaei:main' into main
  • 26d1212 Merge branch 'MHSanaei:main' into main
  • 289a336 added 5 seconds delay before cleaning logs

📊 Changes

2 files changed (+28 additions, -126 deletions)

View changed files

📝 web/job/check_client_ip_job.go (+26 -124)
📝 web/web.go (+2 -2)

📄 Description

Hello! A wasted a couple of days trying to make stable and reliable Device limit with the base code (thorught cmd module you used).
But I made a decision to drop it completly from the panel because it still not that reliable, stable, pretty heave for machine and not configurable at all for end user.
So I just made logging of ips that get added to disAllowedIIps and configured fail2ban. It works like a charm now for me (tested 1 full day).

I did not fully removed whole code, because I noticed that disAllowed Ips somehow interact with XrayBlockedIPS.

fail2ban is pretty lightweight service that could be configured to use with UFW (I'm actually doing it) and perfectly suits for limiting devices aswell.

In my mind I think IP Limit should be optional and added to the main menu to configure (like WARP). Made a quick draft of commands to work:

sudo apt-get install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo echo $'\n[3x-ipl]\nenabled=true\nfilter=3x-ipl\naction=iptables-allports\nlogpath=/var/log/daemon.log\nmaxretry=3\nfindtime=150\nbantime=300' >> /etc/fail2ban/jail.local
sudo echo $'[Definition]\nfailregex = [LIMIT_IP].+SRC= <HOST>\nignoreregex =' >> /etc/fail2ban/filter.d/3x-ipl.conf

My config for jail:

[3x-ipl]
enabled=true
filter=3x-ipl
action=iptables-allports
logpath=/var/log/daemon.log
maxretry=3
findtime=150
bantime=300

Still deciding of what will fit the best. Also you can integrate a few "presets" of configs like above.
image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/580 **Author:** [@somebodywashere](https://github.com/somebodywashere) **Created:** 6/9/2023 **Status:** ✅ Merged **Merged:** 6/15/2023 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (9) - [`61a2e6d`](https://github.com/MHSanaei/3x-ui/commit/61a2e6dc11758e4deadf0070d76fb01bf04108b9) Logging for fail2ban service - [`eb27951`](https://github.com/MHSanaei/3x-ui/commit/eb27951936e23d43a56c2009335a1ddf6ca2938a) Logging for fail2ban service - [`f84897e`](https://github.com/MHSanaei/3x-ui/commit/f84897e4fbdc00fec2e6c598298a447e871263dd) fixed shouldCleanLog - [`29d854e`](https://github.com/MHSanaei/3x-ui/commit/29d854eae71cd726f1f0c030358d45b216e7fc59) last fix - [`eb1bf11`](https://github.com/MHSanaei/3x-ui/commit/eb1bf1148ea296b72f066ba9f0a0bfdc6ea5b350) reduced ip limit detection frequency to 30 sec (less logging, more precise) - [`411cf30`](https://github.com/MHSanaei/3x-ui/commit/411cf30a98f411358e3f93ac5981909cb5f4156b) fixed check delay - [`b1cd912`](https://github.com/MHSanaei/3x-ui/commit/b1cd912ddf2b7de9c868f74ef6878bf07f4bcf2b) Merge branch 'MHSanaei:main' into main - [`26d1212`](https://github.com/MHSanaei/3x-ui/commit/26d12120fd743ce84710074bfd5898a13150d9b8) Merge branch 'MHSanaei:main' into main - [`289a336`](https://github.com/MHSanaei/3x-ui/commit/289a33675f08cd329d7b0defc087e3d01ba4df08) added 5 seconds delay before cleaning logs ### 📊 Changes **2 files changed** (+28 additions, -126 deletions) <details> <summary>View changed files</summary> 📝 `web/job/check_client_ip_job.go` (+26 -124) 📝 `web/web.go` (+2 -2) </details> ### 📄 Description Hello! A wasted a couple of days trying to make stable and reliable Device limit with the base code (thorught cmd module you used). But I made a decision to drop it completly from the panel because it still not that reliable, stable, pretty heave for machine and not configurable at all for end user. So I just made logging of ips that get added to disAllowedIIps and configured fail2ban. It works like a charm now for me (tested 1 full day). I did not fully removed whole code, because I noticed that disAllowed Ips somehow interact with XrayBlockedIPS. fail2ban is pretty lightweight service that could be configured to use with UFW (I'm actually doing it) and perfectly suits for limiting devices aswell. In my mind I think IP Limit should be optional and added to the main menu to configure (like WARP). Made a quick draft of commands to work: `sudo apt-get install fail2ban -y` `sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local` `sudo echo $'\n[3x-ipl]\nenabled=true\nfilter=3x-ipl\naction=iptables-allports\nlogpath=/var/log/daemon.log\nmaxretry=3\nfindtime=150\nbantime=300' >> /etc/fail2ban/jail.local` `sudo echo $'[Definition]\nfailregex = [LIMIT_IP].+SRC= <HOST>\nignoreregex =' >> /etc/fail2ban/filter.d/3x-ipl.conf` My config for jail: [3x-ipl] enabled=true filter=3x-ipl action=iptables-allports logpath=/var/log/daemon.log maxretry=3 findtime=150 bantime=300 Still deciding of what will fit the best. Also you can integrate a few "presets" of configs like above. ![image](https://github.com/MHSanaei/3x-ui/assets/68244480/484a4398-41ac-4a8d-b406-443a9d9d4d32) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:42:36 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4775
No description provided.