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