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