diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 40e3829c7..fd8b47eff 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -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) diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index b7d13350a..3d5460170 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -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() {