1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-12 18:41:51 +00:00

Better check for SS

This commit is contained in:
Ycarus 2018-05-14 13:51:26 +02:00
parent e061504eeb
commit d746142626

View file

@ -12,22 +12,27 @@ timeout=${OMR_TRACKER_TIMEOUT:-5}
interval=${OMR_TRACKER_INTERVAL:-10}
retry=${OMR_TRACKER_TRIES:-4}
proxy=${OMR_TRACKER_PROXY:-127.0.0.1:1111}
hosts=${OMR_TRACKER_HOSTS:-1.1.1.1 23.96.52.53}
hosts=${OMR_TRACKER_HOSTS:-1.1.1.1 1.0.0.1 23.96.52.53}
nodns=0
last=0
while true; do
host=${hosts%% *}
if curl -s --socks5 "${proxy}" --max-time "${timeout}" --retry "${retry}" "$host" &>/dev/null ; then
[ ${last} = 0 ] && log "Shadowsocks is up (can contact ${host})"
/etc/init.d/shadowsocks-libev rules_up 2> /dev/null
last=1
else
[ ${last} = 1 ] && log "Shadowsocks is down (can't contact ${host})"
/etc/init.d/shadowsocks-libev rules_down 2> /dev/null
last=0
fi
while [ "$last" -gt 0 ]; do
host=${hosts%% *}
if curl -s --socks5 "${proxy}" --max-time "${timeout}" "$host" &>/dev/null ; then
[ "${last}" -gt 0 ] && log "Shadowsocks is up (can contact ${host})"
/etc/init.d/shadowsocks-libev rules_up 2> /dev/null
last=0
else
last=$((last + 1 ))
[ "${last}" -ge "${retry}" ] && {
log "Shadowsocks is down (can't contact ${host})"
/etc/init.d/shadowsocks-libev rules_down 2> /dev/null
last=0
}
fi
done
sleep "${interval}"
done