From a615d1824d90b57f2c857edfa07f3a62f2b28c66 Mon Sep 17 00:00:00 2001 From: Mattraks <16359027+Mattraks@users.noreply.github.com> Date: Thu, 27 Feb 2020 20:13:07 +0800 Subject: [PATCH 1/3] luci-app-ssr-plus:Adjust invalid nodes (#3377) --- .../root/usr/share/shadowsocksr/subscribe.lua | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua index 3accef0ba6..1d26df9e3c 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -96,15 +96,15 @@ end -- 处理数据 local function processData(szType, content) local result = { --- auth_enable = '0', --- switch_enable = '1', - type = szType, - local_port = 1234, --- timeout = 60, -- 不太确定 好像是死的 --- fast_open = 0, --- kcp_enable = 0, --- kcp_port = 0, - kcp_param = '--nocomp' + -- auth_enable = '0', + -- switch_enable = '1', + type = szType, + local_port = 1234, + -- timeout = 60, -- 不太确定 好像是死的 + -- fast_open = 0, + -- kcp_enable = 0, + -- kcp_port = 0, + kcp_param = '--nocomp' } if szType == 'ssr' then local dat = split(content, "/%?") @@ -137,8 +137,8 @@ local function processData(szType, content) result.vmess_id = info.id result.alias = info.ps result.insecure = 1 --- result.mux = 1 --- result.concurrency = 8 + -- result.mux = 1 + -- result.concurrency = 8 if info.net == 'ws' then result.ws_host = info.host result.ws_path = info.path @@ -265,10 +265,10 @@ local execute = function() nodes = base64Decode(raw:sub(nEnd + 1, #raw)) nodes = jsonParse(nodes) local extra = { - airport = nodes.airport, - port = nodes.port, - encryption = nodes.encryption, - password = nodes.password + airport = nodes.airport, + port = nodes.port, + encryption = nodes.encryption, + password = nodes.password } local servers = {} -- SS里面包着 干脆直接这样 @@ -304,8 +304,9 @@ local execute = function() result.alias:find("剩余流量") or result.alias:find("QQ群") or result.alias:find("官网") or + result.alias:find("防失联地址") or not result.server - then + then log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias) else log('成功解析: ' .. result.type ..' 节点, ' .. result.alias) @@ -343,9 +344,8 @@ local execute = function() else log('忽略手动添加的节点: ' .. old.alias) end - + end) - for k, v in ipairs(nodeResult) do for kk, vv in ipairs(v) do if not vv._ignore then @@ -354,33 +354,30 @@ local execute = function() ucic:set(name, section, "switch_enable", switch) add = add + 1 end - end end ucic:commit(name) - - -- 如果原有服务器节点已经不见了就尝试换为第一个节点 + -- 如果原有服务器节点已经不见了就尝试换为第一个节点 local globalServer = ucic:get_first(name, 'global', 'global_server', '') local firstServer = ucic:get_first(name, uciType) - if firstServer then - if not ucic:get(name, globalServer) then - luci.sys.call("/etc/init.d/" .. name .. " stop > /dev/null 2>&1 &") - ucic:commit(name) - ucic:set(name, ucic:get_first(name, 'global'), 'global_server', ucic:get_first(name, uciType)) - ucic:commit(name) - log('当前主服务器节点已被删除,正在自动更换为第一个节点。') - luci.sys.call("/etc/init.d/" .. name .. " start > /dev/null 2>&1 &") - else - log('维持当前主服务器节点。') - luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") + if not ucic:get(name, globalServer) then + luci.sys.call("/etc/init.d/" .. name .. " stop > /dev/null 2>&1 &") + ucic:commit(name) + ucic:set(name, ucic:get_first(name, 'global'), 'global_server', ucic:get_first(name, uciType)) + ucic:commit(name) + log('当前主服务器节点已被删除,正在自动更换为第一个节点。') + luci.sys.call("/etc/init.d/" .. name .. " start > /dev/null 2>&1 &") + else + log('维持当前主服务器节点。') + luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") end else - log('没有服务器节点了,停止服务') - luci.sys.call("/etc/init.d/" .. name .. " stop > /dev/null 2>&1 &") + log('没有服务器节点了,停止服务') + luci.sys.call("/etc/init.d/" .. name .. " stop > /dev/null 2>&1 &") end log('新增节点数量: ' ..add, '删除节点数量: ' .. del) - log('订阅更新成功') + log('订阅更新成功') end end @@ -392,10 +389,10 @@ if subscribe_url and #subscribe_url > 0 then local firstServer = ucic:get_first(name, uciType) if firstServer then luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 - log('重启服务成功') + log('重启服务成功') else luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 - log('停止服务成功') + log('停止服务成功') end end) end From 3fcc4bed24073467a40c53f0f2c1849d92a817be Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Thu, 27 Feb 2020 20:43:39 +0800 Subject: [PATCH 2/3] luci-app-ssr-plus: subscribe fail when null alias servr name --- .../root/usr/share/shadowsocksr/subscribe.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua index 1d26df9e3c..2819b978c9 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -342,6 +342,9 @@ local execute = function() setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } }) end else + if not old.alias then + old.alias = old.server .. ':' .. old.server_port + end log('忽略手动添加的节点: ' .. old.alias) end From 965924a2947c34f51247f8bca26a08ce0a56e5c8 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Thu, 27 Feb 2020 21:33:28 +0800 Subject: [PATCH 3/3] luci-app-ssr-plus: change delete servers behavior --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../luasrc/model/cbi/shadowsocksr/servers.lua | 29 +++++-------------- .../luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 3 ++ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index f6358a532b..f679ee007e 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus -PKG_VERSION:=153 +PKG_VERSION:=154 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua index bedf07c33c..bf30d3dafd 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -55,21 +55,17 @@ o = s:option(Button,"subscribe", translate("Update All Subscribe Severs")) o.rawhtml = true o.template = "shadowsocksr/subscribe" - --- o.inputstyle = "apply" --- o.write = function() --- luci.sys.call("lua /root/subscribe.lua >>/tmp/ssrplus.log 2>&1") --- -- luci.sys.call("echo 123 >>/tmp/ssrplus.log 2>&1") --- -- luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1") --- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) --- end - - -o = s:option(Button,"delete",translate("Delete all severs")) +o = s:option(Button,"delete",translate("Delete All Subscribe Severs")) o.inputstyle = "reset" o.description = string.format(translate("Server Count") .. ": %d", server_count) o.write = function() -uci:delete_all("shadowsocksr", "servers", function(s) return true end) +uci:delete_all("shadowsocksr", "servers", function(s) + if s["hashkey"] then + return true + else + return false + end +end) uci:save("shadowsocksr") luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop") luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) @@ -112,15 +108,6 @@ function o.cfgvalue(...) return Value.cfgvalue(...) or "?" end -if nixio.fs.access("/usr/bin/kcptun-client") then - -o = s:option(DummyValue, "kcp_enable", translate("KcpTun")) -function o.cfgvalue(...) - return Value.cfgvalue(...) or "?" -end - -end - o = s:option(DummyValue, "switch_enable", translate("Auto Switch")) function o.cfgvalue(...) return Value.cfgvalue(...) or "1" diff --git a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index 61c69e06fa..a97fd1db75 100644 --- a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -493,6 +493,9 @@ msgstr "服务器节点故障自动切换设置" msgid "Delete all severs" msgstr "删除所有服务器节点" +msgid "Delete All Subscribe Severs" +msgstr "删除所有订阅服务器节点" + msgid "Severs Nodes" msgstr "服务器节点"