1 -- Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
2 -- Licensed to the public under the Apache License 2.0.
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
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)
18 font_red = [[<font color="red">]]
19 font_off = [[</font>]]
20 bold_on = [[<strong>]]
21 bold_off = [[</strong>]]
23 -- cbi-map definition -- #######################################################
26 m.title = [[<a href="]] .. DISP.build_url("admin", "services", "ddns") .. [[">]] ..
27 translate("Dynamic DNS") .. [[</a>]]
29 m.description = translate("Dynamic DNS allows that your router can be reached with " ..
30 "a fixed hostname while having a dynamically changing " ..
33 m.redirect = DISP.build_url("admin", "services", "ddns")
35 -- SimpleSection definition -- #################################################
36 -- show Hints to optimize installation and script usage
37 s = m:section( SimpleSection,
39 translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
41 -- ddns_scripts needs to be updated for full functionality
43 local dv = s:option(DummyValue, "_update_needed")
44 dv.titleref = DISP.build_url("admin", "system", "packages")
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.") ..
50 translate("Please update to the current version!")
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")
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')" )
65 if not DDNS.check_ipv6() then
66 local dv = s:option(DummyValue, "_no_ipv6")
67 dv.titleref = 'http://www.openwrt.org" target="_blank'
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")
78 local dv = s:option(DummyValue, "_no_https")
79 dv.titleref = DISP.build_url("admin", "system", "packages")
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.") ..
85 translate("You should install GNU Wget with SSL (prefered) or cURL package.") ..
87 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
92 local dv = s:option(DummyValue, "_no_bind_network")
93 dv.titleref = DISP.build_url("admin", "system", "packages")
96 translate("Binding to a specific network not supported") .. bold_off
97 dv.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") ..
99 translate("You should install GNU Wget with SSL or cURL package.") ..
101 translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") ..
103 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
106 -- cURL without proxy support
107 if has_ssl and not has_proxy then
108 local dv = s:option(DummyValue, "_no_proxy")
109 dv.titleref = DISP.build_url("admin", "system", "packages")
111 dv.title = bold_on ..
112 translate("cURL without Proxy Support") .. bold_off
113 dv.value = translate("cURL is installed, but libcurl was compiled without proxy support.") ..
115 translate("You should install GNU Wget with SSL or replace libcurl.") ..
117 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
120 -- "Force IP Version not supported"
121 if not (has_ssl and has_dnstcp) then
122 local dv = s:option(DummyValue, "_no_force_ip")
123 dv.titleref = DISP.build_url("admin", "system", "packages")
125 dv.title = bold_on ..
126 translate("Force IP Version not supported") .. bold_off
127 local value = translate("BusyBox's nslookup and Wget do not support to specify " ..
128 "the IP version to use for communication with DDNS Provider.")
130 value = value .. "<br />- " ..
131 translate("You should install GNU Wget with SSL (prefered) or cURL package.")
133 if not has_dnstcp then
134 value = value .. "<br />- " ..
135 translate("You should install BIND host package for DNS requests.")
140 -- "DNS requests via TCP not supported"
141 if not has_dnstcp then
142 local dv = s:option(DummyValue, "_no_dnstcp")
143 dv.titleref = DISP.build_url("admin", "system", "packages")
145 dv.title = bold_on ..
146 translate("DNS requests via TCP not supported") .. bold_off
147 dv.value = translate("BusyBox's nslookup does not support to specify to use TCP instead of default UDP when requesting DNS server") ..
149 translate("You should install BIND host package for DNS requests.")