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:
authorGzngskxgr20 <74984541+Athameral@users.noreply.github.com>2024-04-20 21:29:27 +0300
committerGitHub <noreply@github.com>2024-04-20 21:29:27 +0300
commit3d5c06bf08f0ede7206e0ef39966d6be2106a225 (patch)
treedb645b6faa7f3ca4920b64a7ed1fcb332debf26c /x-ui.sh
parenta3a2d7a6a3aaa25481f80ea6fa5c6698419fe0b4 (diff)
Update x-ui.sh with ufw port settings (#2230)
* 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.
Diffstat (limited to 'x-ui.sh')
-rw-r--r--x-ui.sh22
1 files changed, 11 insertions, 11 deletions
diff --git a/x-ui.sh b/x-ui.sh
index a9ef1601..073ab63e 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -591,8 +591,9 @@ open_ports() {
# Check if the firewall is inactive
if ufw status | grep -q "Status: active"; then
- echo "firewall is already active"
+ echo "Firewall is already active"
else
+ echo "Activating firewall..."
# Open the necessary ports
ufw allow ssh
ufw allow http
@@ -619,17 +620,18 @@ open_ports() {
# Split the range into start and end 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
+ ufw allow $start_port:$end_port
else
ufw allow "$port"
fi
done
# 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() {
@@ -649,10 +651,8 @@ delete_ports() {
# Split the range into start and end 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
+ # Delete the port range
+ ufw delete allow $start_port:$end_port
else
ufw delete allow "$port"
fi
@@ -660,7 +660,7 @@ delete_ports() {
# Confirm that the ports are deleted
echo "Deleted the specified ports:"
- ufw status | grep $ports
+ ufw status | grep "ALLOW" | grep -Eo "[0-9]+(/[a-z]+)?"
}
update_geo() {