parent
0fc5e595b8
commit
5bbaac7772
@ -129,11 +129,13 @@ end
|
||||
|
||||
function curl_direct(url, file, args)
|
||||
--直连访问
|
||||
local chn_list = uci:get(appname, "@global[0]", "chn_list") or "direct"
|
||||
local Dns = (chn_list == "proxy") and "1.1.1.1" or "223.5.5.5"
|
||||
if not args then args = {} end
|
||||
local tmp_args = clone(args)
|
||||
local domain, port = get_domain_port_from_url(url)
|
||||
if domain then
|
||||
local ip = domainToIPv4(domain)
|
||||
local ip = domainToIPv4(domain, Dns)
|
||||
if ip then
|
||||
tmp_args[#tmp_args + 1] = "--resolve " .. domain .. ":" .. port .. ":" .. ip
|
||||
end
|
||||
@ -813,7 +815,7 @@ local default_file_tree = {
|
||||
|
||||
local function get_api_json(url)
|
||||
local jsonc = require "luci.jsonc"
|
||||
local return_code, content = curl_logic(url, nil, curl_args)
|
||||
local return_code, content = curl_auto(url, nil, curl_args)
|
||||
if return_code ~= 0 or content == "" then return {} end
|
||||
return jsonc.parse(content) or {}
|
||||
end
|
||||
@ -930,7 +932,7 @@ function to_download(app_name, url, size)
|
||||
local _curl_args = clone(curl_args)
|
||||
table.insert(_curl_args, "-m 60")
|
||||
|
||||
local return_code, result = curl_logic(url, tmp_file, _curl_args)
|
||||
local return_code, result = curl_auto(url, tmp_file, _curl_args)
|
||||
result = return_code == 0
|
||||
|
||||
if not result then
|
||||
@ -1081,7 +1083,7 @@ end
|
||||
function to_check_self()
|
||||
local url = "https://raw.githubusercontent.com/xiaorouji/openwrt-passwall/main/luci-app-passwall/Makefile"
|
||||
local tmp_file = "/tmp/passwall_makefile"
|
||||
local return_code, result = curl_logic(url, tmp_file, curl_args)
|
||||
local return_code, result = curl_auto(url, tmp_file, curl_args)
|
||||
result = return_code == 0
|
||||
if not result then
|
||||
exec("/bin/rm", {"-f", tmp_file})
|
||||
|
@ -92,7 +92,7 @@ local function curl(url, file, valifile)
|
||||
if valifile then
|
||||
args[#args + 1] = "--dump-header " .. valifile
|
||||
end
|
||||
local return_code, result = api.curl_logic(url, nil, args)
|
||||
local return_code, result = api.curl_auto(url, nil, args)
|
||||
return tonumber(result)
|
||||
end
|
||||
|
||||
@ -285,7 +285,7 @@ end
|
||||
local function fetch_geoip()
|
||||
--请求geoip
|
||||
xpcall(function()
|
||||
local return_code, content = api.curl_logic(geoip_api)
|
||||
local return_code, content = api.curl_auto(geoip_api)
|
||||
local json = jsonc.parse(content)
|
||||
if json.tag_name and json.assets then
|
||||
for _, v in ipairs(json.assets) do
|
||||
@ -336,7 +336,7 @@ end
|
||||
local function fetch_geosite()
|
||||
--请求geosite
|
||||
xpcall(function()
|
||||
local return_code, content = api.curl_logic(geosite_api)
|
||||
local return_code, content = api.curl_auto(geosite_api)
|
||||
local json = jsonc.parse(content)
|
||||
if json.tag_name and json.assets then
|
||||
for _, v in ipairs(json.assets) do
|
||||
|
Loading…
Reference in New Issue
Block a user