mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 16:44:23 +08:00
💐 Sync 2026-08-15 21:58:49
This commit is contained in:
1 parent
5bd78ffd1e
commit
2821617ed2
74 files changed
+3288
-2289
No files matched your search
@@ -19,9 +19,10 @@ OPENWRT_ARCH = nil
|
||||
DISTRIB_ARCH = nil
|
||||
OPENWRT_BOARD = nil
|
||||
|
||||
CACHE_PATH = "/tmp/etc/" .. appname .. "_tmp"
|
||||
LOG_FILE = "/tmp/log/" .. appname .. ".log"
|
||||
TMP_PATH = "/tmp/etc/" .. appname
|
||||
LOCK_PREFIX = "/tmp/lock/passwall"
|
||||
LOG_FILE = "/tmp/log/passwall.log"
|
||||
TMP_PATH = "/tmp/etc/passwall"
|
||||
CACHE_PATH = TMP_PATH .. "_tmp"
|
||||
TMP_IFACE_PATH = TMP_PATH .. "/iface"
|
||||
|
||||
function log(...)
|
||||
@@ -37,7 +38,85 @@ function is_old_uci()
|
||||
return sys.call("grep -E 'require[ \t]*\"uci\"' /usr/lib/lua/luci/model/uci.lua >/dev/null 2>&1") == 0
|
||||
end
|
||||
|
||||
function uci_del(config, section, option)
|
||||
if option then
|
||||
return uci:delete(config, section, option)
|
||||
else
|
||||
return uci:delete(config, section)
|
||||
end
|
||||
end
|
||||
|
||||
function uci_get(config, section, option)
|
||||
if not section then
|
||||
return uci:get_all(config)
|
||||
elseif option then
|
||||
return uci:get(config, section, option) or nil
|
||||
else
|
||||
return uci:get_all(config, section)
|
||||
end
|
||||
end
|
||||
|
||||
function uci_set(config, section, option, value)
|
||||
if type(value) == "number" then
|
||||
value = value .. ""
|
||||
end
|
||||
if #value > 0 then
|
||||
if option then
|
||||
if type(value) == "table" then
|
||||
return uci:set_list(config, section, option, value)
|
||||
else
|
||||
return uci:set(config, section, option, value)
|
||||
end
|
||||
else
|
||||
return uci:set(config, section, value)
|
||||
end
|
||||
else
|
||||
return uci_del(config, section, option)
|
||||
end
|
||||
end
|
||||
|
||||
function uci_del_c(section, option)
|
||||
return uci_del(c_config, section, option)
|
||||
end
|
||||
|
||||
function uci_foreach_c(stype, func)
|
||||
uci:foreach(c_config, stype, func)
|
||||
end
|
||||
|
||||
function uci_get_c(section, option)
|
||||
return uci_get(c_config, section, option)
|
||||
end
|
||||
|
||||
function uci_set_c(section, option, value)
|
||||
return uci_set(c_config, section, option, value)
|
||||
end
|
||||
|
||||
function uci_save_c(commit, apply)
|
||||
return uci_save(uci, c_config, commit, apply)
|
||||
end
|
||||
|
||||
function uci_del_s(section, option)
|
||||
return uci_del(s_config, section, option)
|
||||
end
|
||||
|
||||
function uci_foreach_s(stype, func)
|
||||
uci:foreach(s_config, stype, func)
|
||||
end
|
||||
|
||||
function uci_get_s(section, option)
|
||||
return uci_get(s_config, section, option)
|
||||
end
|
||||
|
||||
function uci_set_s(section, option, value)
|
||||
return uci_set(s_config, section, option, value)
|
||||
end
|
||||
|
||||
function uci_save_s(commit, apply)
|
||||
return uci_save(uci, s_config, commit, apply)
|
||||
end
|
||||
|
||||
function uci_save(cursor, config, commit, apply)
|
||||
if not cursor then cursor = uci end
|
||||
if is_old_uci() then
|
||||
cursor:save(config)
|
||||
if commit then
|
||||
@@ -198,7 +277,7 @@ end
|
||||
|
||||
function curl_direct(url, file, args)
|
||||
--直连访问
|
||||
local chn_list = uci:get(appname, "@global[0]", "chn_list") or "direct"
|
||||
local chn_list = uci_get_c("@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)
|
||||
@@ -213,7 +292,7 @@ function curl_direct(url, file, args)
|
||||
end
|
||||
|
||||
function curl_auto(url, file, args)
|
||||
local localhost_proxy = uci:get(c_config, "@global[0]", "localhost_proxy") or "1"
|
||||
local localhost_proxy = uci_get_c("@global[0]", "localhost_proxy") or "1"
|
||||
if localhost_proxy == "1" then
|
||||
return curl_base(url, file, args) -- 当路由器本机开启代理时,采用passwall规则进行访问
|
||||
else
|
||||
@@ -481,7 +560,7 @@ function get_domain_from_url(url)
|
||||
end
|
||||
|
||||
function get_valid_nodes()
|
||||
local show_node_info = uci:get(c_config, "@global_other[0]", "show_node_info") or "0"
|
||||
local show_node_info = uci_get_c("@global_other[0]", "show_node_info") or "0"
|
||||
local nodes = {}
|
||||
local default_nodes = {}
|
||||
local other_nodes = {}
|
||||
@@ -666,7 +745,7 @@ function chmod_755(file)
|
||||
end
|
||||
|
||||
function get_customed_path(e)
|
||||
return uci:get(c_config, "@global_app[0]", e .. "_file")
|
||||
return uci_get_c("@global_app[0]", e .. "_file")
|
||||
end
|
||||
|
||||
function finded_com(e)
|
||||
@@ -725,7 +804,7 @@ end
|
||||
function get_app_path(app_name)
|
||||
if com[app_name] then
|
||||
local def_path = com[app_name].default_path
|
||||
local path = uci:get(c_config, "@global_app[0]", app_name:gsub("%-","_") .. "_file")
|
||||
local path = uci_get_c("@global_app[0]", app_name:gsub("%-","_") .. "_file")
|
||||
path = path and (#path>0 and path or def_path) or def_path
|
||||
return path
|
||||
end
|
||||
@@ -1003,7 +1082,7 @@ local default_file_tree = {
|
||||
}
|
||||
|
||||
local function get_api_json(url)
|
||||
local gh_proxy = uci:get(c_config, "@global_app[0]", "github_proxy") or "0"
|
||||
local gh_proxy = uci_get_c("@global_app[0]", "github_proxy") or "0"
|
||||
local return_code, content
|
||||
if gh_proxy == "1" then
|
||||
url = "https://gh-proxy.org/" .. url
|
||||
@@ -1127,7 +1206,7 @@ function to_download(app_name, url, size)
|
||||
local _curl_args = clone(curl_args)
|
||||
table.insert(_curl_args, "--speed-limit 51200 --speed-time 15 --max-time 300")
|
||||
|
||||
local gh_proxy = uci:get(c_config, "@global_app[0]", "github_proxy") or "0"
|
||||
local gh_proxy = uci_get_c("@global_app[0]", "github_proxy") or "0"
|
||||
local return_code, result
|
||||
if gh_proxy == "1" then
|
||||
url = "https://gh-proxy.org/" .. url
|
||||
@@ -1285,7 +1364,7 @@ end
|
||||
function to_check_self()
|
||||
local url = "https://raw.githubusercontent.com/Openwrt-Passwall/openwrt-passwall/main/luci-app-passwall/Makefile"
|
||||
local tmp_file = "/tmp/passwall_makefile"
|
||||
local gh_proxy = uci:get(c_config, "@global_app[0]", "github_proxy") or "0"
|
||||
local gh_proxy = uci_get_c("@global_app[0]", "github_proxy") or "0"
|
||||
local return_code, result
|
||||
if gh_proxy == "1" then
|
||||
url = "https://gh-proxy.org/" .. url
|
||||
@@ -1741,7 +1820,7 @@ end
|
||||
function get_socks_backup_nodes(id)
|
||||
id = trim(id)
|
||||
if id == "" then return "" end
|
||||
local socks = uci:get_all(c_config, id)
|
||||
local socks = uci_get_c(id)
|
||||
local nodes
|
||||
if socks.backup_node_add_mode and socks.backup_node_add_mode == "batch" then
|
||||
local node = {}
|
||||
@@ -1762,7 +1841,7 @@ function get_socks_backup_nodes(id)
|
||||
end
|
||||
|
||||
function get_core(field, candidates)
|
||||
local v = uci:get(c_config, "@global_subscribe[0]", field)
|
||||
local v = uci_get_c("@global_subscribe[0]", field)
|
||||
if v and v ~= "" then
|
||||
for _, c in ipairs(candidates) do
|
||||
if c[2] == v and c[1] then
|
||||
|
||||
Reference in new issue
Block a user