libs/web: readd add/remove icons to dynamic list widgets
[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", translate("Quality of Service"),
19         translate("With <abbr title=\"Quality of Service\">QoS</abbr> you " ..
20                 "can prioritize network traffic selected by addresses, " ..
21                 "ports or services."))
22
23 s = m:section(TypedSection, "interface", translate("Interfaces"))
24 s.addremove = true
25 s.anonymous = false
26 s.template  = "cbi/tblsection"
27
28 e = s:option(Flag, "enabled", translate("Enable"))
29 e.rmempty = false
30
31 c = s:option(ListValue, "classgroup", translate("Classification group"))
32 c:value("Default", translate("default"))
33 c.default = "Default"
34
35 s:option(Flag, "overhead", translate("Calculate overhead"))
36
37 s:option(Flag, "halfduplex", translate("Half-duplex"))
38
39 s:option(Value, "download", translate("Download speed (kbit/s)"))
40
41 s:option(Value, "upload", translate("Upload speed (kbit/s)"))
42
43 s = m:section(TypedSection, "classify", translate("Classification Rules"))
44 s.template = "cbi/tblsection"
45 s.anonymous = true
46 s.addremove = true
47
48 t = s:option(ListValue, "target", translate("Target"))
49 t:value("Priority", translate("priority"))
50 t:value("Express", translate("express"))
51 t:value("Normal", translate("normal"))
52 t:value("Bulk", translate("low"))
53 t.default = "Normal"
54
55 srch = s:option(Value, "srchost", translate("Source host"))
56 srch.rmempty = true
57 srch:value("", translate("all"))
58 wa.cbi_add_knownips(srch)
59
60 dsth = s:option(Value, "dsthost", translate("Destination host"))
61 dsth.rmempty = true
62 dsth:value("", translate("all"))
63 wa.cbi_add_knownips(dsth)
64
65 l7 = s:option(ListValue, "layer7", translate("Service"))
66 l7.rmempty = true
67 l7:value("", translate("all"))
68
69 local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
70 if pats then
71         local l
72         while true do
73                 l = pats:read("*l")
74                 if not l then break end
75
76                 l = l:match("([^/]+)%.pat$")
77                 if l then
78                         l7:value(l)
79                 end
80         end
81         pats:close()
82 end
83
84 p = s:option(Value, "proto", translate("Protocol"))
85 p:value("", translate("all"))
86 p:value("tcp", "TCP")
87 p:value("udp", "UDP")
88 p:value("icmp", "ICMP")
89 p.rmempty = true
90
91 ports = s:option(Value, "ports", translate("Ports"))
92 ports.rmempty = true
93 ports:value("", translate("all"))
94
95 bytes = s:option(Value, "connbytes", translate("Number of bytes"))
96
97 return m