Skip to content

Commit

Permalink
luci-app-ssr-plus: check global server node to make sure it's valid w…
Browse files Browse the repository at this point in the history
…hen startup
  • Loading branch information
coolsnowwolf committed Mar 12, 2020
1 parent de64f40 commit 8934f68
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package/lean/luci-app-ssr-plus/Makefile
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
23 changes: 22 additions & 1 deletion package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8934f68

Please sign in to comment.