upnp.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. m = Map("upnpd", luci.util.pcdata(translate("Universal Plug & Play")),
  5. translate("UPnP allows clients in the local network to automatically configure the router."))
  6. m:section(SimpleSection).template = "upnp_status"
  7. s = m:section(NamedSection, "config", "upnpd", translate("MiniUPnP settings"))
  8. s.addremove = false
  9. s:tab("general", translate("General Settings"))
  10. s:tab("advanced", translate("Advanced Settings"))
  11. e = s:taboption("general", Flag, "_init", translate("Start UPnP and NAT-PMP service"))
  12. e.rmempty = false
  13. function e.cfgvalue(self, section)
  14. return luci.sys.init.enabled("miniupnpd") and self.enabled or self.disabled
  15. end
  16. function e.write(self, section, value)
  17. if value == "1" then
  18. luci.sys.call("/etc/init.d/miniupnpd enable >/dev/null")
  19. luci.sys.call("/etc/init.d/miniupnpd start >/dev/null")
  20. else
  21. luci.sys.call("/etc/init.d/miniupnpd stop >/dev/null")
  22. luci.sys.call("/etc/init.d/miniupnpd disable >/dev/null")
  23. end
  24. end
  25. s:taboption("general", Flag, "enable_upnp", translate("Enable UPnP functionality")).default = "1"
  26. s:taboption("general", Flag, "enable_natpmp", translate("Enable NAT-PMP functionality")).default = "1"
  27. s:taboption("general", Flag, "secure_mode", translate("Enable secure mode"),
  28. translate("Allow adding forwards only to requesting ip addresses")).default = "1"
  29. s:taboption("general", Flag, "log_output", translate("Enable additional logging"),
  30. translate("Puts extra debugging information into the system log"))
  31. s:taboption("general", Value, "download", translate("Downlink"),
  32. translate("Value in KByte/s, informational only")).rmempty = true
  33. s:taboption("general", Value, "upload", translate("Uplink"),
  34. translate("Value in KByte/s, informational only")).rmempty = true
  35. port = s:taboption("general", Value, "port", translate("Port"))
  36. port.datatype = "port"
  37. port.default = 5000
  38. s:taboption("advanced", Flag, "system_uptime", translate("Report system instead of daemon uptime")).default = "1"
  39. s:taboption("advanced", Value, "uuid", translate("Device UUID"))
  40. s:taboption("advanced", Value, "serial_number", translate("Announced serial number"))
  41. s:taboption("advanced", Value, "model_number", translate("Announced model number"))
  42. ni = s:taboption("advanced", Value, "notify_interval", translate("Notify interval"))
  43. ni.datatype = "uinteger"
  44. ni.placeholder = 30
  45. ct = s:taboption("advanced", Value, "clean_ruleset_threshold", translate("Clean rules threshold"))
  46. ct.datatype = "uinteger"
  47. ct.placeholder = 20
  48. ci = s:taboption("advanced", Value, "clean_ruleset_interval", translate("Clean rules interval"))
  49. ci.datatype = "uinteger"
  50. ci.placeholder = 600
  51. pu = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL"))
  52. pu.placeholder = "http://192.168.1.1/"
  53. lf = s:taboption("advanced", Value, "upnp_lease_file", translate("UPnP lease file"))
  54. lf.placeholder = "/var/log/upnp.leases"
  55. s2 = m:section(TypedSection, "perm_rule", translate("MiniUPnP ACLs"),
  56. translate("ACLs specify which external ports may be redirected to which internal addresses and ports"))
  57. s2.template = "cbi/tblsection"
  58. s2.sortable = true
  59. s2.anonymous = true
  60. s2.addremove = true
  61. s2:option(Value, "comment", translate("Comment"))
  62. ep = s2:option(Value, "ext_ports", translate("External ports"))
  63. ep.datatype = "portrange"
  64. ep.placeholder = "0-65535"
  65. ia = s2:option(Value, "int_addr", translate("Internal addresses"))
  66. ia.datatype = "ip4addr"
  67. ia.placeholder = "0.0.0.0/0"
  68. ip = s2:option(Value, "int_ports", translate("Internal ports"))
  69. ip.datatype = "portrange"
  70. ip.placeholder = "0-65535"
  71. ac = s2:option(ListValue, "action", translate("Action"))
  72. ac:value("allow")
  73. ac:value("deny")
  74. return m