Merge Lean's source

This commit is contained in:
CN_SZTL 2020-02-28 01:04:15 +08:00
commit 0f0e33d4f3
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 49 additions and 59 deletions

View File

@ -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)

View File

@ -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"

View File

@ -493,6 +493,9 @@ msgstr "服务器节点故障自动切换设置"
msgid "Delete all severs"
msgstr "删除所有服务器节点"
msgid "Delete All Subscribe Severs"
msgstr "删除所有订阅服务器节点"
msgid "Severs Nodes"
msgstr "服务器节点"

View File

@ -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)
@ -341,11 +342,13 @@ 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
end)
for k, v in ipairs(nodeResult) do
for kk, vv in ipairs(v) do
if not vv._ignore then
@ -354,33 +357,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 +392,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