From 20d5204a1ad09f69e0d2f9dfc2e0f2721b9c0f17 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:33:10 +0330 Subject: [PATCH] Ensure BLOCK_DURATION and MAX_IPS exist in CONFIG_ENV correctly --- core/scripts/hysteria2/limit.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/scripts/hysteria2/limit.sh b/core/scripts/hysteria2/limit.sh index 1534008..dbbbf5e 100644 --- a/core/scripts/hysteria2/limit.sh +++ b/core/scripts/hysteria2/limit.sh @@ -9,10 +9,13 @@ SERVICE_NAME="hysteria-ip-limit.service" if [ -f "$CONFIG_ENV" ]; then source "$CONFIG_ENV" BLOCK_DURATION="${BLOCK_DURATION:-60}" # Default to 60 seconds if not set - MAX_IPS="${MAX_IPS:-1}" # Default to 1 IP if not set + MAX_IPS="${MAX_IPS:-1}" # Default to 1 IP if not set + + grep -q "^BLOCK_DURATION=" "$CONFIG_ENV" || echo -e "\nBLOCK_DURATION=$BLOCK_DURATION" >> "$CONFIG_ENV" + + grep -q "^MAX_IPS=" "$CONFIG_ENV" || echo "MAX_IPS=$MAX_IPS" >> "$CONFIG_ENV" else - BLOCK_DURATION=240 - MAX_IPS=5 + echo -e "BLOCK_DURATION=240\nMAX_IPS=5" > "$CONFIG_ENV" fi # --- Ensure files exist --- @@ -361,4 +364,4 @@ case "$1" in ;; esac -exit 0 \ No newline at end of file +exit 0