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