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