830fc26c5bd31a103a6df8674472f0c18fc25f6c
[project/luci.git] / applications / luci-upnp / luasrc / model / cbi / upnp / upnp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
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 m = Map("upnpd", translate("Universal Plug & Play"),
17         translate("UPnP allows clients in the local network to automatically configure the router."))
18
19 m:section(SimpleSection).template  = "upnp_status"
20
21 s = m:section(NamedSection, "config", "upnpd", translate("MiniUPnP settings"))
22 s.addremove = false
23 s:tab("general",  translate("General Settings"))
24 s:tab("advanced", translate("Advanced Settings"))
25
26 e = s:taboption("general", Flag, "_init", translate("Start UPnP and NAT-PMP service"))
27 e.rmempty  = false
28
29 function e.cfgvalue(self, section)
30         return luci.sys.init.enabled("miniupnpd") and self.enabled or self.disabled
31 end
32
33 function e.write(self, section, value)
34         if value == "1" then
35                 luci.sys.call("/etc/init.d/miniupnpd enable >/dev/null")
36                 luci.sys.call("/etc/init.d/miniupnpd start >/dev/null")
37         else
38                 luci.sys.call("/etc/init.d/miniupnpd stop >/dev/null")
39                 luci.sys.call("/etc/init.d/miniupnpd disable >/dev/null")
40         end
41 end
42
43 s:taboption("general", Flag, "enable_upnp", translate("Enable UPnP functionality")).default = "1"
44 s:taboption("general", Flag, "enable_natpmp", translate("Enable NAT-PMP functionality")).default = "1"
45
46 s:taboption("general", Flag, "secure_mode", translate("Enable secure mode")).default = "1"
47 s:taboption("general", Flag, "log_output", translate("Log output")).default = "1"
48
49 s:taboption("general", Value, "download", translate("Downlink"), 
50         translate("Value in KByte/s, informational only")).rmempty = true
51
52 s:taboption("general", Value, "upload", translate("Uplink"),
53         translate("Value in KByte/s, informational only")).rmempty = true
54
55 port = s:taboption("general", Value, "port", translate("Port"))
56 port.datatype = "port"
57 port.default  = 5000
58
59
60 s:taboption("advanced", Flag, "system_uptime", translate("Report system instead of daemon uptime")).default = "1"
61
62 s:taboption("advanced", Value, "uuid", translate("Device UUID"))
63 s:taboption("advanced", Value, "serial_number", translate("Announced serial number"))
64 s:taboption("advanced", Value, "model_number", translate("Announced model number"))
65
66 ni = s:taboption("advanced", Value, "notify_interval", translate("Notify interval"))
67 ni.datatype    = "uinteger"
68 ni.placeholder = 30
69
70 ct = s:taboption("advanced", Value, "clean_ruleset_threshold", translate("Clean rules threshold"))
71 ct.datatype    = "uinteger"
72 ct.placeholder = 20
73
74 ci = s:taboption("advanced", Value, "clean_ruleset_interval", translate("Clean rules interval"))
75 ci.datatype    = "uinteger"
76 ci.placeholder = 600
77
78 pu = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL"))
79 pu.placeholder = "http://192.168.1.1/"
80
81 lf = s:taboption("advanced", Value, "upnp_lease_file", translate("UPnP lease file"))
82 lf.placeholder = "/var/log/upnp.leases"
83
84
85 s2 = m:section(TypedSection, "perm_rule", translate("MiniUPnP ACLs"),
86         translate("ACLs specify which external ports may be redirected to which internal addresses and ports"))
87
88 s2.template  = "cbi/tblsection"
89 s2.sortable  = true
90 s2.anonymous = true
91 s2.addremove = true
92
93 s2:option(Value, "comment", translate("Comment"))
94
95 ep = s2:option(Value, "ext_ports", translate("External ports"))
96 ep.datatype    = "portrange"
97 ep.placeholder = "0-65535"
98
99 ia = s2:option(Value, "int_addr", translate("Internal addresses"))
100 ia.datatype    = "ip4addr"
101 ia.placeholder = "0.0.0.0/0"
102
103 ip = s2:option(Value, "int_ports", translate("Internal ports"))
104 ip.datatype    = "portrange"
105 ip.placeholder = "0-65535"
106
107 ac = s2:option(ListValue, "action", translate("Action"))
108 ac:value("allow")
109 ac:value("deny")
110
111 return m