luci: Optimize subscribe UA
This commit is contained in:
parent
99e5e171d6
commit
9dc1a2f719
@ -145,6 +145,10 @@ o.default = 0
|
|||||||
o:depends("auto_update", true)
|
o:depends("auto_update", true)
|
||||||
|
|
||||||
o = s:option(Value, "user_agent", translate("User-Agent"))
|
o = s:option(Value, "user_agent", translate("User-Agent"))
|
||||||
o.default = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
|
o.default = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
|
||||||
|
o:value("curl")
|
||||||
|
o:value("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0")
|
||||||
|
o:value("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0")
|
||||||
|
o:value("Passwall/OpenWrt")
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -10,7 +10,7 @@ jsonc = require "luci.jsonc"
|
|||||||
i18n = require "luci.i18n"
|
i18n = require "luci.i18n"
|
||||||
|
|
||||||
appname = "passwall"
|
appname = "passwall"
|
||||||
curl_args = { "-skfL", "--connect-timeout 3", "--retry 3", "-m 60" }
|
curl_args = { "-skfL", "--connect-timeout 3", "--retry 3" }
|
||||||
command_timeout = 300
|
command_timeout = 300
|
||||||
OPENWRT_ARCH = nil
|
OPENWRT_ARCH = nil
|
||||||
DISTRIB_ARCH = nil
|
DISTRIB_ARCH = nil
|
||||||
@ -820,7 +820,10 @@ function to_download(app_name, url, size)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local return_code, result = curl_logic(url, tmp_file, curl_args)
|
local _curl_args = clone(curl_args)
|
||||||
|
table.insert(_curl_args, "-m 60")
|
||||||
|
|
||||||
|
local return_code, result = curl_logic(url, tmp_file, _curl_args)
|
||||||
result = return_code == 0
|
result = return_code == 0
|
||||||
|
|
||||||
if not result then
|
if not result then
|
||||||
|
@ -898,13 +898,11 @@ local function processData(szType, content, add_mode, add_from)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function curl(url, file, ua)
|
local function curl(url, file, ua)
|
||||||
if not ua or ua == "" then
|
local curl_args = api.clone(api.curl_args)
|
||||||
ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
|
if ua and ua ~= "" and ua ~= "curl" then
|
||||||
|
table.insert(curl_args, '--user-agent "' .. ua .. '"')
|
||||||
end
|
end
|
||||||
local args = {
|
local return_code, result = api.curl_logic(url, file, curl_args)
|
||||||
"-skL", "--retry 3", "--connect-timeout 3", '--user-agent "' .. ua .. '"'
|
|
||||||
}
|
|
||||||
local return_code, result = api.curl_logic(url, file, args)
|
|
||||||
return return_code
|
return return_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user