From 52d49762ed28033d82e5ab1e0ccf65ad74a4b593 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Thu, 17 Jul 2008 16:02:29 +0000 Subject: [PATCH] applications/luci-qos: Smaller enhancements, support for luci-mini applications/luci-fw: Fixed support for luci-mini libs/web: Removed luci.dispatcher.registered --- .../luasrc/controller/luci_fw/luci_fw.lua | 19 ++--- .../luci-qos/luasrc/controller/qos.lua | 9 ++- applications/luci-qos/luasrc/i18n/qos.de.lua | 10 ++- applications/luci-qos/luasrc/i18n/qos.en.lua | 10 ++- .../luci-qos/luasrc/model/cbi/qos/qos.lua | 21 ++++-- .../luci-qos/luasrc/model/cbi/qos/qosmini.lua | 70 +++++++++++++++++++ contrib/package/luci/Makefile | 4 +- i18n/english/luasrc/i18n/default.en.lua | 1 + i18n/german/luasrc/i18n/default.de.lua | 1 + libs/web/luasrc/dispatcher.lua | 25 +++---- 10 files changed, 133 insertions(+), 37 deletions(-) create mode 100644 applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua diff --git a/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua b/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua index b8c104601..b8967330c 100644 --- a/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua +++ b/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua @@ -3,14 +3,17 @@ module("luci.controller.luci_fw.luci_fw", package.seeall) function index() require("luci.i18n").loadc("luci-fw") local i18n = luci.i18n.translate + + local nodes = {} - if registered("admin") then - entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), i18n("fw_portfw", "Portweiterleitung"), 70).i18n = "luci-fw" - entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), i18n("fw_routing", "Routing"), 73).i18n = "luci-fw" - entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), i18n("fw_fw", "Firewall"), 76).i18n = "luci-fw" - end + table.insert(nodes, entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), i18n("fw_portfw", "Portweiterleitung"), 70)) + table.insert(nodes, entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), i18n("fw_routing", "Routing"), 73)) + table.insert(nodes, entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), i18n("fw_fw", "Firewall"), 76)) + + table.insert(nodes, entry({"mini", "network", "portfw"}, cbi("luci_fw/miniportfw"), i18n("fw_portfw", "Portweiterleitung"), 70)) - if registered("mini") then - entry({"mini", "network", "portfw"}, cbi("luci_fw/miniportfw"), i18n("fw_portfw", "Portweiterleitung"), 70).i18n = "luci-fw" - end + for i,n in ipairs(nodes) do + n.i18n = "luci-fw" + n.dependent = true + end end \ No newline at end of file diff --git a/applications/luci-qos/luasrc/controller/qos.lua b/applications/luci-qos/luasrc/controller/qos.lua index 581706091..0222806bb 100644 --- a/applications/luci-qos/luasrc/controller/qos.lua +++ b/applications/luci-qos/luasrc/controller/qos.lua @@ -18,5 +18,12 @@ function index() return end - entry({"admin", "network", "qos"}, cbi("qos/qos"), "QoS").i18n = "qos" + local page = entry({"admin", "network", "qos"}, cbi("qos/qos"), "QoS") + page.i18n = "qos" + page.dependent = true + + + local page = entry({"mini", "network", "qos"}, cbi("qos/qosmini"), "QoS") + page.i18n = "qos" + page.dependent = true end \ No newline at end of file diff --git a/applications/luci-qos/luasrc/i18n/qos.de.lua b/applications/luci-qos/luasrc/i18n/qos.de.lua index 0bfa588a3..e24dbaa2c 100644 --- a/applications/luci-qos/luasrc/i18n/qos.de.lua +++ b/applications/luci-qos/luasrc/i18n/qos.de.lua @@ -5,10 +5,14 @@ qos_interface_classgroup = "Klassifizierung" qos_interface_overhead = "Overheadberechnung" qos_interface_download = "Downlink" qos_interface_upload = "Uplink" -qos_classify = "Klassifizierung" -qos_classify_target = "Klasse" +qos_classify = "Priorisierung" +qos_classify_target = "Priorität" qos_classify_srchost = "Quelladresse" qos_classify_srchost_dest = "Quellnetz / Quellhost" qos_classify_dsthost = "Zieladresse" qos_classify_dsthost_dest = "Zielnetz / Zielhost" -qos_classify_portrange = "Portbereich" \ No newline at end of file +qos_classify_portrange = "Portbereich" +qos_bulk = "niedrig" +qos_normal = "normal" +qos_express = "express" +qos_priority = "priorisiert" \ No newline at end of file diff --git a/applications/luci-qos/luasrc/i18n/qos.en.lua b/applications/luci-qos/luasrc/i18n/qos.en.lua index bd55862c0..eefa95595 100644 --- a/applications/luci-qos/luasrc/i18n/qos.en.lua +++ b/applications/luci-qos/luasrc/i18n/qos.en.lua @@ -4,10 +4,14 @@ qos_interface_classgroup = "Classification" qos_interface_overhead = "Calculate Overhead" qos_interface_download = "Downlink" qos_interface_upload = "Uplink" -qos_classify = "Classification" -qos_classify_target = "Class" +qos_classify = "Prioritization" +qos_classify_target = "Priority" qos_classify_srchost = "Source address" qos_classify_srchost_dest = "source network / source host" qos_classify_dsthost = "Target address" qos_classify_dsthost_dest = "target network / target host" -qos_classify_portrange = "portrange" \ No newline at end of file +qos_classify_portrange = "portrange" +qos_bulk = "low" +qos_normal = "normal" +qos_express = "express" +qos_priority = "priority" \ No newline at end of file diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua index ea535cea2..0bb559ede 100644 --- a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua +++ b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua @@ -34,15 +34,26 @@ s.anonymous = true s.addremove = true t = s:option(ListValue, "target") -t:value("Priority") -t:value("Express") -t:value("Normal") -t:value("Bulk") +t:value("Priority", translate("qos_priority")) +t:value("Express", translate("qos_express")) +t:value("Normal", translate("qos_normal")) +t:value("Bulk", translate("qos_bulk")) t.default = "Normal" s:option(Value, "srchost").optional = true s:option(Value, "dsthost").optional = true -s:option(Value, "layer7", "Layer 7").optional = true + +l7 = s:option(ListValue, "layer7", translate("service")) +l7.optional = true +l7:value("") +local pats = luci.fs.dir("/etc/l7-protocols") +if pats then + for i,f in ipairs(pats) do + if f:sub(-4) == ".pat" then + l7:value(f:sub(1, #f-4)) + end + end +end p2p = s:option(ListValue, "ipp2p", "P2P") p2p:value("") diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua new file mode 100644 index 000000000..db6fa9c6b --- /dev/null +++ b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua @@ -0,0 +1,70 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +m = Map("qos") + +s = m:section(NamedSection, "wan", "interface", translate("m_n_inet")) + +s:option(Flag, "enabled", translate("qos")) +s:option(Value, "download", translate("qos_interface_download"), "kb/s") +s:option(Value, "upload", translate("qos_interface_upload"), "kb/s") + +s = m:section(TypedSection, "classify") + +s.anonymous = true +s.addremove = true + +t = s:option(ListValue, "target") +t:value("Priority", translate("qos_priority")) +t:value("Express", translate("qos_express")) +t:value("Normal", translate("qos_normal")) +t:value("Bulk", translate("qos_bulk")) +t.default = "Normal" + +s:option(Value, "srchost").optional = true +s:option(Value, "dsthost").optional = true + +l7 = s:option(ListValue, "layer7", translate("service")) +l7.optional = true +l7:value("") +local pats = luci.fs.dir("/etc/l7-protocols") +if pats then + for i,f in ipairs(pats) do + if f:sub(-4) == ".pat" then + l7:value(f:sub(1, #f-4)) + end + end +end + +p2p = s:option(ListValue, "ipp2p", "P2P") +p2p:value("") +p2p:value("all", translate("all")) +p2p:value("bit", "BitTorrent") +p2p:value("dc", "DirectConnect") +p2p:value("edk", "eDonkey") +p2p:value("gnu", "Gnutella") +p2p:value("kazaa", "Kazaa") +p2p.optional = true + +p = s:option(ListValue, "proto", translate("protocol")) +p:value("") +p:value("tcp", "TCP") +p:value("udp", "UDP") +p:value("icmp", "ICMP") +p.optional = true + +s:option(Value, "ports", translate("port")).optional = true +s:option(Value, "portrange").optional = true + +return m \ No newline at end of file diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index 6482ad7ac..8ae97fcf1 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -347,7 +347,7 @@ endef define Package/luci-app-firewall $(call Package/luci/webtemplate) - DEPENDS+=+luci-mod-admin-full + DEPENDS+=+luci-mod-admin-core TITLE:=Firewall and Portforwarding application endef @@ -373,7 +373,7 @@ endef define Package/luci-app-qos $(call Package/luci/webtemplate) - DEPENDS+=+luci-mod-admin-full +qos-scripts + DEPENDS+=+luci-mod-admin-core +qos-scripts TITLE:=Quality of Service configuration module endef diff --git a/i18n/english/luasrc/i18n/default.en.lua b/i18n/english/luasrc/i18n/default.en.lua index 70a839c39..f48bbda46 100644 --- a/i18n/english/luasrc/i18n/default.en.lua +++ b/i18n/english/luasrc/i18n/default.en.lua @@ -77,6 +77,7 @@ reset = "Reset" revert = "Revert" save = "Save" +service = "Service" services = "Services" settings = "Settings" start = "Start" diff --git a/i18n/german/luasrc/i18n/default.de.lua b/i18n/german/luasrc/i18n/default.de.lua index 249fadde8..2c24df24a 100644 --- a/i18n/german/luasrc/i18n/default.de.lua +++ b/i18n/german/luasrc/i18n/default.de.lua @@ -78,6 +78,7 @@ reset = "Zurücksetzen" revert = "Verwerfen" save = "Speichern" +service = "Dienst" services = "Dienste" settings = "Einstellungen" start = "Start" diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 756f3cc7d..e44519a3f 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -141,6 +141,14 @@ function dispatch(request) viewns.resource = luci.config.main.resourcebase viewns.REQUEST_URI = luci.http.getenv("SCRIPT_NAME") .. (luci.http.getenv("PATH_INFO") or "") + if track.dependent then + local stat, err = pcall(assert, not track.auto) + if not stat then + error500(err) + return + end + end + if track.sysauth then require("luci.sauth") local def = (type(track.sysauth) == "string") and track.sysauth @@ -324,20 +332,6 @@ function entry(path, target, title, order) return c end --- Checks whether a node exists -function registered(...) - local c = context.tree - - for k,v in ipairs(arg) do - if not c.nodes[v] then - return false - end - - c = c.nodes[v] - end - return true -end - -- Fetch a dispatching node function node(...) local c = context.tree @@ -345,7 +339,7 @@ function node(...) for k,v in ipairs(arg) do if not c.nodes[v] then - c.nodes[v] = {nodes={}} + c.nodes[v] = {nodes={}, auto=true} end c = c.nodes[v] @@ -353,6 +347,7 @@ function node(...) c.module = getfenv(2)._NAME c.path = arg + c.auto = nil return c end -- 2.25.1