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:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-02-11 23:32:23 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-02-11 23:32:23 +0300
commitf4057989f520daaef30b9d1cc0b0b0f12dbd7edc (patch)
treed722a403b238004a2ad1211548408942add7c662
parent84013b0b3f4b4da47e776cbbb44af849c33e664f (diff)
Require HTTP 200 from curl before using IP
Replace simple curl+trim checks with a response+http_code parse to ensure the remote URL returns HTTP 200 and a non-empty body before assigning server_ip. Changes applied to install.sh, update.sh and x-ui.sh: use curl -w to append the status code, extract http_code and ip_result, and only set server_ip when http_code == 200 and ip_result is non-empty. This makes the IP discovery more robust against error pages or partial responses while keeping the existing timeout behavior.
-rw-r--r--install.sh7
-rwxr-xr-xupdate.sh7
-rw-r--r--x-ui.sh8
3 files changed, 16 insertions, 6 deletions
diff --git a/install.sh b/install.sh
index 852e128a..46207777 100644
--- a/install.sh
+++ b/install.sh
@@ -654,8 +654,11 @@ config_after_install() {
)
local server_ip=""
for ip_address in "${URL_lists[@]}"; do
- server_ip=$(curl -s --max-time 3 "${ip_address}" 2>/dev/null | tr -d '[:space:]')
- if [[ -n "${server_ip}" ]]; then
+ local response=$(curl -s -w "\n%{http_code}" --max-time 3 "${ip_address}" 2>/dev/null)
+ local http_code=$(echo "$response" | tail -n1)
+ local ip_result=$(echo "$response" | head -n-1 | tr -d '[:space:]')
+ if [[ "${http_code}" == "200" && -n "${ip_result}" ]]; then
+ server_ip="${ip_result}"
break
fi
done
diff --git a/update.sh b/update.sh
index 0c4bb725..5dce0ce3 100755
--- a/update.sh
+++ b/update.sh
@@ -687,8 +687,11 @@ config_after_update() {
)
local server_ip=""
for ip_address in "${URL_lists[@]}"; do
- server_ip=$(${curl_bin} -s --max-time 3 "${ip_address}" 2>/dev/null | tr -d '[:space:]')
- if [[ -n "${server_ip}" ]]; then
+ local response=$(curl -s -w "\n%{http_code}" --max-time 3 "${ip_address}" 2>/dev/null)
+ local http_code=$(echo "$response" | tail -n1)
+ local ip_result=$(echo "$response" | head -n-1 | tr -d '[:space:]')
+ if [[ "${http_code}" == "200" && -n "${ip_result}" ]]; then
+ server_ip="${ip_result}"
break
fi
done
diff --git a/x-ui.sh b/x-ui.sh
index 22d02358..2bd125ab 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -2062,11 +2062,15 @@ SSH_port_forwarding() {
)
local server_ip=""
for ip_address in "${URL_lists[@]}"; do
- server_ip=$(curl -s --max-time 3 "${ip_address}" 2>/dev/null | tr -d '[:space:]')
- if [[ -n "${server_ip}" ]]; then
+ local response=$(curl -s -w "\n%{http_code}" --max-time 3 "${ip_address}" 2>/dev/null)
+ local http_code=$(echo "$response" | tail -n1)
+ local ip_result=$(echo "$response" | head -n-1 | tr -d '[:space:]')
+ if [[ "${http_code}" == "200" && -n "${ip_result}" ]]; then
+ server_ip="${ip_result}"
break
fi
done
+
local existing_webBasePath=$(${xui_folder}/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}')
local existing_port=$(${xui_folder}/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}')
local existing_listenIP=$(${xui_folder}/x-ui setting -getListen true | grep -Eo 'listenIP: .+' | awk '{print $2}')