diff --git a/doc/lucky1.png b/doc/lucky1.png deleted file mode 100644 index a5b41b6e..00000000 Binary files a/doc/lucky1.png and /dev/null differ diff --git a/doc/lucky2.png b/doc/lucky2.png deleted file mode 100644 index ba4c026f..00000000 Binary files a/doc/lucky2.png and /dev/null differ diff --git a/doc/lucky3.png b/doc/lucky3.png deleted file mode 100644 index 6fa7982f..00000000 Binary files a/doc/lucky3.png and /dev/null differ diff --git a/doc/taskplan1.png b/doc/taskplan1.png new file mode 100644 index 00000000..1f8db7be Binary files /dev/null and b/doc/taskplan1.png differ diff --git a/doc/taskplan2.png b/doc/taskplan2.png new file mode 100644 index 00000000..edb45d6d Binary files /dev/null and b/doc/taskplan2.png differ diff --git a/doc/taskplan3.png b/doc/taskplan3.png new file mode 100644 index 00000000..d4794702 Binary files /dev/null and b/doc/taskplan3.png differ diff --git a/doc/view.png b/doc/view.png new file mode 100644 index 00000000..169e112f Binary files /dev/null and b/doc/view.png differ diff --git a/doc/view2.png b/doc/view2.png new file mode 100644 index 00000000..9058c632 Binary files /dev/null and b/doc/view2.png differ diff --git a/luci-app-linkeasefull/luasrc/controller/linkeasefull.lua b/luci-app-linkeasefull/luasrc/controller/linkeasefull.lua index e493bdc8..1db6cc9d 100644 --- a/luci-app-linkeasefull/luasrc/controller/linkeasefull.lua +++ b/luci-app-linkeasefull/luasrc/controller/linkeasefull.lua @@ -1,13 +1,14 @@ module("luci.controller.linkeasefull", package.seeall) function index() + entry({"admin", "services", "linkeasefull_status"}, call("linkeasefull_status")) + entry({"admin", "services", "linkeasefull", "auth"}, call("linkeasefull_auth")).leaf = true + if not nixio.fs.access("/etc/config/linkeasefull") then return end entry({"admin", "services", "linkeasefull"}, cbi("linkeasefull"), _("LinkEase Full"), 21).dependent = true - entry({"admin", "services", "linkeasefull_status"}, call("linkeasefull_status")) - entry({"admin", "services", "linkeasefull", "auth"}, call("linkeasefull_auth")).leaf = true end local function uhttpd_has_apps_proxy_prefix() @@ -62,11 +63,39 @@ local function valid_apps_return(value) if not value or value == "" then return false end - if value == "/apps" then - return true + local function valid_path(path) + if path == "/apps" then + return true + end + local prefix = path:sub(1, 6) + return prefix == "/apps/" or prefix == "/apps?" or prefix == "/apps#" end - local prefix = value:sub(1, 6) - return prefix == "/apps/" or prefix == "/apps?" or prefix == "/apps#" + if value:sub(1, 1) == "/" then + return valid_path(value) + end + + local scheme, authority, path = value:match("^(https?://)([^/]+)(/.*)$") + if not scheme or not authority or not valid_path(path) then + return false + end + + local http = require "luci.http" + local uci = require "luci.model.uci".cursor() + local request_host = http.getenv("HTTP_HOST") or "" + local lan_host = uci:get("network", "lan", "ipaddr") or "" + local allowed_authorities = { + request_host, + request_host .. ":19290", + lan_host, + lan_host .. ":19290" + } + + for _, host in ipairs(allowed_authorities) do + if host ~= "" and authority == host then + return true + end + end + return false end local function valid_cookie_value(value) diff --git a/luci-app-linkeasefull/luasrc/model/cbi/linkeasefull.lua b/luci-app-linkeasefull/luasrc/model/cbi/linkeasefull.lua index 23950bc4..fbf598de 100644 --- a/luci-app-linkeasefull/luasrc/model/cbi/linkeasefull.lua +++ b/luci-app-linkeasefull/luasrc/model/cbi/linkeasefull.lua @@ -45,6 +45,22 @@ local function storage_mounts() return mounts end +local function ensure_linkease_config(uci) + if not fs.access("/etc/config/linkease") then + fs.writefile("/etc/config/linkease", "") + end + uci:load("linkease") + local section = uci:get_first("linkease", "linkease") + if not section then + section = uci:add("linkease", "linkease") + uci:set("linkease", section, "enabled", "0") + uci:set("linkease", section, "port", "8897") + uci:set("linkease", section, "allowPublic", "0") + uci:commit("linkease") + end + return section +end + m = Map("linkeasefull", translate("LinkEase Full"), translate("LinkEase Full uses fixed entries at port 19290 /apps/ and legacy port 8897.")) m:section(SimpleSection).template = "linkeasefull_status" @@ -55,10 +71,11 @@ s.anonymous = true s:option(Flag, "enabled", translate("Enable")).rmempty = false -local data = s:option(ListValue, "data_root_parent", translate("Storage path"), translate("Choose a mounted persistent disk. /tmp is not allowed.")) +local data = s:option(ListValue, "_local_home", translate("Storage path"), translate("Choose a mounted persistent disk. /tmp is not allowed.")) data.rmempty = false -local current = m.uci:get_first("linkeasefull", "linkeasefull", "data_root_parent") or "" +ensure_linkease_config(m.uci) +local current = m.uci:get_first("linkease", "linkease", "local_home") or "" local has_current = false for _, mount in ipairs(storage_mounts()) do data:value(mount.path, mount.label) @@ -83,4 +100,15 @@ function data.validate(self, value) return value end +function data.cfgvalue(self, section) + m.uci:load("linkease") + return m.uci:get_first("linkease", "linkease", "local_home") or "" +end + +function data.write(self, section, value) + local linkease_section = ensure_linkease_config(m.uci) + m.uci:set("linkease", linkease_section, "local_home", value) + m.uci:commit("linkease") +end + return m