Merge pull request #1777 from dibdot/travelmate
[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, "igdv1", translate("Enable IGDv1 mode"),
39         translate("Advertise as IGDv1 device instead of IGDv2")).default = "0"
40
41 s:taboption("general", Flag, "log_output", translate("Enable additional logging"),
42         translate("Puts extra debugging information into the system log"))
43
44 s:taboption("general", Value, "download", translate("Downlink"),
45         translate("Value in KByte/s, informational only")).rmempty = true
46
47 s:taboption("general", Value, "upload", translate("Uplink"),
48         translate("Value in KByte/s, informational only")).rmempty = true
49
50 port = s:taboption("general", Value, "port", translate("Port"))
51 port.datatype = "port"
52 port.default  = 5000
53
54
55 s:taboption("advanced", Flag, "system_uptime", translate("Report system instead of daemon uptime")).default = "1"
56
57 s:taboption("advanced", Value, "uuid", translate("Device UUID"))
58 s:taboption("advanced", Value, "serial_number", translate("Announced serial number"))
59 s:taboption("advanced", Value, "model_number", translate("Announced model number"))
60
61 ni = s:taboption("advanced", Value, "notify_interval", translate("Notify interval"))
62 ni.datatype    = "uinteger"
63 ni.placeholder = 30
64
65 ct = s:taboption("advanced", Value, "clean_ruleset_threshold", translate("Clean rules threshold"))
66 ct.datatype    = "uinteger"
67 ct.placeholder = 20
68
69 ci = s:taboption("advanced", Value, "clean_ruleset_interval", translate("Clean rules interval"))
70 ci.datatype    = "uinteger"
71 ci.placeholder = 600
72
73 pu = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL"))
74 pu.placeholder = "http://192.168.1.1/"
75
76 lf = s:taboption("advanced", Value, "upnp_lease_file", translate("UPnP lease file"))
77 lf.placeholder = "/var/log/upnp.leases"
78
79
80 s2 = m:section(TypedSection, "perm_rule", translate("MiniUPnP ACLs"),
81         translate("ACLs specify which external ports may be redirected to which internal addresses and ports"))
82
83 s2.template  = "cbi/tblsection"
84 s2.sortable  = true
85 s2.anonymous = true
86 s2.addremove = true
87
88 s2:option(Value, "comment", translate("Comment"))
89
90 ep = s2:option(Value, "ext_ports", translate("External ports"))
91 ep.datatype    = "portrange"
92 ep.placeholder = "0-65535"
93
94 ia = s2:option(Value, "int_addr", translate("Internal addresses"))
95 ia.datatype    = "ip4addr"
96 ia.placeholder = "0.0.0.0/0"
97
98 ip = s2:option(Value, "int_ports", translate("Internal ports"))
99 ip.datatype    = "portrange"
100 ip.placeholder = "0-65535"
101
102 ac = s2:option(ListValue, "action", translate("Action"))
103 ac:value("allow")
104 ac:value("deny")
105
106 return m