luci-app-ddns: rollup to 2.3.0 to reflect changes on ddns-scripts
[project/luci.git] / applications / luci-app-ddns / luasrc / model / cbi / ddns / hints.lua
1 -- Copyright 2014 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 -- 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
15 -- html constants
16 font_red = [[<font color="red">]]
17 font_off = [[</font>]]
18 bold_on  = [[<strong>]]
19 bold_off = [[</strong>]]
20
21 -- cbi-map definition -- #######################################################
22 m = Map("ddns")
23 m.title         = CTRL.app_title_back()
24 m.description   = CTRL.app_description()
25 m.redirect      = DISP.build_url("admin", "services", "ddns")
26
27 -- SimpleSection definition -- #################################################
28 -- show Hints to optimize installation and script usage
29 s = m:section( SimpleSection,
30         translate("Hints"),
31         translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
32
33 -- ddns_scripts needs to be updated for full functionality
34 if not CTRL.service_ok() 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
45 -- DDNS Service disabled
46 if not SYS.init.enabled("ddns") then
47         local dv = s:option(DummyValue, "_not_enabled")
48         dv.titleref = DISP.build_url("admin", "system", "startup")
49         dv.rawhtml  = true
50         dv.title = bold_on ..
51                 translate("DDNS Autostart disabled") .. bold_off
52         dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" ..
53                         "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" )
54 end
55
56 -- No IPv6 support
57 if not DDNS.check_ipv6() then
58         local dv = s:option(DummyValue, "_no_ipv6")
59         dv.titleref = 'http://www.openwrt.org" target="_blank'
60         dv.rawhtml  = true
61         dv.title = bold_on ..
62                 translate("IPv6 not supported") .. bold_off
63         dv.value = translate("IPv6 is currently not (fully) supported by this system" .. "<br />" ..
64                         "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "<br />" ..
65                         "or update your system to the latest OpenWrt Release")
66 end
67
68 -- No HTTPS support
69 if not has_ssl then
70         local dv = s:option(DummyValue, "_no_https")
71         dv.titleref = DISP.build_url("admin", "system", "packages")
72         dv.rawhtml  = true
73         dv.title = bold_on ..
74                 translate("HTTPS not supported") .. bold_off
75         dv.value = translate("Neither GNU Wget with SSL nor cURL installed to support updates via HTTPS protocol.") ..
76                         "<br />- " ..
77                         translate("You should install GNU Wget with SSL (prefered) or cURL package.") ..
78                         "<br />- " ..
79                         translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
80 end
81
82 -- No bind_network
83 if not has_ssl then
84         local dv = s:option(DummyValue, "_no_bind_network")
85         dv.titleref = DISP.build_url("admin", "system", "packages")
86         dv.rawhtml  = true
87         dv.title = bold_on ..
88                 translate("Binding to a specific network not supported") .. bold_off
89         dv.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") ..
90                         "<br />- " ..
91                         translate("You should install GNU Wget with SSL or cURL package.") ..
92                         "<br />- " ..
93                         translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") ..
94                         "<br />- " ..
95                         translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
96 end
97
98 -- cURL without proxy support
99 if has_ssl and not has_proxy then
100         local dv = s:option(DummyValue, "_no_proxy")
101         dv.titleref = DISP.build_url("admin", "system", "packages")
102         dv.rawhtml  = true
103         dv.title = bold_on ..
104                 translate("cURL without Proxy Support") .. bold_off
105         dv.value = translate("cURL is installed, but libcurl was compiled without proxy support.") ..
106                         "<br />- " ..
107                         translate("You should install GNU Wget with SSL or replace libcurl.") ..
108                         "<br />- " ..
109                         translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
110 end
111
112 -- "Force IP Version not supported"
113 if not (has_ssl and has_dnstcp) then
114         local dv = s:option(DummyValue, "_no_force_ip")
115         dv.titleref = DISP.build_url("admin", "system", "packages")
116         dv.rawhtml  = true
117         dv.title = bold_on ..
118                 translate("Force IP Version not supported") .. bold_off
119         local value = translate("BusyBox's nslookup and Wget do not support to specify " ..
120                         "the IP version to use for communication with DDNS Provider.")
121         if not has_ssl then
122                 value = value .. "<br />- " ..
123                         translate("You should install GNU Wget with SSL (prefered) or cURL package.")
124         end
125         if not has_dnstcp then
126                 value = value .. "<br />- " ..
127                         translate("You should install BIND host package for DNS requests.")
128         end
129         dv.value = value
130 end
131
132 -- "DNS requests via TCP not supported"
133 if not has_dnstcp then
134         local dv = s:option(DummyValue, "_no_dnstcp")
135         dv.titleref = DISP.build_url("admin", "system", "packages")
136         dv.rawhtml  = true
137         dv.title = bold_on ..
138                 translate("DNS requests via TCP not supported") .. bold_off
139         dv.value = translate("BusyBox's nslookup does not support to specify to use TCP instead of default UDP when requesting DNS server") ..
140                         "<br />- " ..
141                         translate("You should install BIND host package for DNS requests.")
142 end
143
144 return m