206ef705312093888a73d65166929c63378f9415
[project/luci.git] / applications / luci-app-splash / luasrc / model / cbi / splash / splash.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8         http://www.apache.org/licenses/LICENSE-2.0
9 ]]--
10
11 require("luci.model.uci")
12
13 m = Map("luci_splash", translate("Client-Splash"), translate("Client-Splash is a hotspot authentification system for wireless mesh networks."))
14
15 s = m:section(NamedSection, "general", "core", translate("General"))
16 s.addremove = false
17
18 s:option(Value, "leasetime", translate("Clearance time"), translate("Clients that have accepted the splash are allowed to use the network for that many hours."))
19 local redir = s:option(Value, "redirect_url", translate("Redirect target"), translate("Clients are redirected to this page after they have accepted the splash. If this is left empty they are redirected to the page they had requested."))
20 redir.rmempty = true
21
22 s:option(Value, "limit_up", translate("Upload limit"), translate("Clients upload speed is limited to this value (kbyte/s)"))
23 s:option(Value, "limit_down", translate("Download limit"), translate("Clients download speed is limited to this value (kbyte/s)"))
24
25 s:option(DummyValue, "_tmp", "",
26         translate("Bandwidth limit for clients is only activated when both up- and download limit are set. " ..
27         "Use a value of 0 here to completely disable this limitation. Whitelisted clients are not limited."))
28
29 s = m:section(TypedSection, "iface", translate("Interfaces"), translate("Interfaces that are used for Splash."))
30
31 s.template = "cbi/tblsection"
32 s.addremove = true
33 s.anonymous = true
34
35 local uci = luci.model.uci.cursor()
36
37 zone = s:option(ListValue, "zone", translate("Firewall zone"),
38         translate("Splash rules are integrated in this firewall zone"))
39
40 uci:foreach("firewall", "zone",
41         function (section)
42                 zone:value(section.name)
43         end)
44         
45 iface = s:option(ListValue, "network", translate("Network"),
46         translate("Intercept client traffic on this Interface"))
47
48 uci:foreach("network", "interface",
49         function (section)
50                 if section[".name"] ~= "loopback" then
51                         iface:value(section[".name"])
52                 end
53         end)
54         
55 uci:foreach("network", "alias",
56         function (section)
57                 iface:value(section[".name"])
58         end)
59
60
61 s = m:section(TypedSection, "whitelist", translate("Whitelist"),
62         translate("MAC addresses of whitelisted clients. These do not need to accept the splash and are not bandwidth limited."))
63
64 s.template = "cbi/tblsection"
65 s.addremove = true
66 s.anonymous = true
67 s:option(Value, "mac", translate ("MAC Address"))
68
69
70 s = m:section(TypedSection, "blacklist", translate("Blacklist"),
71         translate("MAC addresses in this list are blocked."))
72
73 s.template = "cbi/tblsection"
74 s.addremove = true
75 s.anonymous = true
76 s:option(Value, "mac", translate ("MAC Address"))
77
78 s = m:section(TypedSection, "subnet", translate("Allowed hosts/subnets"),
79         translate("Destination hosts and networks that are excluded from splashing, i.e. they are always allowed."))
80
81 s.template = "cbi/tblsection"
82 s.addremove = true
83 s.anonymous = true
84 s:option(Value, "ipaddr", translate("IP Address"))
85 s:option(Value, "netmask", translate("Netmask"), translate("optional when using host addresses")).rmempty = true
86         
87 return m