Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'x-ui.sh')
-rw-r--r--x-ui.sh79
1 files changed, 44 insertions, 35 deletions
diff --git a/x-ui.sh b/x-ui.sh
index 8a70c5be..3f456190 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -1353,6 +1353,11 @@ iplimit_remove_conflicts() {
done
}
+ip_validation() {
+ ipv6_regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
+ ipv4_regex="^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)$"
+}
+
iplimit_main() {
echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit"
echo -e "${green}\t2.${plain} Change Ban Duration"
@@ -1406,7 +1411,8 @@ iplimit_main() {
;;
5)
read -rp "Enter the IP address you want to ban: " ban_ip
- if [[ $ban_ip =~ ^(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]))$ || $ban_ip =~ ^(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})$ ]]; then
+ ip_validation
+ if [[ $ban_ip =~ $ipv4_regex || $ban_ip =~ $ipv6_regex ]]; then
fail2ban-client set 3x-ipl banip "$ban_ip"
echo -e "${green}IP Address ${ban_ip} has been banned successfully.${plain}"
else
@@ -1416,7 +1422,8 @@ iplimit_main() {
;;
6)
read -rp "Enter the IP address you want to unban: " unban_ip
- if [[ $unban_ip =~ ^(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]))$ || $unban_ip =~ ^(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})$ ]]; then
+ ip_validation
+ if [[ $unban_ip =~ $ipv4_regex || $unban_ip =~ $ipv6_regex ]]; then
fail2ban-client set 3x-ipl unbanip "$unban_ip"
echo -e "${green}IP Address ${unban_ip} has been unbanned successfully.${plain}"
else
@@ -1673,39 +1680,41 @@ show_usage() {
show_menu() {
echo -e "
- ${green}3X-UI Panel Management Script${plain}
- ${green}0.${plain} Exit Script
-————————————————
- ${green}1.${plain} Install
- ${green}2.${plain} Update
- ${green}3.${plain} Update Menu
- ${green}4.${plain} Legacy Version
- ${green}5.${plain} Uninstall
-————————————————
- ${green}6.${plain} Reset Username & Password & Secret Token
- ${green}7.${plain} Reset Web Base Path
- ${green}8.${plain} Reset Settings
- ${green}9.${plain} Change Port
- ${green}10.${plain} View Current Settings
-————————————————
- ${green}11.${plain} Start
- ${green}12.${plain} Stop
- ${green}13.${plain} Restart
- ${green}14.${plain} Check Status
- ${green}15.${plain} Logs Management
-————————————————
- ${green}16.${plain} Enable Autostart
- ${green}17.${plain} Disable Autostart
-————————————————
- ${green}18.${plain} SSL Certificate Management
- ${green}19.${plain} Cloudflare SSL Certificate
- ${green}20.${plain} IP Limit Management
- ${green}21.${plain} Firewall Management
- ${green}22.${plain} SSH Port Forwarding Management
-————————————————
- ${green}23.${plain} Enable BBR
- ${green}24.${plain} Update Geo Files
- ${green}25.${plain} Speedtest by Ookla
+╔────────────────────────────────────────────────╗
+│ ${green}3X-UI Panel Management Script${plain} │
+│ ${green}0.${plain} Exit Script │
+│────────────────────────────────────────────────│
+│ ${green}1.${plain} Install │
+│ ${green}2.${plain} Update │
+│ ${green}3.${plain} Update Menu │
+│ ${green}4.${plain} Legacy Version │
+│ ${green}5.${plain} Uninstall │
+│────────────────────────────────────────────────│
+│ ${green}6.${plain} Reset Username & Password & Secret Token │
+│ ${green}7.${plain} Reset Web Base Path │
+│ ${green}8.${plain} Reset Settings │
+│ ${green}9.${plain} Change Port │
+│ ${green}10.${plain} View Current Settings │
+│────────────────────────────────────────────────│
+│ ${green}11.${plain} Start │
+│ ${green}12.${plain} Stop │
+│ ${green}13.${plain} Restart │
+│ ${green}14.${plain} Check Status │
+│ ${green}15.${plain} Logs Management │
+│────────────────────────────────────────────────│
+│ ${green}16.${plain} Enable Autostart │
+│ ${green}17.${plain} Disable Autostart │
+│────────────────────────────────────────────────│
+│ ${green}18.${plain} SSL Certificate Management │
+│ ${green}19.${plain} Cloudflare SSL Certificate │
+│ ${green}20.${plain} IP Limit Management │
+│ ${green}21.${plain} Firewall Management │
+│ ${green}22.${plain} SSH Port Forwarding Management │
+│────────────────────────────────────────────────│
+│ ${green}23.${plain} Enable BBR │
+│ ${green}24.${plain} Update Geo Files │
+│ ${green}25.${plain} Speedtest by Ookla │
+╚────────────────────────────────────────────────╝
"
show_status
echo && read -p "Please enter your selection [0-25]: " num