luci-app-passwall: sync with upstream source

This commit is contained in:
CN_SZTL 2020-10-25 14:22:57 +08:00
parent fba54535c8
commit 09d5aa83cd
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -68,7 +68,30 @@ test_auto_switch() {
status=$(test_proxy)
if [ "$status" == 0 ]; then
#echolog "自动切换检测:${type}_${index}节点正常。"
echolog "自动切换检测:${type}_${index}节点$(config_n_get $now_node type) $(config_n_get $now_node address) $(config_n_get $now_node port)正常。"
#检测主节点是否能使用
local main_node=$(config_t_get auto_switch tcp_main1)
if [ "$now_node" != "$main_node" ]; then
local node_type=$(echo $(config_n_get $main_node type) | tr 'A-Z' 'a-z')
if [ "$node_type" == "socks" ]; then
local node_address=$(config_n_get $main_node address)
local node_port=$(config_n_get $main_node port)
[ -n "$node_address" ] && [ -n "$node_port" ] && local curlx="socks5h://$node_address:$node_port"
else
local tmp_port=$(/usr/share/passwall/app.sh get_new_port 61080 tcp)
/usr/share/passwall/app.sh run_socks "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch_$index.json" "10"
local curlx="socks5h://127.0.0.1:$tmp_port"
fi
sleep 10s
proxy_status=$(test_url "https://www.google.com/generate_204" 3 3 "-x $curlx")
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch_$index.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
if [ "$proxy_status" -eq 200 ]; then
#主节点正常,切换到主节点
echolog "自动切换检测:${type}_${index}主节点正常,切换到主节点!"
/usr/share/passwall/app.sh node_switch $type $2 $index $main_node
return 0
fi
fi
return 0
elif [ "$status" == 2 ]; then
echolog "自动切换检测:无法连接到网络,请检查网络是否正常!"
@ -89,6 +112,7 @@ test_auto_switch() {
/usr/share/passwall/app.sh run_socks "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch_$index.json" "10"
local curlx="socks5h://127.0.0.1:$tmp_port"
fi
sleep 10s
proxy_status=$(test_url "https://www.google.com/generate_204" 3 3 "-x $curlx")
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch_$index.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
if [ "$proxy_status" -eq 200 ]; then