From fb877ab84ab713d2bad7ca8bc1807d0a2c71e462 Mon Sep 17 00:00:00 2001 From: Gzngskxgr20 <74984541+Athameral@users.noreply.github.com> Date: Sun, 21 Apr 2024 00:09:05 +0800 Subject: [PATCH] Update x-ui.sh with ufw port settings It really costs time when adding rules for a large range, if for loop is used in bash. Changed it to built-in port range support in ufw. --- x-ui.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index a9ef1601..138132e6 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -620,9 +620,10 @@ open_ports() { start_port=$(echo $port | cut -d'-' -f1) end_port=$(echo $port | cut -d'-' -f2) # Loop through the range and open each port - for ((i = start_port; i <= end_port; i++)); do - ufw allow $i - done + # for ((i = start_port; i <= end_port; i++)); do + # ufw allow $i + # done + ufw allow $start_port:$end_port else ufw allow "$port" fi @@ -650,9 +651,10 @@ delete_ports() { start_port=$(echo $port | cut -d'-' -f1) end_port=$(echo $port | cut -d'-' -f2) # Loop through the range and delete each port - for ((i = start_port; i <= end_port; i++)); do - ufw delete allow $i - done + # for ((i = start_port; i <= end_port; i++)); do + # ufw delete allow $i + # done + ufw delete allow $start_port:$end_port else ufw delete allow "$port" fi