From 5945d0a79b4e3aba455c0974ed673d65bbf1cfa9 Mon Sep 17 00:00:00 2001 From: Mattraks <16359027+Mattraks@users.noreply.github.com> Date: Thu, 14 Jan 2021 11:58:54 +0800 Subject: [PATCH] luci-app-ssr-plus:bump to 182-5 Modify 'Apply' and 'Delete All Subscribe Severs' execution method Fix the subscription update failure caused by manually adding invalid nodes --- luci-app-ssr-plus/Makefile | 2 +- .../luasrc/controller/shadowsocksr.lua | 17 ++++++++++++++--- .../luasrc/model/cbi/shadowsocksr/servers.lua | 6 ++++-- .../root/usr/share/shadowsocksr/subscribe.lua | 10 ++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index 95b2f23e..eb198676 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=182 -PKG_RELEASE:=4 +PKG_RELEASE:=5 define Package/$(PKG_NAME)/conffiles /etc/config/shadowsocksr diff --git a/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua b/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua index 2fe43138..55be05e7 100644 --- a/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua +++ b/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua @@ -21,6 +21,8 @@ function index() entry({"admin", "services", "shadowsocksr", "run"}, call("act_status")).leaf = true entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf = true entry({"admin", "services", "shadowsocksr", "reset"}, call("act_reset")) + entry({"admin", "services", "shadowsocksr", "restart"}, call("act_restart")) + entry({"admin", "services", "shadowsocksr", "delete"}, call("act_delete")) end function subscribe() @@ -109,7 +111,16 @@ function check_port() end function act_reset() - nixio.exec("/etc/init.d/shadowsocksr", "reset") - http.redirect(luci.dispatcher.build_url('admin/services/shadowsocksr')) - return + luci.sys.call("/etc/init.d/shadowsocksr reset &") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr")) end + +function act_restart() + luci.sys.call("/etc/init.d/shadowsocksr restart &") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr")) +end + +function act_delete() + luci.sys.call("/etc/init.d/shadowsocksr restart &") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) +end \ No newline at end of file diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua index f7cad174..ea620a00 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -66,7 +66,8 @@ o.write = function() end end) uci:save("shadowsocksr") - m.uci:commit("shadowsocksr") + uci:commit("shadowsocksr") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "delete")) return end @@ -113,7 +114,8 @@ node.inputstyle = "apply" node.write = function(self, section) uci:set("shadowsocksr", '@global[0]', 'global_server', section) uci:save("shadowsocksr") - m.uci:commit("shadowsocksr") + uci:commit("shadowsocksr") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "restart")) end o = s:option(Flag, "switch_enable", translate("Auto Switch")) diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua index 5695acc0..7962c883 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -457,9 +457,15 @@ local execute = function() end else if not old.alias then - old.alias = old.server .. ':' .. old.server_port + if not old.server or old.server_port then + ucic:delete(name, old['.name']) + else + old.alias = old.server .. ':' .. old.server_port + log('忽略手动添加的节点: ' .. old.alias) + end + else + log('忽略手动添加的节点: ' .. old.alias) end - log('忽略手动添加的节点: ' .. old.alias) end end) for k, v in ipairs(nodeResult) do