mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-10 12:16:18 +00:00
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.
This commit is contained in:
parent
a3a2d7a6a3
commit
fb877ab84a
1 changed files with 8 additions and 6 deletions
14
x-ui.sh
14
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
|
||||
|
|
Loading…
Reference in a new issue