luci: Optimize subscribe UA

This commit is contained in:
xiaorouji 2024-03-19 19:13:53 +08:00 committed by sbwml
parent 99e5e171d6
commit 9dc1a2f719
3 changed files with 14 additions and 9 deletions

View File

@ -145,6 +145,10 @@ o.default = 0
o:depends("auto_update", true)
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

View File

@ -10,7 +10,7 @@ jsonc = require "luci.jsonc"
i18n = require "luci.i18n"
appname = "passwall"
curl_args = { "-skfL", "--connect-timeout 3", "--retry 3", "-m 60" }
curl_args = { "-skfL", "--connect-timeout 3", "--retry 3" }
command_timeout = 300
OPENWRT_ARCH = nil
DISTRIB_ARCH = nil
@ -820,7 +820,10 @@ function to_download(app_name, url, size)
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
if not result then

View File

@ -898,13 +898,11 @@ local function processData(szType, content, add_mode, add_from)
end
local function curl(url, file, ua)
if not ua or ua == "" then
ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
local curl_args = api.clone(api.curl_args)
if ua and ua ~= "" and ua ~= "curl" then
table.insert(curl_args, '--user-agent "' .. ua .. '"')
end
local args = {
"-skL", "--retry 3", "--connect-timeout 3", '--user-agent "' .. ua .. '"'
}
local return_code, result = api.curl_logic(url, file, args)
local return_code, result = api.curl_logic(url, file, curl_args)
return return_code
end