diff --git a/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh b/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh index dcf2879af..fa430ca6d 100755 --- a/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh +++ b/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh @@ -9,20 +9,21 @@ probe_file="/tmp/etc/passwall/haproxy/Probe_URL" probeUrl="https://www.google.com/generate_204" if [ -f "$probe_file" ]; then firstLine=$(head -n 1 "$probe_file" | tr -d ' \t') - if [ -n "$firstLine" ]; then - probeUrl="$firstLine" - fi + [ -n "$firstLine" ] && probeUrl="$firstLine" fi -status=$(/usr/bin/curl -I -o /dev/null -skL -x socks5h://${server_address}:${server_port} --connect-timeout 3 --retry 3 -w %{http_code} "${probeUrl}") +extra_params="-x socks5h://${server_address}:${server_port}" +if /usr/bin/curl --help all | grep -q "\-\-retry-all-errors"; then + extra_params="${extra_params} --retry-all-errors" +fi + +status=$(/usr/bin/curl -I -o /dev/null -skL ${extra_params} --connect-timeout 3 --retry 1 -w "%{http_code}" "${probeUrl}") + case "$status" in - 204|\ - 200) - status=200 + 200|204) + exit 0 + ;; + *) + exit 1 ;; esac -return_code=1 -if [ "$status" = "200" ]; then - return_code=0 -fi -exit ${return_code} diff --git a/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh b/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh index 60ff4b413..28b788ce3 100755 --- a/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh +++ b/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh @@ -28,9 +28,10 @@ test_url() { local timeout=2 [ -n "$3" ] && timeout=$3 local extra_params=$4 - curl --help all | grep "\-\-retry-all-errors" > /dev/null - [ $? == 0 ] && extra_params="--retry-all-errors ${extra_params}" - status=$(/usr/bin/curl -I -o /dev/null -skL --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" ${extra_params} --connect-timeout ${timeout} --retry ${try} -w %{http_code} "$url") + if /usr/bin/curl --help all | grep -q "\-\-retry-all-errors"; then + extra_params="--retry-all-errors ${extra_params}" + fi + status=$(/usr/bin/curl -I -o /dev/null -skL ${extra_params} --connect-timeout ${timeout} --retry ${try} -w %{http_code} "$url") case "$status" in 204) status=200