applications/luci-qos: Smaller enhancements, support for luci-mini
authorSteven Barth <steven@midlink.org>
Thu, 17 Jul 2008 16:02:29 +0000 (16:02 +0000)
committerSteven Barth <steven@midlink.org>
Thu, 17 Jul 2008 16:02:29 +0000 (16:02 +0000)
applications/luci-fw: Fixed support for luci-mini
libs/web: Removed luci.dispatcher.registered

applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua
applications/luci-qos/luasrc/controller/qos.lua
applications/luci-qos/luasrc/i18n/qos.de.lua
applications/luci-qos/luasrc/i18n/qos.en.lua
applications/luci-qos/luasrc/model/cbi/qos/qos.lua
applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua [new file with mode: 0644]
contrib/package/luci/Makefile
i18n/english/luasrc/i18n/default.en.lua
i18n/german/luasrc/i18n/default.de.lua
libs/web/luasrc/dispatcher.lua

index b8c1046..b896733 100644 (file)
@@ -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
index 5817060..0222806 100644 (file)
@@ -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
index 0bfa588..e24dbaa 100644 (file)
@@ -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
index bd55862..eefa955 100644 (file)
@@ -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
index ea535ce..0bb559e 100644 (file)
@@ -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 (file)
index 0000000..db6fa9c
--- /dev/null
@@ -0,0 +1,70 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+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
index 6482ad7..8ae97fc 100644 (file)
@@ -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
 
index 70a839c..f48bbda 100644 (file)
@@ -77,6 +77,7 @@ reset = "Reset"
 revert = "Revert"
 
 save = "Save"
+service = "Service"
 services = "Services"
 settings = "Settings"
 start = "Start"
index 249fadd..2c24df2 100644 (file)
@@ -78,6 +78,7 @@ reset = "Zurücksetzen"
 revert = "Verwerfen"
 
 save = "Speichern"
+service = "Dienst"
 services = "Dienste"
 settings = "Einstellungen"
 start = "Start"
index 756f3cc..e44519a 100644 (file)
@@ -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