#!/opt/lnxall_app/bin/lua local invoker = require "invoker" local cjson = require "cjson" local module = {} local FRPC_API_URL = "http://127.0.0.1:7400/api/status" local FRPC_API_AUTH = "dywl:dywlfrp123" function module.checkplat() return true end function module.category() return "网络设置" end function module.description() return "检查 FRPC 状态" end function module.detailed() return "获取 frpc 版本信息, 并检查 frpc 进程是否正在运行." end function module.suggestion() return "1. '域名已被使用': /etc/frpc.toml 修改为: subdomain = \"\", 然后执行: systemctl restart frpc" end local function parse_proxy_errors(api_status) if type(api_status) ~= "string" then return nil end local ok, status_doc = pcall(cjson.decode, api_status) if not ok or type(status_doc) ~= "table" then return nil end local errors = {} for _, proxies in pairs(status_doc) do if type(proxies) == "table" then for _, item in ipairs(proxies) do local name = type(item) == "table" and item.name or nil local status = type(item) == "table" and item.status or nil local err = type(item) == "table" and item.err or nil if status and status ~= "running" and type(err) == "string" and #err > 0 then errors[#errors + 1] = { name = name, status = status, err = err, } end end end end if #errors > 0 then return errors end return nil end function module.step() local _, version = invoker.invoke(invoker.OUTPUT + invoker.TRIMEND, "frpc", "--version") if type(version) ~= "string" then version = "" end local _, pidof_out = invoker.invoke(invoker.OUTPUT + invoker.TRIMEND, "pidof", "frpc") if type(pidof_out) ~= "string" then pidof_out = "" end local running = #pidof_out > 0 local proxy_errors = nil if running then local _, api_out = invoker.invoke(invoker.OUTPUT, "curl", "-fsS", "--max-time", "3", "-u", FRPC_API_AUTH, FRPC_API_URL) if type(api_out) == "string" then proxy_errors = parse_proxy_errors(api_out) end end local has_error = not running or proxy_errors ~= nil return { frpc_version = version, frpc_running = running, proxy_errors = proxy_errors, }, has_error end return module