luci-app-ddns: improve performance
[project/luci.git] / applications / luci-app-ddns / luasrc / model / cbi / ddns / hints.lua
1 -- Copyright 2014-2016 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local DISP = require "luci.dispatcher"
5 local SYS = require "luci.sys"
6 local CTRL = require "luci.controller.ddns" -- this application's controller
7 local DDNS = require "luci.tools.ddns" -- ddns multiused functions
8
9 -- html constants
10 font_red = [[<font color="red">]]
11 font_off = [[</font>]]
12 bold_on = [[<strong>]]
13 bold_off = [[</strong>]]
14
15 -- cbi-map definition -- #######################################################
16 m = Map("ddns")
17 m.title = CTRL.app_title_back()
18 m.description = CTRL.app_description()
19 m.redirect = DISP.build_url("admin", "services", "ddns")
20
21 -- SimpleSection definition -- #################################################
22 -- show Hints to optimize installation and script usage
23 s = m:section( SimpleSection,
24 translate("Hints"),
25 translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
26
27 -- ddns-scripts needs to be updated for full functionality
28 if not CTRL.service_ok() then
29 local so = s:option(DummyValue, "_update_needed")
30 so.titleref = DISP.build_url("admin", "system", "packages")
31 so.rawhtml = true
32 so.title = font_red .. bold_on ..
33 translate("Software update required") .. bold_off .. font_off
34 so.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") ..
35 "<br />" ..
36 translate("Please update to the current version!")
37 end
38
39 -- DDNS Service disabled
40 if not SYS.init.enabled("ddns") then
41 local se = s:option(DummyValue, "_not_enabled")
42 se.titleref = DISP.build_url("admin", "system", "startup")
43 se.rawhtml = true
44 se.title = bold_on ..
45 translate("DDNS Autostart disabled") .. bold_off
46 se.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" ..
47 "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" )
48 end
49
50 -- No IPv6 support
51 if not DDNS.env_info("has_ipv6") then
52 local v6 = s:option(DummyValue, "_no_ipv6")
53 v6.titleref = 'http://www.openwrt.org" target="_blank'
54 v6.rawhtml = true
55 v6.title = bold_on ..
56 translate("IPv6 not supported") .. bold_off
57 v6.value = translate("IPv6 is currently not (fully) supported by this system" .. "<br />" ..
58 "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "<br />" ..
59 "or update your system to the latest OpenWrt Release")
60 end
61
62 -- No HTTPS support
63 if not DDNS.env_info("has_ssl") then
64 local sl = s:option(DummyValue, "_no_https")
65 sl.titleref = DISP.build_url("admin", "system", "packages")
66 sl.rawhtml = true
67 sl.title = bold_on ..
68 translate("HTTPS not supported") .. bold_off
69 sl.value = translate("Neither GNU Wget with SSL nor cURL installed to support secure updates via HTTPS protocol.") ..
70 "<br />- " ..
71 translate("You should install 'wget' or 'curl' or 'uclient-fetch' with 'libustream-*ssl' package.") ..
72 "<br />- " ..
73 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
74 end
75
76 -- No bind_network
77 if not DDNS.env_info("has_bindnet") then
78 local bn = s:option(DummyValue, "_no_bind_network")
79 bn.titleref = DISP.build_url("admin", "system", "packages")
80 bn.rawhtml = true
81 bn.title = bold_on ..
82 translate("Binding to a specific network not supported") .. bold_off
83 bn.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") ..
84 "<br />- " ..
85 translate("You should install 'wget' or 'curl' package.") ..
86 "<br />- " ..
87 translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") ..
88 "<br />- " ..
89 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
90 end
91
92 -- currently only cURL possibly without proxy support
93 if not DDNS.env_info("has_proxy") then
94 local px = s:option(DummyValue, "_no_proxy")
95 px.titleref = DISP.build_url("admin", "system", "packages")
96 px.rawhtml = true
97 px.title = bold_on ..
98 translate("cURL without Proxy Support") .. bold_off
99 px.value = translate("cURL is installed, but libcurl was compiled without proxy support.") ..
100 "<br />- " ..
101 translate("You should install 'wget' or 'uclient-fetch' package or replace libcurl.") ..
102 "<br />- " ..
103 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
104 end
105
106 -- "Force IP Version not supported"
107 if not DDNS.env_info("has_forceip") then
108 local fi = s:option(DummyValue, "_no_force_ip")
109 fi.titleref = DISP.build_url("admin", "system", "packages")
110 fi.rawhtml = true
111 fi.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 (DDNS.env_info("has_wgetssl") or DDNS.env_info("has_curl") or DDNS.env_info("has_fetch")) then
116 value = value .. "<br />- " ..
117 translate("You should install 'wget' or 'curl' or 'uclient-fetch' package.")
118 end
119 if not DDNS.env_info("has_bindhost") then
120 value = value .. "<br />- " ..
121 translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.")
122 end
123 fi.value = value
124 end
125
126 -- "DNS requests via TCP not supported"
127 if not DDNS.env_info("has_bindhost") then
128 local dt = s:option(DummyValue, "_no_dnstcp")
129 dt.titleref = DISP.build_url("admin", "system", "packages")
130 dt.rawhtml = true
131 dt.title = bold_on ..
132 translate("DNS requests via TCP not supported") .. bold_off
133 dt.value = translate("BusyBox's nslookup and hostip do not support to specify to use TCP " ..
134 "instead of default UDP when requesting DNS server!") ..
135 "<br />- " ..
136 translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.")
137 end
138
139 -- nslookup compiled with musl produce problems when using
140 if not DDNS.env_info("has_dnsserver") then
141 local ds = s:option(DummyValue, "_no_dnsserver")
142 ds.titleref = DISP.build_url("admin", "system", "packages")
143 ds.rawhtml = true
144 ds.title = bold_on ..
145 translate("Using specific DNS Server not supported") .. bold_off
146 ds.value = translate("BusyBox's nslookup in the current compiled version " ..
147 "does not handle given DNS Servers correctly!") ..
148 "<br />- " ..
149 translate("You should install 'bind-host' or 'knot-host' or 'drill' or 'hostip' package, " ..
150 "if you need to specify a DNS server to detect your registered IP.")
151 end
152
153 -- certificates installed
154 if DDNS.env_info("has_ssl") and not DDNS.env_info("has_cacerts") then
155 local ca = s:option(DummyValue, "_no_certs")
156 ca.titleref = DISP.build_url("admin", "system", "packages")
157 ca.rawhtml = true
158 ca.title = bold_on ..
159 translate("No certificates found") .. bold_off
160 ca.value = translate("If using secure communication you should verify server certificates!") ..
161 "<br />- " ..
162 translate("Install 'ca-certificates' package or needed certificates " ..
163 "by hand into /etc/ssl/certs default directory")
164 end
165
166 return m