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-23 00:05:05 +0300
committerGitHub <noreply@github.com>2024-04-23 00:05:05 +0300
commit835cf2801c23c5ed4fd12a722079d70f0d5341d8 (patch)
tree8aaff49a74bf90f281a97f685909797909e75ed8 /x-ui.sh
parente794d3d87f0fb2535f8a6296e94e2125e33d0b91 (diff)
Correction of Previous Mistaken PR and the delete_ports function (#2231)
* 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 to correct the previous one, which cannot handle port range settings correctly. Corrected the confirmation of the deleted ports.
Diffstat (limited to 'x-ui.sh')
-rw-r--r--x-ui.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/x-ui.sh b/x-ui.sh
index 073ab63e..ddb4017b 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -620,7 +620,8 @@ open_ports() {
# Split the range into start and end ports
start_port=$(echo $port | cut -d'-' -f1)
end_port=$(echo $port | cut -d'-' -f2)
- ufw allow $start_port:$end_port
+ ufw allow $start_port:$end_port/tcp
+ ufw allow $start_port:$end_port/udp
else
ufw allow "$port"
fi
@@ -652,15 +653,27 @@ delete_ports() {
start_port=$(echo $port | cut -d'-' -f1)
end_port=$(echo $port | cut -d'-' -f2)
# Delete the port range
- ufw delete allow $start_port:$end_port
+ ufw delete allow $start_port:$end_port/tcp
+ ufw delete allow $start_port:$end_port/udp
else
ufw delete allow "$port"
fi
done
# Confirm that the ports are deleted
+
echo "Deleted the specified ports:"
- ufw status | grep "ALLOW" | grep -Eo "[0-9]+(/[a-z]+)?"
+ for port in "${PORT_LIST[@]}"; do
+ if [[ $port == *-* ]]; then
+ start_port=$(echo $port | cut -d'-' -f1)
+ end_port=$(echo $port | cut -d'-' -f2)
+ # Check if the port range has been successfully deleted
+ (ufw status | grep -q "$start_port:$end_port") || echo "$start_port-$end_port"
+ else
+ # Check if the individual port has been successfully deleted
+ (ufw status | grep -q "$port") || echo "$port"
+ fi
+ done
}
update_geo() {