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