parent
c423746d17
commit
76829b9ffc
@ -1303,19 +1303,21 @@ local function processData(szType, content, add_mode, add_from)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function curl(url, file, ua, mode)
|
local function curl(url, file, ua, mode)
|
||||||
local curl_args = api.clone(api.curl_args)
|
local curl_args = {
|
||||||
|
"-skL", "-w %{http_code}", "--retry 3", "--connect-timeout 3"
|
||||||
|
}
|
||||||
if ua and ua ~= "" and ua ~= "curl" then
|
if ua and ua ~= "" and ua ~= "curl" then
|
||||||
table.insert(curl_args, '--user-agent "' .. ua .. '"')
|
curl_args[#curl_args + 1] = '--user-agent "' .. ua .. '"'
|
||||||
end
|
end
|
||||||
local return_code
|
local return_code, result
|
||||||
if mode == "direct" then
|
if mode == "direct" then
|
||||||
return_code = api.curl_direct(url, file, curl_args)
|
return_code, result = api.curl_direct(url, file, curl_args)
|
||||||
elseif mode == "proxy" then
|
elseif mode == "proxy" then
|
||||||
return_code = api.curl_proxy(url, file, curl_args)
|
return_code, result = api.curl_proxy(url, file, curl_args)
|
||||||
else
|
else
|
||||||
return_code = api.curl_auto(url, file, curl_args)
|
return_code, result = api.curl_auto(url, file, curl_args)
|
||||||
end
|
end
|
||||||
return return_code
|
return tonumber(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function truncate_nodes(add_from)
|
local function truncate_nodes(add_from)
|
||||||
@ -1714,18 +1716,12 @@ local execute = function()
|
|||||||
local result = (not access_mode) and "自动" or (access_mode == "direct" and "直连访问" or (access_mode == "proxy" and "通过代理" or "自动"))
|
local result = (not access_mode) and "自动" or (access_mode == "direct" and "直连访问" or (access_mode == "proxy" and "通过代理" or "自动"))
|
||||||
log('正在订阅:【' .. remark .. '】' .. url .. ' [' .. result .. ']')
|
log('正在订阅:【' .. remark .. '】' .. url .. ' [' .. result .. ']')
|
||||||
local tmp_file = "/tmp/" .. cfgid
|
local tmp_file = "/tmp/" .. cfgid
|
||||||
local raw = curl(url, tmp_file, ua, access_mode)
|
value.http_code = curl(url, tmp_file, ua, access_mode)
|
||||||
if raw ~= 0 then
|
if value.http_code ~= 200 then
|
||||||
fail_list[#fail_list + 1] = value
|
fail_list[#fail_list + 1] = value
|
||||||
else
|
else
|
||||||
if luci.sys.call("[ -f " .. tmp_file .. " ] && sed -i -e '/^[ \t]*$/d' -e '/^[ \t]*\r$/d' " .. tmp_file) == 0 then
|
if luci.sys.call("[ -f " .. tmp_file .. " ] && sed -i -e '/^[ \t]*$/d' -e '/^[ \t]*\r$/d' " .. tmp_file) == 0 then
|
||||||
local f = io.open(tmp_file, "r")
|
local f = io.open(tmp_file, "r")
|
||||||
local count = 0
|
|
||||||
for _ in f:lines() do
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
if count == 1 then
|
|
||||||
f:seek("set")
|
|
||||||
local stdout = f:read("*all")
|
local stdout = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
local raw_data = trim(stdout)
|
local raw_data = trim(stdout)
|
||||||
@ -1738,11 +1734,6 @@ local execute = function()
|
|||||||
parse_link(raw_data, "2", remark, cfgid)
|
parse_link(raw_data, "2", remark, cfgid)
|
||||||
uci:set(appname, cfgid, "md5", new_md5)
|
uci:set(appname, cfgid, "md5", new_md5)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
f:close()
|
|
||||||
os.remove(tmp_file)
|
|
||||||
fail_list[#fail_list + 1] = value
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
fail_list[#fail_list + 1] = value
|
fail_list[#fail_list + 1] = value
|
||||||
end
|
end
|
||||||
@ -1760,7 +1751,7 @@ local execute = function()
|
|||||||
|
|
||||||
if #fail_list > 0 then
|
if #fail_list > 0 then
|
||||||
for index, value in ipairs(fail_list) do
|
for index, value in ipairs(fail_list) do
|
||||||
log(string.format('【%s】订阅失败,可能是订阅地址无效,或是网络问题,请诊断!', value.remark))
|
log(string.format('【%s】订阅失败,可能是订阅地址无效,或是网络问题,请诊断![%s]', value.remark, tostring(value.http_code)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
update_node(0)
|
update_node(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user