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)
|
start_port=$(echo $port | cut -d'-' -f1)
|
||||||
end_port=$(echo $port | cut -d'-' -f2)
|
end_port=$(echo $port | cut -d'-' -f2)
|
||||||
# Loop through the range and open each port
|
# Loop through the range and open each port
|
||||||
for ((i = start_port; i <= end_port; i++)); do
|
# for ((i = start_port; i <= end_port; i++)); do
|
||||||
ufw allow $i
|
# ufw allow $i
|
||||||
done
|
# done
|
||||||
|
ufw allow $start_port:$end_port
|
||||||
else
|
else
|
||||||
ufw allow "$port"
|
ufw allow "$port"
|
||||||
fi
|
fi
|
||||||
|
@ -650,9 +651,10 @@ delete_ports() {
|
||||||
start_port=$(echo $port | cut -d'-' -f1)
|
start_port=$(echo $port | cut -d'-' -f1)
|
||||||
end_port=$(echo $port | cut -d'-' -f2)
|
end_port=$(echo $port | cut -d'-' -f2)
|
||||||
# Loop through the range and delete each port
|
# Loop through the range and delete each port
|
||||||
for ((i = start_port; i <= end_port; i++)); do
|
# for ((i = start_port; i <= end_port; i++)); do
|
||||||
ufw delete allow $i
|
# ufw delete allow $i
|
||||||
done
|
# done
|
||||||
|
ufw delete allow $start_port:$end_port
|
||||||
else
|
else
|
||||||
ufw delete allow "$port"
|
ufw delete allow "$port"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue