0c5766f342089869e2a3c188f4227beb7fa70699
[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
25 dl = s:option(Value, "download", translate("Downlink"), "kbit/s")
26 dl.datatype = "and(uinteger,min(1))"
27
28 ul = s:option(Value, "upload", translate("Uplink"), "kbit/s")
29 ul.datatype = "and(uinteger,min(1))"
30
31 s = m:section(TypedSection, "classify")
32 s.template = "cbi/tblsection"
33
34 s.anonymous = true
35 s.addremove = true
36 s.sortable  = true
37
38 t = s:option(ListValue, "target")
39 t:value("Priority", translate("priority"))
40 t:value("Express", translate("express"))
41 t:value("Normal", translate("normal"))
42 t:value("Bulk", translate("low"))
43 t.default = "Normal"
44
45 srch = s:option(Value, "srchost")
46 srch.rmempty = true
47 srch:value("", translate("all"))
48 wa.cbi_add_knownips(srch)
49
50 dsth = s:option(Value, "dsthost")
51 dsth.rmempty = true
52 dsth:value("", translate("all"))
53 wa.cbi_add_knownips(dsth)
54
55 l7 = s:option(ListValue, "layer7", translate("Service"))
56 l7.rmempty = true
57 l7:value("", translate("all"))
58
59 local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
60 if pats then
61         local l
62         while true do
63                 l = pats:read("*l")
64                 if not l then break end
65
66                 l = l:match("([^/]+)%.pat$")
67                 if l then
68                         l7:value(l)
69                 end
70         end
71         pats:close()
72 end
73
74 p = s:option(ListValue, "proto", translate("Protocol"))
75 p:value("", translate("all"))
76 p:value("tcp", "TCP")
77 p:value("udp", "UDP")
78 p:value("icmp", "ICMP")
79 p.rmempty = true
80
81 ports = s:option(Value, "ports", translate("Ports"))
82 ports.rmempty = true
83 ports:value("", translate("allf", translate("all")))
84
85 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
86
87 return m