applications/luci-qos: fix cbi
[project/luci.git] / applications / luci-qos / luasrc / model / cbi / qos / qos.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local wa = require "luci.tools.webadmin"
16 local fs = require "nixio.fs"
17
18 m = Map("qos")
19
20 s = m:section(TypedSection, "interface", translate("Interfaces"))
21 s.addremove = true
22 s.anonymous = false
23
24 s:option(Flag, "enabled", translate("enable"))
25
26 c = s:option(ListValue, "classgroup")
27 c:value("Default", "standard")
28 c.default = "Default"
29
30 s:option(Flag, "overhead")
31
32 s:option(Flag, "halfduplex")
33
34 s:option(Value, "download", nil, "kb/s")
35
36 s:option(Value, "upload", nil, "kb/s")
37
38 s = m:section(TypedSection, "classify")
39 s.template = "cbi/tblsection"
40 s.anonymous = true
41 s.addremove = true
42
43 t = s:option(ListValue, "target")
44 t:value("Priority", translate("priority"))
45 t:value("Express", translate("express"))
46 t:value("Normal", translate("normal"))
47 t:value("Bulk", translate("low"))
48 t.default = "Normal"
49
50 srch = s:option(Value, "srchost")
51 srch.rmempty = true
52 srch:value("", translate("all"))
53 wa.cbi_add_knownips(srch)
54
55 dsth = s:option(Value, "dsthost")
56 dsth.rmempty = true
57 dsth:value("", translate("all"))
58 wa.cbi_add_knownips(dsth)
59
60 l7 = s:option(ListValue, "layer7", translate("Service"))
61 l7.rmempty = true
62 l7:value("", translate("all"))
63 local pats = fs.dir("/etc/l7-protocols")
64 if pats then
65         for f in pats do
66                 if f:sub(-4) == ".pat" then
67                         l7:value(f:sub(1, #f-4))
68                 end
69         end
70 end
71
72 p = s:option(Value, "proto", translate("Protocol"))
73 p:value("", translate("all"))
74 p:value("tcp", "TCP")
75 p:value("udp", "UDP")
76 p:value("icmp", "ICMP")
77 p.rmempty = true
78
79 ports = s:option(Value, "ports", translate("Ports"))
80 ports.rmempty = true
81 ports:value("", translate("allf", translate("all")))
82
83 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
84
85 return m