1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Merge branch 'test' into develop

This commit is contained in:
suyuan 2021-03-23 23:55:52 +08:00
commit eee530bb72
19 changed files with 195 additions and 33 deletions

View file

@ -174,11 +174,10 @@ _httping() {
ret=$(httping "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
-c 1 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
fi
return
@ -187,11 +186,10 @@ _httping() {
ret=$(httping -l "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
-c 1 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
fi
return
@ -370,12 +368,24 @@ while true; do
else
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_LIST_HOSTS,$OMR_TRACKER_HOST"
fi
OMR_TRACKER_STATUS_MSG="check error"
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$server_ping" != false ] && [ "$OMR_TRACKER_TYPE" != "httping" ] && [ "$OMR_TRACKER_SERVER_HTTP_TEST" = "1" ]; then
serverip_ping=false
config_load openmptcprouter
config_foreach _httping_server server $OMR_TRACKER_DEVICE_IP
if [ "$serverip_ping" = false ]; then
OMR_TRACKER_STATUS_MSG="No access to server API"
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
@ -454,16 +464,28 @@ while true; do
break
else
if [ "$OMR_TRACKER_LIST_HOSTS6" = "" ]; then
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_HOST6"
OMR_TRACKER_LIST_HOSTS6="$OMR_TRACKER_HOST6"
else
OMR_TRACKER_LIST_HOSTS6="$OMR_TRACKER_LIST_HOSTS6,$OMR_TRACKER_HOST6"
fi
OMR_TRACKER_STATUS_MSG="check error"
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$server_ping" != false ] && [ "$OMR_TRACKER_TYPE" != "httping" ] && [ "$OMR_TRACKER_SERVER_HTTP_TEST" = "1" ]; then
serverip_ping=false
config_load openmptcprouter
config_foreach _httping_server server $OMR_TRACKER_DEVICE_IP
if [ "$serverip_ping" = false ]; then
OMR_TRACKER_STATUS_MSG="No access to server API"
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"

View file

@ -57,6 +57,7 @@ _check_master() {
local name=$1
local count=0
local countips=0
local changes="0"
config_get master $1 master
config_get ip $1 ip
config_get port $1 port "65500"
@ -69,10 +70,10 @@ _check_master() {
if [ "$server_ping" = true ]; then
if [ "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n')" != "$ip" ]; then
logger -t "OMR-Tracker-Server" "Master server ${name} up ($ip), set it back"
changes="1"
#logger -t "OMR-Tracker-Server" "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n') - $ip"
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss${count}.server=$ip
commit shadowsocks-libev
EOF
if [ "$count" -eq "0" ]; then
uci -q batch <<-EOF >/dev/null
@ -97,7 +98,6 @@ _check_master() {
/etc/init.d/openvpn restart >/dev/null 2>/dev/null
/etc/init.d/dsvpn restart >/dev/null 2>/dev/null
fi
/etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null
fi
config_load shadowsocks-libev
config_foreach _enable_redir ss_redir
@ -109,6 +109,14 @@ _check_master() {
countips=$((countips+1))
}
config_list_foreach $1 ip set_ip
#if [ "$server_ping" = true ] && [ "$countips" = "1" ]; then
# uci -q batch <<-EOF >/dev/null
# set shadowsocks-libev.sss${count}.server=$ip
# EOF
# config_foreach _enable_redir ss_redir
#fi
uci -q commit shadowsocks-libev
[ "$changes" = "1" ] && /etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null
break
}
}
@ -117,6 +125,7 @@ _check_backup() {
local name=$1
local count=0
local countips=0
local changes="0"
config_get backup $1 backup
config_get ip $1 ip
config_get port $1 port
@ -129,9 +138,9 @@ _check_backup() {
if [ "$server_ping" = true ]; then
if [ "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n')" != "$ip" ]; then
logger -t "OMR-Tracker-Server" "Use backup server $1 ($ip)"
changes="1"
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss${count}.server=$ip
commit shadowsocks-libev
EOF
if [ "$count" -eq "0" ]; then
uci -q batch <<-EOF >/dev/null
@ -156,7 +165,6 @@ _check_backup() {
/etc/init.d/openvpn restart >/dev/null 2>/dev/null
/etc/init.d/dsvpn restart >/dev/null 2>/dev/null
fi
/etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null
sleep $waittest
fi
config_load shadowsocks-libev
@ -169,7 +177,14 @@ _check_backup() {
countips=$((countips+1))
}
config_list_foreach $1 ip set_ip
#if [ "$server_ping" = true ] && [ "$countips" = "1" ]; then
# uci -q batch <<-EOF >/dev/null
# set shadowsocks-libev.sss${count}.server=$ip
# EOF
# config_foreach _enable_redir ss_redir
#fi
uci -q commit shadowsocks-libev
[ "$changes" = "1" ] && /etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null
[ "$server_ping" = true ] && break
}
}

View file

@ -16,20 +16,19 @@ config defaults 'defaults'
list hosts '199.85.126.30'
list hosts '119.29.29.29'
list hosts '182.254.118.118'
list hosts6 '2400:3200::1 2400:3200:baba::1'
list hosts6 '2400:da00::6666'
list hosts6 '2606:4700:4700::1111'
list hosts6 '2606:4700:4700::1001'
list hosts6 '2620:fe::fe'
list hosts6 '2620:fe::9'
list hosts6 '2001:4860:4860::8888'
list hosts6 '2001:4860:4860::8844'
option timeout '10'
option timeout '2'
option tries '3'
option interval '2'
option interval_tries '1'
option type 'ping'
option wait_test '0'
option server_http_test '1'
option options ''
config proxy 'proxy'

View file

@ -15,7 +15,7 @@
_validate_section() {
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test
uci_validate_section omr-tracker "$1" "$2" \
'hosts:list(host)' \
@ -27,6 +27,7 @@ _validate_section() {
'wait_test:uinteger' \
'type:string:undef' \
'enabled:bool:1' \
'server_http_test:bool:1' \
'options:string'
[ -z "$hosts" ] && hosts=$tmp_hosts
@ -38,6 +39,7 @@ _validate_section() {
[ -z "$wait_test" ] && wait_test=$tmp_wait_test
[ -z "$options" ] && options=$tmp_options
[ "$type" = "undef" ] && type=${tmp_type:-ping}
[ -z "$server_http_test" ] && server_http_test=$tmp_server_http_test
[ -z "$enabled" ] && enabled=$tmp_enabled
}
@ -46,7 +48,7 @@ _launch_tracker() {
loopback|lan*|if0*) return;;
esac
local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test ipv6 proto
local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test
_validate_section "defaults" "defaults"
_validate_section "interface" "$1"
@ -84,6 +86,7 @@ _launch_tracker() {
procd_append_param env "OMR_TRACKER_IPV6=$ipv6"
procd_append_param env "OMR_TRACKER_PROTO=$proto"
procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test"
procd_append_param env "OMR_TRACKER_SERVER_HTTP_TEST=$server_http_test"
procd_set_param limits nofile="51200 51200"
procd_set_param respawn 0 10 0
procd_set_param stderr 1
@ -268,7 +271,7 @@ start_service() {
}
service_triggers() {
procd_add_reload_trigger omr-tracker network shadowsocks-libev
procd_add_reload_trigger omr-tracker network shadowsocks-libev v2ray
}
reload_service() {

View file

@ -65,6 +65,13 @@ if [ "$(uci -q get omr-tracker.proxy.hosts | grep '176.103.130.130')" != "" ]; t
EOF
fi
if [ "$(uci -q get omr-tracker.proxy.hosts | grep '198.41.212.162')" = "" ]; then
uci -q batch <<-EOF >/dev/null
add_list omr-tracker.proxy.hosts='198.41.212.162'
commit omr-tracker
EOF
fi
if [ -z "$(uci -q get omr-tracker.defaults.hosts6)" ]; then
uci -q batch <<-EOF >/dev/null
add_list omr-tracker.defaults.hosts6='2606:4700:4700::1111'
@ -86,4 +93,11 @@ if [ "$(uci -q get omr-tracker.defaults.wait_test)" = "" ]; then
EOF
fi
if [ "$(uci -q get omr-tracker.defaults.server_http_test)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set omr-tracker.defaults.server_http_test=1
commit omr-tracker
EOF
fi
exit 0