You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2023. It is now read-only.
以可否访问YouTube为标准来判断是否运行成功,不太严谨,建议改为:
-- 判断ss-redir是否运行
state = luci.sys.exec('if [ "
ps | grep /usr/bin/ss-redir | grep -c -v grep
" == "1" ]; then echo -n "start"; else echo -n "stop"; fi;')-- 获取本机IP地址
localip = luci.sys.exec('curl -s https://api.ipify.org/ | tr -d '\n'')
if (state == "start"){
if (服务器IP == localip){
status = "运行中 连接正常";
}else{
status = "运行中 连接错误";
}
}else{
status = "未启动";
}
原理:如果已经运行成功,则查询到的本地IP与服务器地址相同。
如果服务器地址填写的是域名而不是IP,可以想法解析为IP,这里不展开说明。
get“服务器IP”方法,这里也不详说了。
再说个另外的判断YouTube是否可访问的方法,简洁。
http_code = luci.sys.exec('curl -Ikm 10 -o /dev/null -s -w %{http_code} https://www.youtube.com')
如果http_code等于200 ,那就表明可以访问,这是利用HTTP状态码进行判断,状态码为200表明成功返回网页。
The text was updated successfully, but these errors were encountered: