mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-ssr-plus: check global server node to make sure it's valid when startup
This commit is contained in:
parent
de64f40b56
commit
8934f681b3
@ -1,8 +1,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-ssr-plus
|
||||
PKG_VERSION:=165
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=166
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
@ -41,6 +41,11 @@ uci_get_by_type() {
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
uci_get_by_cfgid() {
|
||||
local ret=$(uci show $NAME.@$1[0].$2 | awk -F '.' '{print $2}' 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
add_cron() {
|
||||
sed -i '/shadowsocksr/d' $CRON_FILE
|
||||
sed -i '/ssrplus.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/ssrplus.log' >>$CRON_FILE
|
||||
@ -512,6 +517,7 @@ start() {
|
||||
GLOBAL_SERVER=$switch_server
|
||||
switch_enable=1
|
||||
fi
|
||||
|
||||
if rules; then
|
||||
start_redir
|
||||
mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/
|
||||
@ -539,8 +545,23 @@ start() {
|
||||
service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable
|
||||
fi
|
||||
fi
|
||||
|
||||
ENABLE_SERVER=$(uci_get_by_type global global_server nil)
|
||||
[ "$ENABLE_SERVER" == "nil" ] && return 1
|
||||
if [ "$ENABLE_SERVER" == "nil" ]; then
|
||||
return 1
|
||||
else
|
||||
STYPE=$(uci_get_by_name $ENABLE_SERVER type nil)
|
||||
if [ "$STYPE" == "nil" ]; then
|
||||
CFGID=$(uci_get_by_cfgid servers type nil)
|
||||
if [ "$CFGID" == "nil" ]; then
|
||||
uci set shadowsocksr.@global[0].global_server='nil'
|
||||
else
|
||||
uci set shadowsocksr.@global[0].global_server=$CFGID
|
||||
fi
|
||||
uci commit shadowsocksr
|
||||
/etc/init.d/shadowsocksr restart
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
boot() {
|
||||
|
Loading…
Reference in New Issue
Block a user