🍓 Sync 2026-08-30 00:07:42

This commit is contained in:
github-actions[bot] committed 2026-08-30 00:07:42 +08:00
1 parent cd0177380e
commit c2438b27c7
17 files changed
+1387 -65

No files matched your search

@@ -142,18 +142,6 @@ local function http_write_json_error(data)
http.write(jsonStringify({code = 0, data = data}))
end
function reset_config()
uci:revert(c_config)
luci.sys.call("echo '' > /tmp/log/passwall.log")
luci.sys.call('/etc/init.d/passwall stop')
if luci.sys.call('[ -s "/usr/share/passwall/0_default_config" ]') == 0 then
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
api.log(" * 恢复默认配置成功。")
else
api.log(" * 找不到默认配置文件,重置失败!")
end
end
function show_menu()
api.sh_uci_del(c_config, "@global[0]", "hide_from_luci", true)
luci.sys.call("rm -rf /tmp/luci-*")
@@ -952,6 +940,7 @@ function create_backup()
end
function restore_backup()
local type = http.formvalue("type")
local result = { status = "error", message = "unknown error" }
local ok, err = pcall(function()
local filename = http.formvalue("filename")
@@ -981,21 +970,29 @@ function restore_backup()
fp:close()
if chunk_index + 1 == total_chunks then
uci:revert(c_config)
uci:revert(api.s_config)
luci.sys.call("echo '' > /tmp/log/passwall.log")
api.log(" * PassWall 配置文件上传成功…")
local temp_dir = '/tmp/passwall_bak'
luci.sys.call("mkdir -p " .. temp_dir)
if luci.sys.call("tar -xzf " .. file_path .. " -C " .. temp_dir) == 0 then
for _, backup_file in ipairs(backup_files) do
local temp_file = temp_dir .. backup_file
if fs.access(temp_file) then
luci.sys.call("cp -f " .. temp_file .. " " .. backup_file)
local is_server_config = backup_file == "/etc/config/passwall_server"
if type == "all" or (type == "client" and not is_server_config) or (type == "server" and is_server_config) then
local temp_file = temp_dir .. backup_file
if fs.access(temp_file) then
luci.sys.call("cp -f " .. temp_file .. " " .. backup_file)
end
end
end
api.log(" * PassWall 配置还原成功…")
api.log(" * 重启 PassWall 服务中…\n")
luci.sys.call('/etc/init.d/passwall restart > /dev/null 2>&1 &')
luci.sys.call('/etc/init.d/passwall_server restart > /dev/null 2>&1 &')
if type == "all" or type == "client" then
api.log(" * PassWall 配置还原成功…")
api.log(" * 重启 PassWall 服务中…\n")
luci.sys.call('/etc/init.d/passwall restart > /dev/null 2>&1 &')
end
if type == "all" or type == "server" then
luci.sys.call('/etc/init.d/passwall_server restart > /dev/null 2>&1 &')
end
result = { status = "success", message = "Upload completed", path = file_path }
else
api.log(" * PassWall 配置文件解压失败,请重试!")
@@ -1013,6 +1010,26 @@ function restore_backup()
http_write_json(result)
end
function reset_config()
local type = http.formvalue("type")
if type == "client" then
uci:revert(c_config)
luci.sys.call("echo '' > /tmp/log/passwall.log")
luci.sys.call('/etc/init.d/passwall stop')
if luci.sys.call('[ -s "/usr/share/passwall/0_default_config" ]') == 0 then
luci.sys.call('cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
api.log(" * 恢复默认配置成功。")
else
api.log(" * 找不到默认配置文件,重置失败!")
end
elseif type == "server" then
uci:revert(api.s_config)
luci.sys.call("echo '' > /tmp/log/passwall_server.log")
luci.sys.call('/etc/init.d/passwall_server stop')
luci.sys.call("echo \"config global 'global'\" > /etc/config/passwall_server")
end
end
function geo_view()
local action = http.formvalue("action")
local value = http.formvalue("value")