🍕 Sync 2026-08-16 23:43:42

This commit is contained in:
github-actions[bot] committed 2026-08-16 23:43:42 +08:00
1 parent cea9097c34
commit 4bf1fb0640
40 files changed
+2889 -144

No files matched your search

+60 -29
View File
@@ -19,10 +19,11 @@ OPENWRT_ARCH = nil
DISTRIB_ARCH = nil
OPENWRT_BOARD = nil
LOCK_PREFIX = "/tmp/lock/passwall"
LOG_FILE = "/tmp/log/passwall.log"
TMP_PATH = "/tmp/etc/passwall"
LOCK_PREFIX = "/tmp/lock/" .. c_config
LOG_FILE = "/tmp/log/" .. c_config .. ".log"
TMP_PATH = "/tmp/etc/" .. c_config
CACHE_PATH = TMP_PATH .. "_tmp"
S_TMP_PATH = "/tmp/etc/" .. s_config
TMP_IFACE_PATH = TMP_PATH .. "/iface"
function log(...)
@@ -784,16 +785,16 @@ function clone(org)
end
function get_bin_version_cache(file, cmd)
sys.call("mkdir -p /tmp/etc/passwall_tmp")
sys.call("mkdir -p " .. CACHE_PATH)
if fs.access(file) then
chmod_755(file)
local md5 = sys.exec("echo -n $(md5sum " .. file .. " | awk '{print $1}')")
if fs.access("/tmp/etc/passwall_tmp/" .. md5) then
return sys.exec("echo -n $(cat /tmp/etc/passwall_tmp/%s)" % md5)
if fs.access(CACHE_PATH .. "/" .. md5) then
return sys.exec("echo -n $(cat %s)" % { CACHE_PATH .. "/" .. md5 })
else
local version = sys.exec(string.format("echo -n $(%s %s)", file, cmd))
if version and version ~= "" then
sys.call("echo '" .. version .. "' > " .. "/tmp/etc/passwall_tmp/" .. md5)
sys.call("echo '%s' > %s" % { version, CACHE_PATH .. "/" .. md5})
return version
end
end
@@ -1410,29 +1411,24 @@ function set_default_cbi()
if true then
--Map
local Map = cbi.Map
if not Map._passwall_default_cbi then
Map._passwall_default_cbi = true
local original_parse = Map.parse
function Map.parse(self, ...)
if is_js_luci() then
apply_redirect(self)
local old = self.on_after_save
self.on_after_save = function(map)
if old then old(map) end
map:set("@global[0]", "timestamp", os.time())
end
end
return original_parse(self, ...)
end
end
local original_init = Map.__init__
local default_init = Map.__init__
function Map.__init__(self, config, ...)
if not config then config = c_config end
original_init(self, config, ...)
default_init(self, config, ...)
self.api = require "luci.passwall.api"
end
if is_js_luci() == true then
local default_parse = Map.parse
function Map.parse(self, ...)
apply_redirect(self)
local old = self.on_after_save
self.on_after_save = function(self)
if old then old(self) end
self:set("@global[0]", "timestamp", os.time())
end
return default_parse(self, ...)
end
end
function Map.foreach(self, stype, func)
self.uci:foreach(self.config, stype, func)
end
@@ -1470,9 +1466,9 @@ function set_default_cbi()
if true then
--TextValue
local TextValue = cbi.TextValue
local original_init = TextValue.__init__
local default_init = TextValue.__init__
function TextValue.__init__(self, ...)
original_init(self, ...)
default_init(self, ...)
self.template = appname .. "/cbi/tvalue"
end
end
@@ -1599,7 +1595,9 @@ function luci_types(id, m, s, type_name, option_prefix)
local deps = s.fields[key].deps
if #deps > 0 then
for index, value in ipairs(deps) do
deps[index]["type"] = type_name
if not deps[index]['!reverse'] then
deps[index]["type"] = type_name
end
end
else
s.fields[key]:depends({ type = type_name })
@@ -2045,3 +2043,36 @@ function table_remove_duplicates(t)
end
return new_t
end
function gen_wireguard_key()
if sys.call("command -v wg >/dev/null") == 0 then
local private_key = sys.exec('echo -n $(wg genkey)')
local public_key = sys.exec('echo -n $(echo "%s" | wg pubkey)' % private_key)
return {
private_key = private_key,
public_key = public_key
}
end
local xray = finded_com("xray")
if xray then
local result = sys.exec(xray .. " wg | awk -F ': ' '{print $2}'")
local s = split(result, "\n")
local private_key = s[1]
local public_key = s[2]
return {
private_key = private_key,
public_key = public_key
}
end
local sb = finded_com("sing-box")
if sb then
local result = sys.exec(sb .. " generate wg-keypair | awk '{print $2}'")
local s = split(result, "\n")
local private_key = s[1]
local public_key = s[2]
return {
private_key = private_key,
public_key = public_key
}
end
end