diff options
Diffstat (limited to 'applications/luci-app-ddns/luasrc/model/cbi/ddns')
4 files changed, 77 insertions, 64 deletions
diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua index c924e845c2..a8f4cbf7ad 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua @@ -58,7 +58,7 @@ end -- read services/services_ipv6 files -- ######################################## local services4 = { } -- IPv4 -- -local fd4 = io.open("/usr/lib/ddns/services", "r") +local fd4 = io.open("/etc/ddns/services", "r") if fd4 then local ln, s, t repeat @@ -72,7 +72,7 @@ if fd4 then end local services6 = { } -- IPv6 -- -local fd6 = io.open("/usr/lib/ddns/services_ipv6", "r") +local fd6 = io.open("/etc/ddns/services_ipv6", "r") if fd6 then local ln, s, t repeat @@ -91,35 +91,38 @@ end -- local IP can be read local function _verify_ip_source() -- section is globally defined here be calling agrument (see above) - local _network = "-" - local _url = "-" - local _interface = "-" - local _script = "-" - local _proxy = "" + local _arg local _ipv6 = usev6:formvalue(section) local _source = (_ipv6 == "1") and src6:formvalue(section) or src4:formvalue(section) + + local command = CTRL.luci_helper .. [[ -]] + if (_ipv6 == "1") then command = command .. [[6]] end + if _source == "network" then - _network = (_ipv6 == "1") + _arg = (_ipv6 == "1") and ipn6:formvalue(section) or ipn4:formvalue(section) + command = command .. [[n ]] .. _arg elseif _source == "web" then - _url = (_ipv6 == "1") + _arg = (_ipv6 == "1") and iurl6:formvalue(section) or iurl4:formvalue(section) + command = command .. [[u ]] .. _arg + -- proxy only needed for checking url - _proxy = (pxy) and pxy:formvalue(section) or "" + _arg = (pxy) and pxy:formvalue(section) or "" + if (_arg and #_arg > 0) then + command = command .. [[ -p ]] .. _arg + end elseif _source == "interface" then - _interface = ipi:formvalue(section) + command = command .. [[i ]] .. ipi:formvalue(section) elseif _source == "script" then - _script = ips:formvalue(section) + command = command .. [[s ]] .. ips:formvalue(section) end - - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh get_local_ip ]] .. - _ipv6 .. [[ ]] .. _source .. [[ ]] .. _network .. [[ ]] .. - _url .. [[ ]] .. _interface .. [[ ']] .. _script.. [[' ]] .. _proxy + command = command .. [[ -- get_local_ip]] return (SYS.call(command) == 0) end @@ -248,10 +251,8 @@ if m:formvalue("cbid.ddns.%s._switch" % section) then -- section == arg[1] end -- read application settings -- ################################################ --- date format; if not set use ISO format -local date_format = m.uci:get(m.config, "global", "date_format") or "%F %R" -- log directory -local log_dir = m.uci:get(m.config, "global", "log_dir") or "/var/log/ddns" +local logdir = m.uci:get(m.config, "global", "ddns_logdir") or "/var/log/ddns" -- cbi-section definition -- ################################################### local ns = m:section( NamedSection, section, "service", @@ -335,7 +336,7 @@ function svc4.validate(self, value) if usev6:formvalue(section) ~= "1" then -- do only on IPv4 return value else - return "" -- supress validate error + return "" -- suppress validate error end end function svc4.write(self, section, value) @@ -376,7 +377,7 @@ function svc6.validate(self, value) if DDNS.has_ipv6 then return value end return nil, err_tab_basic(self) .. err_ipv6_plain else - return "" -- supress validate error + return "" -- suppress validate error end end function svc6.write(self, section, value) @@ -626,7 +627,7 @@ if DDNS.has_ssl then cert.forcewrite = true function cert.validate(self, value) if https:formvalue(section) ~= "1" then - return "" -- supress validate error if NOT https + return "" -- suppress validate error if NOT https end if value then -- otherwise errors in datatype check if DTYP.directory(value) @@ -1086,7 +1087,7 @@ function eif6.parse(self, section, novld) end -- IPv4/IPv6 - bind_network -- ################################################ -if DDNS.has_bindnet or ( ( m:get(section, "bind_network") ) ~= "" ) then +if DDNS.has_bindnet or ( ( m:get(section, "bind_network") or "" ) ~= "" ) then bnet = ns:taboption("advanced", ListValue, "bind_network", translate("Bind Network") ) bnet:depends("ipv4_source", "web") @@ -1158,8 +1159,11 @@ if DDNS.has_dnsserver or ( ( m:get(section, "dns_server") or "" ) ~= "" ) then else local ipv6 = usev6:formvalue(section) or "0" local force = fipv:formvalue(section) or "0" - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_dns ]] .. - value .. [[ ]] .. ipv6 .. [[ ]] .. force + local command = CTRL.luci_helper .. [[ -]] + if (ipv6 == 1) then command = command .. [[6]] end + if (force == 1) then command = command .. [[f]] end + command = command .. [[d ]] .. value .. [[ -- verify_dns]] + local ret = SYS.call(command) if ret == 0 then return value -- everything OK elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host") @@ -1225,8 +1229,10 @@ if DDNS.has_proxy or ( ( m:get(section, "proxy") or "" ) ~= "" ) then elseif DDNS.has_proxy then local ipv6 = usev6:formvalue(section) or "0" local force = fipv:formvalue(section) or "0" - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_proxy ]] .. - value .. [[ ]] .. ipv6 .. [[ ]] .. force + local command = CRTL.luci_helper .. [[ -]] + if (ipv6 == 1) then command = command .. [[6]] end + if (force == 1) then command = command .. [[f]] end + command = command .. [[p ]] .. value .. [[ -- verify_proxy]] local ret = SYS.call(command) if ret == 0 then return value elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host") @@ -1262,7 +1268,7 @@ end logf = ns:taboption("advanced", Flag, "use_logfile", translate("Log to file"), translate("Writes detailed messages to log file. File will be truncated automatically.") .. "<br />" .. - translate("File") .. [[: "]] .. log_dir .. [[/]] .. section .. [[.log"]] ) + translate("File") .. [[: "]] .. logdir .. [[/]] .. section .. [[.log"]] ) logf.orientation = "horizontal" logf.default = "1" -- if not defined write to log by default @@ -1464,7 +1470,7 @@ lv.template = "ddns/detail_logview" lv.inputtitle = translate("Read / Reread log file") lv.rows = 50 function lv.cfgvalue(self, section) - local lfile=log_dir .. "/" .. section .. ".log" + local lfile=logdir .. "/" .. section .. ".log" if NXFS.access(lfile) then return lfile .. "\n" .. translate("Please press [Read] button") end diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua index 23ce4f13f7..9dc0857509 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua @@ -16,7 +16,8 @@ m.redirect = DISP.build_url("admin", "services", "ddns") function m.commit_handler(self) if self.changed then -- changes ? - os.execute("/etc/init.d/ddns reload &") -- reload configuration + local command = CTRL.luci_helper .. " -- reload" + os.execute(command) -- reload configuration end end @@ -40,8 +41,8 @@ function ns.cfgvalue(self, section) return self.map:get(section) end --- allow_local_ip -- ########################################################## -local ali = ns:option(Flag, "allow_local_ip") +-- upd_privateip -- ########################################################### +local ali = ns:option(Flag, "upd_privateip") ali.title = translate("Allow non-public IP's") ali.description = translate("Non-public and by default blocked IP's") .. ":" .. [[<br /><strong>IPv4: </strong>]] @@ -50,8 +51,8 @@ ali.description = translate("Non-public and by default blocked IP's") .. ":" .. "::/32, f000::/4" ali.default = "0" --- date_format -- ############################################################# -local df = ns:option(Value, "date_format") +-- ddns_dateformat -- ######################################################### +local df = ns:option(Value, "ddns_dateformat") df.title = translate("Date format") df.description = [[<a href="http://www.cplusplus.com/reference/ctime/strftime/" target="_blank">]] .. translate("For supported codes look here") @@ -69,8 +70,8 @@ function df.parse(self, section, novld) DDNS.value_parse(self, section, novld) end --- run_dir -- ################################################################# -local rd = ns:option(Value, "run_dir") +-- ddns_rundir -- ############################################################# +local rd = ns:option(Value, "ddns_rundir") rd.title = translate("Status directory") rd.description = translate("Directory contains PID and other status information for each running section") rd.default = "/var/run/ddns" @@ -79,8 +80,8 @@ function rd.parse(self, section, novld) DDNS.value_parse(self, section, novld) end --- log_dir -- ################################################################# -local ld = ns:option(Value, "log_dir") +-- ddns_logdir -- ############################################################# +local ld = ns:option(Value, "ddns_logdir") ld.title = translate("Log directory") ld.description = translate("Directory contains Log files for each running section") ld.default = "/var/log/ddns" @@ -89,8 +90,8 @@ function ld.parse(self, section, novld) DDNS.value_parse(self, section, novld) end --- log_lines -- ############################################################### -local ll = ns:option(Value, "log_lines") +-- ddns_loglines -- ########################################################### +local ll = ns:option(Value, "ddns_loglines") ll.title = translate("Log length") ll.description = translate("Number of last lines stored in log files") ll.default = "250" diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua index 335bb01b2d..df39a3a7e5 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua @@ -24,7 +24,7 @@ s = m:section( SimpleSection, translate("Hints"), translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") ) --- ddns_scripts needs to be updated for full functionality +-- ddns-scripts needs to be updated for full functionality if not CTRL.service_ok() then local so = s:option(DummyValue, "_update_needed") so.titleref = DISP.build_url("admin", "system", "packages") @@ -66,9 +66,9 @@ if not DDNS.has_ssl then sl.rawhtml = true sl.title = bold_on .. translate("HTTPS not supported") .. bold_off - sl.value = translate("Neither GNU Wget with SSL nor cURL installed to support updates via HTTPS protocol.") .. + sl.value = translate("Neither GNU Wget with SSL nor cURL installed to support secure updates via HTTPS protocol.") .. "<br />- " .. - translate("You should install GNU Wget with SSL (prefered) or cURL package.") .. + translate("You should install 'wget' or 'curl' or 'uclient-fetch' with 'libustream-*ssl' package.") .. "<br />- " .. translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") end @@ -82,7 +82,7 @@ if not DDNS.has_bindnet then translate("Binding to a specific network not supported") .. bold_off bn.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") .. "<br />- " .. - translate("You should install GNU Wget with SSL or cURL package.") .. + translate("You should install 'wget' or 'curl' package.") .. "<br />- " .. translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") .. "<br />- " .. @@ -98,7 +98,7 @@ if not DDNS.has_proxy then translate("cURL without Proxy Support") .. bold_off px.value = translate("cURL is installed, but libcurl was compiled without proxy support.") .. "<br />- " .. - translate("You should install GNU Wget with SSL or replace libcurl.") .. + translate("You should install 'wget' or 'uclient-fetch' package or replace libcurl.") .. "<br />- " .. translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") end @@ -112,13 +112,13 @@ if not DDNS.has_forceip then translate("Force IP Version not supported") .. bold_off local value = translate("BusyBox's nslookup and Wget do not support to specify " .. "the IP version to use for communication with DDNS Provider!") - if not (DDNS.has_wgetssl or DDNS.has_curl) then + if not (DDNS.has_wgetssl or DDNS.has_curl or DDNS.has_fetch) then value = value .. "<br />- " .. - translate("You should install GNU Wget with SSL (prefered) or cURL package.") + translate("You should install 'wget' or 'curl' or 'uclient-fetch' package.") end - if not (DDNS.has_bindhost or DDNS.has_hostip) then + if not DDNS.has_bindhost then value = value .. "<br />- " .. - translate("You should install BIND host or hostip package for DNS requests.") + translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.") end fi.value = value end @@ -133,7 +133,7 @@ if not DDNS.has_bindhost then dt.value = translate("BusyBox's nslookup and hostip do not support to specify to use TCP " .. "instead of default UDP when requesting DNS server!") .. "<br />- " .. - translate("You should install BIND host package for DNS requests.") + translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.") end -- nslookup compiled with musl produce problems when using @@ -146,7 +146,7 @@ if not DDNS.has_dnsserver then ds.value = translate("BusyBox's nslookup in the current compiled version " .. "does not handle given DNS Servers correctly!") .. "<br />- " .. - translate("You should install BIND host or hostip package, " .. + translate("You should install 'bind-host' or 'knot-host' or 'drill' or 'hostip' package, " .. "if you need to specify a DNS server to detect your registered IP.") end @@ -159,7 +159,7 @@ if DDNS.has_ssl and not DDNS.has_cacerts then translate("No certificates found") .. bold_off ca.value = translate("If using secure communication you should verify server certificates!") .. "<br />- " .. - translate("Install ca-certificates package or needed certificates " .. + translate("Install 'ca-certificates' package or needed certificates " .. "by hand into /etc/ssl/certs default directory") end diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua index e6da7cc188..6ba3ea0dd8 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua @@ -33,15 +33,18 @@ m.description = CTRL.app_description() m.on_after_commit = function(self) if self.changed then -- changes ? + local command = CTRL.luci_helper if SYS.init.enabled("ddns") then -- ddns service enabled, restart all - os.execute("/etc/init.d/ddns restart") + command = command .. " -- restart" + os.execute(command) else -- ddns service disabled, send SIGHUP to running - os.execute("killall -1 dynamic_dns_updater.sh") + command = command .. " -- reload" + os.execute(command) end end end --- SimpleSection definiton -- ################################################## +-- SimpleSection definition -- ################################################## -- with all the JavaScripts we need for "a good Show" a = m:section( SimpleSection ) a.template = "ddns/overview_status" @@ -52,7 +55,7 @@ if show_hints or need_update or not_enabled then s = m:section( SimpleSection, translate("Hints") ) - -- ddns_scripts needs to be updated for full functionality + -- ddns-scripts needs to be updated for full functionality if need_update then local dv = s:option(DummyValue, "_update_needed") dv.titleref = DISP.build_url("admin", "system", "packages") @@ -119,18 +122,21 @@ function dom.set_one(self, section) end end function dom.set_two(self, section) - local lookup = self.map:get(section, "lookup_host") or "" - if lookup == "" then return "" end + local lookup_host = self.map:get(section, "lookup_host") or "" + if lookup_host == "" then return "" end local dnsserver = self.map:get(section, "dnsserver") or "" local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0) local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0) local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0) - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh]] - if not NXFS.access(command, "rwx", "rx", "rx") then - NXFS.chmod(command, 755) - end - command = command .. [[ get_registered_ip ]] .. lookup .. [[ ]] .. use_ipv6 .. - [[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp .. [[ ]] .. dnsserver + local is_glue = tonumber(self.map:get(section, "is_glue") or 0) + local command = CTRL.luci_helper .. [[ -]] + if (use_ipv6 == 1) then command = command .. [[6]] end + if (force_ipversion == 1) then command = command .. [[f]] end + if (force_dnstcp == 1) then command = command .. [[t]] end + if (is_glue == 1) then command = command .. [[g]] end + command = command .. [[l ]] .. lookup_host + if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end + command = command .. [[ -- get_registered_ip]] local ip = SYS.exec(command) if ip == "" then ip = translate("no data") end return ip |