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