支持以空格分割的订阅节点和空订阅节点的处理 (#2770)

* 支持以空格分割的订阅节点

* 修复订阅内容为空字符串时导致的json格式转换异常
This commit is contained in:
Max Zhao 2020-01-15 11:05:15 +08:00 committed by coolsnowwolf
parent d78dd0b948
commit 320f80fec6

View File

@ -112,6 +112,11 @@ local function processData(szType, content)
hash = md5(luci.jsonc.stringify(content))
end
result.hashkey = hash
-- 如果节点内容为空,返回无效的节点信息
if content == '' then
result.server = ''
return result, hash
end
if szType == 'ssr' then
local dat = split(content, "/\\?")
local hostInfo = split(dat[1], ':')
@ -232,7 +237,7 @@ local execute = function()
node = servers
else
-- ssd 外的格式
node = split(base64Decode(raw, true), "\n")
node = split(base64Decode(raw, true):gsub(" ", "\n"), "\n")
end
for _, v in ipairs(node) do
if v then
@ -336,4 +341,4 @@ if subscribe_url and #subscribe_url > 0 then
luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
end
end)
end
end