🎈 Sync 2026-10-04 14:38:18

This commit is contained in:
github-actions[bot] committed 2026-10-04 14:38:18 +08:00
1 parent 0e6611f767
commit aba12667c5
88 files changed
+4600 -1458

No files matched your search

@@ -27,9 +27,57 @@ function index()
entry({"admin", "vpn", "openvpn-server","status"},call("act_status")).leaf=true
end
-- 内核是否提供 DCO (需要 ovpn.ko)
function dco_kernel_supported()
local fs = require "nixio.fs"
local krel = luci.sys.exec("uname -r"):gsub("%s+$", "")
return (fs.access("/sys/module/ovpn") or fs.access("/lib/modules/" .. krel .. "/ovpn.ko")) and true or false
end
-- openvpn 是否编译了 DCO 支持
function dco_build_supported()
local v = luci.sys.exec("openvpn --version 2>/dev/null | head -n1")
return v:find("%[DCO%]") ~= nil
end
-- DCO 是否真的在工作: 优先看内核模块引用计数, 退路是查运行日志
function dco_in_use()
local fs = require "nixio.fs"
local rc = fs.readfile("/sys/module/ovpn/refcnt")
if rc then
-- 注意: gsub 返回两个值, 必须加括号只取第一个
local n = tonumber((rc:gsub("%s+$", "")))
if n and n > 0 then
return true
end
end
local uci = require("luci.model.uci").cursor()
local logf = uci:get("openvpn", "myvpn", "log") or "/tmp/openvpn.log"
local hit = luci.sys.exec("grep -m1 -E 'DCO device .* opened|ovpn-dco device' '" .. logf .. "' 2>/dev/null")
return hit ~= nil and hit ~= ""
end
function act_status()
local e={}
e.running=luci.sys.call("pgrep openvpn >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
local e = {}
e.running = luci.sys.call("pgrep openvpn >/dev/null") == 0
e.dco_kernel = dco_kernel_supported()
e.dco_build = dco_build_supported()
e.dco_supported = (e.dco_kernel and e.dco_build) and true or false
e.dco_active = dco_in_use()
local uci = require("luci.model.uci").cursor()
local ac = uci:get("openvpn", "myvpn", "allow_compression")
local lzo = uci:get("openvpn", "myvpn", "comp_lzo")
local dis = uci:get("openvpn", "myvpn", "disable_dco")
e.dco_disabled = (dis == "1")
e.allow_compression = ac or ""
e.comp_lzo = lzo or ""
-- 非法的压缩组合: allow-compression=no 与 comp_lzo 同时存在, openvpn 会拒绝启动
e.conflict = (ac == "no" and lzo ~= nil and lzo ~= "")
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end