update 2026-09-01 17:05:42

This commit is contained in:
action committed 2026-09-01 17:05:42 +08:00
1 parent 61fbf62840
commit 6041d81065
1967 files changed
+348 -1523392

No files matched your search

@@ -38,6 +38,11 @@ local function uhttpd_apps_proxy_available()
return uhttpd_supports_proxy_prefix() and uhttpd_has_apps_proxy_prefix()
end
local function linkeasefull_running()
local sys = require "luci.sys"
return sys.call("[ -x /etc/init.d/linkeasefull ] && /etc/init.d/linkeasefull running >/dev/null 2>&1") == 0
end
local function normalized_base_path(path)
path = path or "/apps/dockermanager/"
if path:sub(1, 1) ~= "/" then
@@ -94,29 +99,79 @@ local function dockermanager_config()
local uci = require "luci.model.uci".cursor()
local port = uci:get_first("dockermanager", "dockermanager", "port") or "8192"
local base_path = normalized_base_path(uci:get_first("dockermanager", "dockermanager", "base_path"))
return port, base_path
local external_port_enabled = uci:get_first("dockermanager", "dockermanager", "external_port_enabled") == "1"
local listen_mode = uci:get_first("dockermanager", "dockermanager", "listen_mode") or "auto"
local socket_path = uci:get_first("dockermanager", "dockermanager", "socket_path") or "/var/run/dockermanager.sock"
return port, base_path, external_port_enabled, listen_mode, socket_path
end
local function dockermanager_entry_url()
local port, base_path = dockermanager_config()
if uhttpd_apps_proxy_available() then
local port, base_path, external_port_enabled = dockermanager_config()
if linkeasefull_running() and uhttpd_apps_proxy_available() then
return base_path
end
if not external_port_enabled then
return nil
end
return "http://" .. url_authority(request_or_lan_host(), port) .. base_path
end
local function enable_external_port()
local uci = require "luci.model.uci".cursor()
local section = nil
uci:foreach("dockermanager", "dockermanager", function(s)
if not section then
section = s[".name"]
end
end)
if section then
uci:set("dockermanager", section, "external_port_enabled", "1")
uci:set("dockermanager", section, "listen_mode", "tcp")
uci:commit("dockermanager")
end
local sys = require "luci.sys"
sys.call("/etc/init.d/dockermanager restart >/dev/null 2>&1; sleep 1")
end
local function render_enable_port_confirm()
local dispatcher = require "luci.dispatcher"
local confirm_url = dispatcher.build_url("admin", "services", "dockermanager", "open") .. "?enable_port=1"
luci.http.prepare_content("text/html; charset=utf-8")
luci.http.write("<!doctype html><html><head><meta charset='utf-8'><title>Docker Manager</title></head><body>")
luci.http.write("<h2>Docker Manager</h2>")
luci.http.write("<p>当前系统无法通过 LinkEase 桌面代理打开 Docker Manager。</p>")
luci.http.write("<p>可以启用局域网端口 8192 后继续打开。</p>")
luci.http.write("<p><a class='cbi-button cbi-button-apply' href='" .. confirm_url .. "'>启用 8192 并打开</a></p>")
luci.http.write("</body></html>")
end
local function render_open_failed()
luci.http.prepare_content("text/html; charset=utf-8")
luci.http.write("<!doctype html><html><head><meta charset='utf-8'><title>Docker Manager</title></head><body>")
luci.http.write("<h2>Docker Manager</h2>")
luci.http.write("<p>Docker Manager 已安装,但当前没有可用访问入口。</p>")
luci.http.write("<p>请启用 LinkEaseFull 的 /apps 代理,或在 Docker Manager 设置中开放 8192 端口。</p>")
luci.http.write("</body></html>")
end
function dockermanager_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local port, base_path = dockermanager_config()
local port, base_path, external_port_enabled, listen_mode, socket_path = dockermanager_config()
local entry_url = dockermanager_entry_url()
local status = {
running = (sys.call("pidof docker-manager >/dev/null") == 0),
port = port,
base_path = base_path,
listen_mode = listen_mode,
socket_path = socket_path,
external_port_enabled = external_port_enabled,
entry_url = entry_url or "",
lan_ip = uci:get("network", "lan", "ipaddr") or "",
proxy_prefix_supported = uhttpd_supports_proxy_prefix(),
proxy_prefix_enabled = uhttpd_apps_proxy_available()
proxy_prefix_enabled = uhttpd_apps_proxy_available(),
linkeasefull_running = linkeasefull_running()
}
luci.http.prepare_content("application/json")
@@ -125,5 +180,19 @@ end
function dockermanager_open()
local http = require "luci.http"
http.redirect(linkease_auth_url("auth") .. "?return=" .. cookie_encode(dockermanager_entry_url()))
if http.formvalue("enable_port") == "1" then
enable_external_port()
end
local entry_url = dockermanager_entry_url()
if entry_url then
http.redirect(linkease_auth_url("auth") .. "?return=" .. cookie_encode(entry_url))
return
end
if http.formvalue("enable_port") == "1" then
render_open_failed()
return
end
render_enable_port_confirm()
end