hints.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. -- Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local CTRL = require "luci.controller.ddns" -- this application's controller
  4. local DISP = require "luci.dispatcher"
  5. local SYS = require "luci.sys"
  6. local DDNS = require "luci.tools.ddns" -- ddns multiused functions
  7. -- check supported options -- ##################################################
  8. -- saved to local vars here because doing multiple os calls slow down the system
  9. has_ssl = DDNS.check_ssl() -- HTTPS support and --bind-network / --interface
  10. has_proxy = DDNS.check_proxy() -- Proxy support
  11. has_dnstcp = DDNS.check_bind_host() -- DNS TCP support
  12. -- correct ddns-scripts version
  13. need_update = DDNS.ipkg_ver_compare(DDNS.ipkg_ver_installed("ddns-scripts"), "<<", CTRL.DDNS_MIN)
  14. -- html constants
  15. font_red = [[<font color="red">]]
  16. font_off = [[</font>]]
  17. bold_on = [[<strong>]]
  18. bold_off = [[</strong>]]
  19. -- cbi-map definition -- #######################################################
  20. m = Map("ddns")
  21. -- first need to close <a> from cbi map template our <a> closed by template
  22. m.title = [[</a><a href="]] .. DISP.build_url("admin", "services", "ddns") .. [[">]] ..
  23. translate("Dynamic DNS")
  24. m.description = translate("Dynamic DNS allows that your router can be reached with " ..
  25. "a fixed hostname while having a dynamically changing " ..
  26. "IP address.")
  27. m.redirect = DISP.build_url("admin", "services", "ddns")
  28. -- SimpleSection definition -- #################################################
  29. -- show Hints to optimize installation and script usage
  30. s = m:section( SimpleSection,
  31. translate("Hints"),
  32. translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
  33. -- ddns_scripts needs to be updated for full functionality
  34. if need_update then
  35. local dv = s:option(DummyValue, "_update_needed")
  36. dv.titleref = DISP.build_url("admin", "system", "packages")
  37. dv.rawhtml = true
  38. dv.title = font_red .. bold_on ..
  39. translate("Software update required") .. bold_off .. font_off
  40. dv.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") ..
  41. "<br />" ..
  42. translate("Please update to the current version!")
  43. end
  44. -- DDNS Service disabled
  45. if not SYS.init.enabled("ddns") then
  46. local dv = s:option(DummyValue, "_not_enabled")
  47. dv.titleref = DISP.build_url("admin", "system", "startup")
  48. dv.rawhtml = true
  49. dv.title = bold_on ..
  50. translate("DDNS Autostart disabled") .. bold_off
  51. dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" ..
  52. "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" )
  53. end
  54. -- No IPv6 support
  55. if not DDNS.check_ipv6() then
  56. local dv = s:option(DummyValue, "_no_ipv6")
  57. dv.titleref = 'http://www.openwrt.org" target="_blank'
  58. dv.rawhtml = true
  59. dv.title = bold_on ..
  60. translate("IPv6 not supported") .. bold_off
  61. dv.value = translate("IPv6 is currently not (fully) supported by this system" .. "<br />" ..
  62. "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "<br />" ..
  63. "or update your system to the latest OpenWrt Release")
  64. end
  65. -- No HTTPS support
  66. if not has_ssl then
  67. local dv = s:option(DummyValue, "_no_https")
  68. dv.titleref = DISP.build_url("admin", "system", "packages")
  69. dv.rawhtml = true
  70. dv.title = bold_on ..
  71. translate("HTTPS not supported") .. bold_off
  72. dv.value = translate("Neither GNU Wget with SSL nor cURL installed to support updates via HTTPS protocol.") ..
  73. "<br />- " ..
  74. translate("You should install GNU Wget with SSL (prefered) or cURL package.") ..
  75. "<br />- " ..
  76. translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
  77. end
  78. -- No bind_network
  79. if not has_ssl then
  80. local dv = s:option(DummyValue, "_no_bind_network")
  81. dv.titleref = DISP.build_url("admin", "system", "packages")
  82. dv.rawhtml = true
  83. dv.title = bold_on ..
  84. translate("Binding to a specific network not supported") .. bold_off
  85. dv.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") ..
  86. "<br />- " ..
  87. translate("You should install GNU Wget with SSL or cURL package.") ..
  88. "<br />- " ..
  89. translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") ..
  90. "<br />- " ..
  91. translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
  92. end
  93. -- cURL without proxy support
  94. if has_ssl and not has_proxy then
  95. local dv = s:option(DummyValue, "_no_proxy")
  96. dv.titleref = DISP.build_url("admin", "system", "packages")
  97. dv.rawhtml = true
  98. dv.title = bold_on ..
  99. translate("cURL without Proxy Support") .. bold_off
  100. dv.value = translate("cURL is installed, but libcurl was compiled without proxy support.") ..
  101. "<br />- " ..
  102. translate("You should install GNU Wget with SSL or replace libcurl.") ..
  103. "<br />- " ..
  104. translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
  105. end
  106. -- "Force IP Version not supported"
  107. if not (has_ssl and has_dnstcp) then
  108. local dv = s:option(DummyValue, "_no_force_ip")
  109. dv.titleref = DISP.build_url("admin", "system", "packages")
  110. dv.rawhtml = true
  111. dv.title = bold_on ..
  112. translate("Force IP Version not supported") .. bold_off
  113. local value = translate("BusyBox's nslookup and Wget do not support to specify " ..
  114. "the IP version to use for communication with DDNS Provider.")
  115. if not has_ssl then
  116. value = value .. "<br />- " ..
  117. translate("You should install GNU Wget with SSL (prefered) or cURL package.")
  118. end
  119. if not has_dnstcp then
  120. value = value .. "<br />- " ..
  121. translate("You should install BIND host package for DNS requests.")
  122. end
  123. dv.value = value
  124. end
  125. -- "DNS requests via TCP not supported"
  126. if not has_dnstcp then
  127. local dv = s:option(DummyValue, "_no_dnstcp")
  128. dv.titleref = DISP.build_url("admin", "system", "packages")
  129. dv.rawhtml = true
  130. dv.title = bold_on ..
  131. translate("DNS requests via TCP not supported") .. bold_off
  132. dv.value = translate("BusyBox's nslookup does not support to specify to use TCP instead of default UDP when requesting DNS server") ..
  133. "<br />- " ..
  134. translate("You should install BIND host package for DNS requests.")
  135. end
  136. return m