diff --git a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch index e46de0a2ac..281d0f851e 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch +++ b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch @@ -33,7 +33,7 @@ uci_get_by_type() { DEFAULT_SERVER=$(uci_get_by_type global global_server) CURRENT_SERVER=$DEFAULT_SERVER -#判断代理是否正常 +#鍒ゆ柇浠g悊鏄惁姝e父 check_proxy() { /usr/bin/ssr-check www.google.com 80 $switch_time 1 if [ "$?" == "0" ]; then @@ -41,7 +41,7 @@ if [ "$?" == "0" ]; then else /usr/bin/ssr-check www.baidu.com 80 $switch_time 1 if [ "$?" == "0" ]; then - #goole不通baidu通则不正常 + #goole涓嶉歜aidu閫氬垯涓嶆甯 return 1 else return 2 @@ -95,7 +95,7 @@ return 1 fi } -#选择可用的代理 +#閫夋嫨鍙敤鐨勪唬鐞 select_proxy() { config_load $NAME @@ -106,33 +106,33 @@ config_foreach search_proxy servers } -#切换代理 +#鍒囨崲浠g悊 switch_proxy() { /etc/init.d/shadowsocksr restart $1 return 0 } start() { -#不支持kcptun启用时的切换 +#涓嶆敮鎸乲cptun鍚敤鏃剁殑鍒囨崲 [ $(uci_get_by_name $DEFAULT_SERVER kcp_enable) = "1" ] && return 1 -while [ "1" = "1" ] #死循环 +while [ "1" = "1" ] #姝诲惊鐜 do sleep $cycle_time LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") - #判断当前代理是否为缺省服务器 + #鍒ゆ柇褰撳墠浠g悊鏄惁涓虹己鐪佹湇鍔″櫒 if [ "$CURRENT_SERVER" != "$DEFAULT_SERVER" ] ;then #echo "not default proxy" echo "$(date "+%Y-%m-%d %H:%M:%S") Current server is not default Main server, try to switch back." >> /tmp/ssrplus.log - #检查缺省服务器是否正常 + #妫鏌ョ己鐪佹湇鍔″櫒鏄惁姝e父 if test_proxy $DEFAULT_SERVER ;then #echo "switch to default proxy" echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is avilable." >> /tmp/ssrplus.log - #缺省服务器正常,切换回来 + #缂虹渷鏈嶅姟鍣ㄦ甯革紝鍒囨崲鍥炴潵 CURRENT_SERVER=$DEFAULT_SERVER switch_proxy $CURRENT_SERVER echo "switch to default ["$(uci_get_by_name $CURRENT_SERVER server)"] proxy!" >> /tmp/ssrplus.log @@ -142,18 +142,18 @@ do fi fi - #判断当前代理是否正常 + #鍒ゆ柇褰撳墠浠g悊鏄惁姝e父 check_proxy current_ret=$? if [ "$current_ret" = "1" ] ;then - #当前代理错误,判断有无可用的服务器 + #褰撳墠浠g悊閿欒锛屽垽鏂湁鏃犲彲鐢ㄧ殑鏈嶅姟鍣 #echo "current error" echo "$(date "+%Y-%m-%d %H:%M:%S") Current server error, try to switch another server." >> /tmp/ssrplus.log select_proxy if [ "$ENABLE_SERVER" != nil ] ;then - #有其他服务器可用,进行切换 + #鏈夊叾浠栨湇鍔″櫒鍙敤锛岃繘琛屽垏鎹 #echo $(uci_get_by_name $new_proxy server) echo "$(date "+%Y-%m-%d %H:%M:%S") Another server is avilable, now switching server." >> /tmp/ssrplus.log CURRENT_SERVER=$ENABLE_SERVER @@ -161,7 +161,9 @@ do normal_flag=1 echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR server switch OK" >> /tmp/ssrplus.log else - normal_flag=0 + switch_proxy $CURRENT_SERVER + normal_flag=1 + echo "$(date "+%Y-%m-%d %H:%M:%S") Try restart current server." >> /tmp/ssrplus.log fi else normal_flag=0 @@ -170,4 +172,4 @@ do done -} \ No newline at end of file +}