Update x-ui.sh

This commit is contained in:
mhsanaei 2024-04-20 21:59:05 +03:30
parent fb877ab84a
commit 9ca6d98fb4

20
x-ui.sh
View file

@ -591,8 +591,9 @@ open_ports() {
# Check if the firewall is inactive # Check if the firewall is inactive
if ufw status | grep -q "Status: active"; then if ufw status | grep -q "Status: active"; then
echo "firewall is already active" echo "Firewall is already active"
else else
echo "Activating firewall..."
# Open the necessary ports # Open the necessary ports
ufw allow ssh ufw allow ssh
ufw allow http ufw allow http
@ -619,10 +620,6 @@ open_ports() {
# Split the range into start and end ports # Split the range into start and end 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
# for ((i = start_port; i <= end_port; i++)); do
# ufw allow $i
# done
ufw allow $start_port:$end_port ufw allow $start_port:$end_port
else else
ufw allow "$port" ufw allow "$port"
@ -630,7 +627,11 @@ open_ports() {
done done
# Confirm that the ports are open # Confirm that the ports are open
ufw status | grep $ports echo "The following ports are now open:"
ufw status | grep "ALLOW" | grep -Eo "[0-9]+(/[a-z]+)?"
echo "Firewall status:"
ufw status verbose
} }
delete_ports() { delete_ports() {
@ -650,10 +651,7 @@ delete_ports() {
# Split the range into start and end ports # Split the range into start and end 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 # Delete the port range
# for ((i = start_port; i <= end_port; i++)); do
# ufw delete allow $i
# done
ufw delete allow $start_port:$end_port ufw delete allow $start_port:$end_port
else else
ufw delete allow "$port" ufw delete allow "$port"
@ -662,7 +660,7 @@ delete_ports() {
# Confirm that the ports are deleted # Confirm that the ports are deleted
echo "Deleted the specified ports:" echo "Deleted the specified ports:"
ufw status | grep $ports ufw status | grep "ALLOW" | grep -Eo "[0-9]+(/[a-z]+)?"
} }
update_geo() { update_geo() {