diff options
Diffstat (limited to 'applications/luci-ddns')
19 files changed, 0 insertions, 2763 deletions
diff --git a/applications/luci-ddns/CHANGELOG b/applications/luci-ddns/CHANGELOG deleted file mode 100644 index 34c2c8d227..0000000000 --- a/applications/luci-ddns/CHANGELOG +++ /dev/null @@ -1,51 +0,0 @@ -Version: 2.1.0-3 -Date: 2014-12-07 -ddns-scripts: 2.1.0-2 or greater needed - -- modified controller - - remove support for ddns-scripts Version 1.x - - ddns-scripts not correctly installed do not start - - no config file create an empty one -- moved log settings to advanced tab -- set default syslog level "Notice" -- removed special handling for dynamic_dns_helper.sh in postinst - --------------------------------------------------------------------------------- -Version: 2.1.0-2 -Date: 2014-11-15 -ddns-scripts: 2.1.0-2 or greater needed - -- moved /usr/lib/ddns/dynamic_dns_lucihelper.sh to ddns-scripts package -- fixed error message when validating proxy -- modified validating ip_script to allow the usage of parameters -- using ipkg/postinst AND ipkg/postinst-pkg as long as LuCI Makefiles did not - fullfil requirements of new OpenWrt default_postinst and default_postrm - reported in Issue #255 -- cleanup whitespaces at line ends - --------------------------------------------------------------------------------- -Version: 2.1.0-1 -Date: 2014-11-09 -ddns-scripts: 2.1.0-1 or greater needed - -fix verify of entry for DNS server Issue #244 - https://github.com/openwrt/luci/issues/244 -add support for option 'update_script' -add display of version information when click on "Dynamic DNS" on overview page -add verify of installed ddns-scripts version and show as hint if not correct version -modified epoch to date conversation -cbi object Flag did not set section.changed state, fixed in tools.flag_parse function -ucitrack entry no longer needed and removed -minor fixes - --------------------------------------------------------------------------------- -Version: 2.0.1-1 -Date: 2014-09-21 -ddns-scripts: 2.0.1-1 up to 2.0.1-9 - -New DDNS status in System->Status overview -New Overview page with option to start/stop a section -New Detail page with tabbed view incl. logfile viewer -Extended verify of all entries before save to config - incl. connect test to DNS- and Proxy-server -Support for all available options of ddns-scripts 1.x and 2.x diff --git a/applications/luci-ddns/Makefile b/applications/luci-ddns/Makefile deleted file mode 100644 index 3f57d63c69..0000000000 --- a/applications/luci-ddns/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -PO = ddns - -include ../../build/config.mk -include ../../build/module.mk diff --git a/applications/luci-ddns/ipkg/postinst b/applications/luci-ddns/ipkg/postinst deleted file mode 100644 index a2c13fa34c..0000000000 --- a/applications/luci-ddns/ipkg/postinst +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -[ -n "${IPKG_INSTROOT}" ] || { - ( . /etc/uci-defaults/luci-ddns ) && rm -f /etc/uci-defaults/luci-ddns - exit 0 -} diff --git a/applications/luci-ddns/ipkg/postinst-pkg b/applications/luci-ddns/ipkg/postinst-pkg deleted file mode 100644 index a2c13fa34c..0000000000 --- a/applications/luci-ddns/ipkg/postinst-pkg +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -[ -n "${IPKG_INSTROOT}" ] || { - ( . /etc/uci-defaults/luci-ddns ) && rm -f /etc/uci-defaults/luci-ddns - exit 0 -} diff --git a/applications/luci-ddns/luasrc/controller/ddns.lua b/applications/luci-ddns/luasrc/controller/ddns.lua deleted file mode 100644 index b11388c30c..0000000000 --- a/applications/luci-ddns/luasrc/controller/ddns.lua +++ /dev/null @@ -1,261 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> -Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -module("luci.controller.ddns", package.seeall) - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local DISP = require "luci.dispatcher" -local HTTP = require "luci.http" -local UCI = require "luci.model.uci" -local SYS = require "luci.sys" -local DDNS = require "luci.tools.ddns" -- ddns multiused functions -local UTIL = require "luci.util" - -local luci_ddns_version = "2.1.0-3" -- luci-app-ddns / openwrt Makefile compatible version -local ddns_scripts_min = "2.1.0-2" -- minimum version of ddns-scripts required - -function index() - -- no services_ipv6 file or no dynamic_dns_lucihelper.sh - -- do NOT start - if not nixio.fs.access("/usr/lib/ddns/services_ipv6") - or not nixio.fs.access("/usr/lib/ddns/dynamic_dns_lucihelper.sh") then - return - end - -- no config create an empty one - if not nixio.fs.access("/etc/config/ddns") then - nixio.fs.writefile("/etc/config/ddns", "") - end - - entry( {"admin", "services", "ddns"}, cbi("ddns/overview"), _("Dynamic DNS"), 59) - entry( {"admin", "services", "ddns", "detail"}, cbi("ddns/detail"), nil ).leaf = true - entry( {"admin", "services", "ddns", "hints"}, cbi("ddns/hints", - {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), nil ).leaf = true - entry( {"admin", "services", "ddns", "logview"}, call("logread") ).leaf = true - entry( {"admin", "services", "ddns", "startstop"}, call("startstop") ).leaf = true - entry( {"admin", "services", "ddns", "status"}, call("status") ).leaf = true -end - --- function to read all sections status and return data array -local function _get_status() - local uci = UCI.cursor() - local service = SYS.init.enabled("ddns") and 1 or 0 - local url_start = DISP.build_url("admin", "system", "startup") - local luci_build = DDNS.ipkg_version("luci-app-ddns").version - local ddns_act = DDNS.ipkg_version("ddns-scripts").version - local data = {} -- Array to transfer data to javascript - - data[#data+1] = { - enabled = service, -- service enabled - url_up = url_start, -- link to enable DDS (System-Startup) - luci_ver = luci_ddns_version, -- luci-app-ddns / openwrt Makefile compatible version - luci_build = luci_build, -- installed luci build - script_min = ddns_scripts_min, -- minimum version of ddns-scripts needed - script_ver = ddns_act -- installed ddns-scripts - } - - uci:foreach("ddns", "service", function (s) - - -- Get section we are looking at - -- and enabled state - local section = s[".name"] - local enabled = tonumber(s["enabled"]) or 0 - local datelast = "_empty_" -- formated date of last update - local datenext = "_empty_" -- formated date of next update - - -- get force seconds - local force_seconds = DDNS.calc_seconds( - tonumber(s["force_interval"]) or 72 , - s["force_unit"] or "hours" ) - -- get/validate pid and last update - local pid = DDNS.get_pid(section) - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp - lasttime = 0 -- and/or not cleared on reboot - end - - -- no last update happen - if lasttime == 0 then - datelast = "_never_" - - -- we read last update - else - -- calc last update - -- sys.epoch - sys uptime + lastupdate(uptime) - local epoch = os.time() - uptime + lasttime - -- use linux date to convert epoch - datelast = DDNS.epoch2date(epoch) - -- calc and fill next update - datenext = DDNS.epoch2date(epoch + force_seconds) - end - - -- process running but update needs to happen - -- problems it force_seconds > uptime - force_seconds = (force_seconds > uptime) and uptime or force_seconds - if pid > 0 and ( lasttime + force_seconds - uptime ) <= 0 then - datenext = "_verify_" - - -- run once - elseif force_seconds == 0 then - datenext = "_runonce_" - - -- no process running and NOT enabled - elseif pid == 0 and enabled == 0 then - datenext = "_disabled_" - - -- no process running and NOT - elseif pid == 0 and enabled ~= 0 then - datenext = "_stopped_" - end - - -- get/set monitored interface and IP version - local iface = s["interface"] or "_nonet_" - local use_ipv6 = tonumber(s["use_ipv6"]) or 0 - if iface ~= "_nonet_" then - local ipv = (use_ipv6 == 1) and "IPv6" or "IPv4" - iface = ipv .. " / " .. iface - end - - -- try to get registered IP - local domain = s["domain"] or "_nodomain_" - local dnsserver = s["dns_server"] or "" - local force_ipversion = tonumber(s["force_ipversion"] or 0) - local force_dnstcp = tonumber(s["force_dnstcp"] or 0) - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh]] - command = command .. [[ get_registered_ip ]] .. domain .. [[ ]] .. use_ipv6 .. - [[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp .. [[ ]] .. dnsserver - local reg_ip = SYS.exec(command) - if reg_ip == "" then - reg_ip = "_nodata_" - end - - -- fill transfer array - data[#data+1] = { - section = section, - enabled = enabled, - iface = iface, - domain = domain, - reg_ip = reg_ip, - pid = pid, - datelast = datelast, - datenext = datenext - } - end) - - uci:unload("ddns") - return data -end - --- called by XHR.get from detail_logview.htm -function logread(section) - -- read application settings - local uci = UCI.cursor() - local log_dir = uci:get("ddns", "global", "log_dir") or "/var/log/ddns" - local lfile=log_dir .. "/" .. section .. ".log" - - local ldata=NXFS.readfile(lfile) - if not ldata or #ldata == 0 then - ldata="_nodata_" - end - uci:unload("ddns") - HTTP.write(ldata) -end - --- called by XHR.get from overview_status.htm -function startstop(section, enabled) - local uci = UCI.cursor() - local data = {} -- Array to transfer data to javascript - - -- if process running we want to stop and return - local pid = DDNS.get_pid(section) - if pid > 0 then - local tmp = NX.kill(pid, 15) -- terminate - NX.nanosleep(2) -- 2 second "show time" - -- status changed so return full status - data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) - return - end - - -- read uncommited changes - -- we don't save and commit data from other section or other options - -- only enabled will be done - local exec = true - local changed = uci:changes("ddns") - for k_config, v_section in pairs(changed) do - -- security check because uci.changes only gets our config - if k_config ~= "ddns" then - exec = false - break - end - for k_section, v_option in pairs(v_section) do - -- check if only section of button was changed - if k_section ~= section then - exec = false - break - end - for k_option, v_value in pairs(v_option) do - -- check if only enabled was changed - if k_option ~= "enabled" then - exec = false - break - end - end - end - end - - -- we can not execute because other - -- uncommited changes pending, so exit here - if not exec then - HTTP.write("_uncommited_") - return - end - - -- save enable state - uci:set("ddns", section, "enabled", ( (enabled == "true") and "1" or "0") ) - uci:save("ddns") - uci:commit("ddns") - uci:unload("ddns") - - -- start dynamic_dns_updater.sh script - os.execute ([[/usr/lib/ddns/dynamic_dns_updater.sh %s 0 > /dev/null 2>&1 &]] % section) - NX.nanosleep(3) -- 3 seconds "show time" - - -- status changed so return full status - data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) -end - --- called by XHR.poll from overview_status.htm -function status() - local data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) -end - --- check if installed ddns-scripts version < required version -function update_needed() - local sver = DDNS.ipkg_version("ddns-scripts") - local rver = UTIL.split(ddns_scripts_min, "[%.%-]", nil, true) - return (sver.major < (tonumber(rver[1]) or 0)) - or (sver.minor < (tonumber(rver[2]) or 0)) - or (sver.patch < (tonumber(rver[3]) or 0)) - or (sver.build < (tonumber(rver[4]) or 0)) -end - diff --git a/applications/luci-ddns/luasrc/model/cbi/ddns/detail.lua b/applications/luci-ddns/luasrc/model/cbi/ddns/detail.lua deleted file mode 100644 index 748586cdf6..0000000000 --- a/applications/luci-ddns/luasrc/model/cbi/ddns/detail.lua +++ /dev/null @@ -1,1224 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -A lot of code taken from original ddns.lua cbi-model made by -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> -Copyright 2013 Manuel Munz <freifunk at somakoma dot de> - -modified to use as detail page together with new overview page and -extensions for IPv6, HTTPS settings, syslog and log settings, -optional Proxy-Support, optional DNS-Server, optional use of TCP requests to DNS server, -optional force of IP protocol version usage -Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local NX = require "nixio" -local FS = require "nixio.fs" -local SYS = require "luci.sys" -local UTIL = require "luci.util" -local DISP = require "luci.dispatcher" -local WADM = require "luci.tools.webadmin" -local DTYP = require "luci.cbi.datatypes" -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- takeover arguments -- ####################################################### -section = arg[1] - --- check supported options -- ################################################## --- saved to local vars here because doing multiple os calls slow down the system -has_ipv6 = DDNS.check_ipv6() -- IPv6 support -has_ssl = DDNS.check_ssl() -- HTTPS support -has_proxy = DDNS.check_proxy() -- Proxy support -has_dnstcp = DDNS.check_bind_host() -- DNS TCP support -has_force = has_ssl and has_dnstcp -- Force IP Protocoll - --- html constants -- ########################################################### -font_red = "<font color='red'>" -font_off = "</font>" -bold_on = "<strong>" -bold_off = "</strong>" - --- error text constants -- ##################################################### -err_ipv6_plain = translate("IPv6 not supported") .. " - " .. - translate("please select 'IPv4' address version") -err_ipv6_basic = bold_on .. - font_red .. - translate("IPv6 not supported") .. - font_off .. - "<br />" .. translate("please select 'IPv4' address version") .. - bold_off -err_ipv6_other = bold_on .. - font_red .. - translate("IPv6 not supported") .. - font_off .. - "<br />" .. translate("please select 'IPv4' address version in") .. " " .. - [[<a href="]] .. - DISP.build_url("admin", "services", "ddns", "detail", section) .. - "?tab.dns." .. section .. "=basic" .. - [[">]] .. - translate("Basic Settings") .. - [[</a>]] .. - bold_off - -function err_tab_basic(self) - return translate("Basic Settings") .. " - " .. self.title .. ": " -end -function err_tab_adv(self) - return translate("Advanced Settings") .. " - " .. self.title .. ": " -end -function err_tab_timer(self) - return translate("Timer Settings") .. " - " .. self.title .. ": " -end - --- function to verify settings around ip_source --- will use dynamic_dns_lucihelper to check if --- 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 _ipv6 = usev6:formvalue(section) - local _source = (_ipv6 == "1") - and src6:formvalue(section) - or src4:formvalue(section) - if _source == "network" then - _network = (_ipv6 == "1") - and ipn6:formvalue(section) - or ipn4:formvalue(section) - elseif _source == "web" then - _url = (_ipv6 == "1") - and iurl6:formvalue(section) - or iurl4:formvalue(section) - -- proxy only needed for checking url - _proxy = (pxy) and pxy:formvalue(section) or "" - elseif _source == "interface" then - _interface = ipi:formvalue(section) - elseif _source == "script" then - _script = ips:formvalue(section) - end - - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh get_local_ip ]] .. - _ipv6 .. [[ ]] .. _source .. [[ ]] .. _network .. [[ ]] .. - _url .. [[ ]] .. _interface .. [[ ']] .. _script.. [[' ]] .. _proxy - local ret = SYS.call(command) - - if ret == 0 then - return true -- valid - else - return nil -- invalid - end -end - --- cbi-map definition -- ####################################################### -m = Map("ddns") - --- first need to close <a> from cbi map template our <a> closed by template -m.title = [[</a><a href="]] .. DISP.build_url("admin", "services", "ddns") .. [[">]] .. - translate("Dynamic DNS") - -m.description = translate("Dynamic DNS allows that your router can be reached with " .. - "a fixed hostname while having a dynamically changing " .. - "IP address.") - -m.redirect = DISP.build_url("admin", "services", "ddns") - -m.on_after_commit = function(self) - if self.changed then -- changes ? - local pid = DDNS.get_pid(section) - if pid > 0 then -- running ? - local tmp = NX.kill(pid, 1) -- send SIGHUP - end - end -end - --- read application settings -- ################################################ --- date format; if not set use ISO format -date_format = m.uci:get(m.config, "global", "date_format") or "%F %R" --- log directory -log_dir = m.uci:get(m.config, "global", "log_dir") or "/var/log/ddns" - --- cbi-section definition -- ################################################### -ns = m:section( NamedSection, section, "service", - translate("Details for") .. ([[: <strong>%s</strong>]] % section), - translate("Configure here the details for selected Dynamic DNS service") ) -ns.instance = section -- arg [1] -ns:tab("basic", translate("Basic Settings"), nil ) -ns:tab("advanced", translate("Advanced Settings"), nil ) -ns:tab("timer", translate("Timer Settings"), nil ) -ns:tab("logview", translate("Log File Viewer"), nil ) - --- TAB: Basic ##################################################################################### --- enabled -- ################################################################# -en = ns:taboption("basic", Flag, "enabled", - translate("Enabled"), - translate("If this service section is disabled it could not be started." .. "<br />" .. - "Neither from LuCI interface nor from console") ) -en.orientation = "horizontal" -function en.parse(self, section) - DDNS.flag_parse(self, section) -end - --- use_ipv6 (NEW) -- ########################################################## -usev6 = ns:taboption("basic", ListValue, "use_ipv6", - translate("IP address version"), - translate("Defines which IP address 'IPv4/IPv6' is send to the DDNS provider") ) -usev6.widget = "radio" -usev6.default = "0" -usev6:value("0", translate("IPv4-Address") ) -function usev6.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if has_ipv6 or (value == "1" and not has_ipv6) then - self:value("1", translate("IPv6-Address") ) - end - if value == "1" and not has_ipv6 then - self.description = err_ipv6_basic - end - return value -end -function usev6.validate(self, value) - if (value == "1" and has_ipv6) or value == "0" then - return value - end - return nil, err_tab_basic(self) .. err_ipv6_plain -end -function usev6.write(self, section, value) - if value == "0" then -- force rmempty - return self.map:del(section, self.option) - else - return self.map:set(section, self.option, value) - end -end - --- IPv4 - service_name -- ###################################################### -svc4 = ns:taboption("basic", ListValue, "ipv4_service_name", - translate("DDNS Service provider") .. " [IPv4]" ) -svc4.default = "-" -svc4:depends("use_ipv6", "0") -- only show on IPv4 - -local services4 = { } -local fd4 = io.open("/usr/lib/ddns/services", "r") - -if fd4 then - local ln - repeat - ln = fd4:read("*l") - local s = ln and ln:match('^%s*"([^"]+)"') - if s then services4[#services4+1] = s end - until not ln - fd4:close() -end - -for _, v in UTIL.vspairs(services4) do svc4:value(v) end -svc4:value("-", translate("-- custom --") ) - -function svc4.cfgvalue(self, section) - local v = DDNS.read_value(self, section, "service_name") - if not v or #v == 0 then - return "-" - else - return v - end -end -function svc4.validate(self, value) - if usev6:formvalue(section) == "0" then -- do only on IPv4 - return value - else - return "" -- supress validate error - end -end -function svc4.write(self, section, value) - if usev6:formvalue(section) == "0" then -- do only IPv4 here - self.map:del(section, self.option) -- to be shure - if value ~= "-" then -- and write "service_name - self.map:del(section, "update_url") -- delete update_url - return self.map:set(section, "service_name", value) - else - return self.map:del(section, "service_name") - end - end -end - --- IPv6 - service_name -- ###################################################### -svc6 = ns:taboption("basic", ListValue, "ipv6_service_name", - translate("DDNS Service provider") .. " [IPv6]" ) -svc6.default = "-" -svc6:depends("use_ipv6", "1") -- only show on IPv6 -if not has_ipv6 then - svc6.description = err_ipv6_basic -end - -local services6 = { } -local fd6 = io.open("/usr/lib/ddns/services_ipv6", "r") - -if fd6 then - local ln - repeat - ln = fd6:read("*l") - local s = ln and ln:match('^%s*"([^"]+)"') - if s then services6[#services6+1] = s end - until not ln - fd6:close() -end - -for _, v in UTIL.vspairs(services6) do svc6:value(v) end -svc6:value("-", translate("-- custom --") ) - -function svc6.cfgvalue(self, section) - local v = DDNS.read_value(self, section, "service_name") - if not v or #v == 0 then - return "-" - else - return v - end -end -function svc6.validate(self, value) - if usev6:formvalue(section) == "1" then -- do only on IPv6 - if has_ipv6 then return value end - return nil, err_tab_basic(self) .. err_ipv6_plain - else - return "" -- supress validate error - end -end -function svc6.write(self, section, value) - if usev6:formvalue(section) == "1" then -- do only when IPv6 - self.map:del(section, self.option) -- delete "ipv6_service_name" helper - if value ~= "-" then -- and write "service_name - self.map:del(section, "update_url") -- delete update_url - return self.map:set(section, "service_name", value) - else - return self.map:del(section, "service_name") - end - end -end - --- IPv4/IPv6 - update_url -- ################################################### -uurl = ns:taboption("basic", Value, "update_url", - translate("Custom update-URL"), - translate("Update URL to be used for updating your DDNS Provider." .. "<br />" .. - "Follow instructions you will find on their WEB page.") ) -uurl:depends("ipv4_service_name", "-") -uurl:depends("ipv6_service_name", "-") -function uurl.validate(self, value) - local script = ush:formvalue(section) - - if (usev6:formvalue(section) == "0" and svc4:formvalue(section) ~= "-") or - (usev6:formvalue(section) == "1" and svc6:formvalue(section) ~= "-") then - return "" -- suppress validate error - elseif not value then - if not script or not (#script > 0) then - return nil, err_tab_basic(self) .. translate("missing / required") - else - return "" -- suppress validate error / update_script is given - end - elseif (#script > 0) then - return nil, err_tab_basic(self) .. translate("either url or script could be set") - end - - local url = DDNS.parse_url(value) - if not url.scheme == "http" then - return nil, err_tab_basic(self) .. translate("must start with 'http://'") - elseif not url.query then - return nil, err_tab_basic(self) .. "<QUERY> " .. translate("missing / required") - elseif not url.host then - return nil, err_tab_basic(self) .. "<HOST> " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[ >/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_basic(self) .. translate("can not resolve host: ") .. url.host - end - - return value -end - --- IPv4/IPv6 - update_script -- ################################################ -ush = ns:taboption("basic", Value, "update_script", - translate("Custom update-script"), - translate("Custom update script to be used for updating your DDNS Provider.") ) -ush:depends("ipv4_service_name", "-") -ush:depends("ipv6_service_name", "-") -function ush.validate(self, value) - local url = uurl:formvalue(section) - - if (usev6:formvalue(section) == "0" and svc4:formvalue(section) ~= "-") or - (usev6:formvalue(section) == "1" and svc6:formvalue(section) ~= "-") then - return "" -- suppress validate error - elseif not value then - if not url or not (#url > 0) then - return nil, err_tab_basic(self) .. translate("missing / required") - else - return "" -- suppress validate error / update_url is given - end - elseif (#url > 0) then - return nil, err_tab_basic(self) .. translate("either url or script could be set") - elseif not FS.access(value) then - return nil, err_tab_basic(self) .. translate("File not found") - end - return value -end - --- IPv4/IPv6 - domain -- ####################################################### -dom = ns:taboption("basic", Value, "domain", - translate("Hostname/Domain"), - translate("Replaces [DOMAIN] in Update-URL") ) -dom.rmempty = false -dom.placeholder = "mypersonaldomain.dyndns.org" -function dom.validate(self, value) - if not value - or not (#value > 0) - or not DTYP.hostname(value) then - return nil, err_tab_basic(self) .. translate("invalid - Sample") .. ": 'mypersonaldomain.dyndns.org'" - else - return value - end -end - --- IPv4/IPv6 - username -- ##################################################### -user = ns:taboption("basic", Value, "username", - translate("Username"), - translate("Replaces [USERNAME] in Update-URL") ) -user.rmempty = false -function user.validate(self, value) - if not value then - return nil, err_tab_basic(self) .. translate("missing / required") - end - return value -end - --- IPv4/IPv6 - password -- ##################################################### -pw = ns:taboption("basic", Value, "password", - translate("Password"), - translate("Replaces [PASSWORD] in Update-URL") ) -pw.rmempty = false -pw.password = true -function pw.validate(self, value) - if not value then - return nil, err_tab_basic(self) .. translate("missing / required") - end - return value -end - --- IPv4/IPv6 - use_https (NEW) -- ############################################## -if has_ssl or ( ( m:get(section, "use_https") or "0" ) == "1" ) then - https = ns:taboption("basic", Flag, "use_https", - translate("Use HTTP Secure") ) - https.orientation = "horizontal" - https.rmempty = false -- force validate function - function https.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not has_ssl and value == "1" then - self.description = bold_on .. font_red .. - translate("HTTPS not supported") .. font_off .. "<br />" .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("Enable secure communication with DDNS provider") - end - return value - end - function https.parse(self, section) - DDNS.flag_parse(self, section) - end - function https.validate(self, value) - if (value == "1" and has_ssl ) or value == "0" then return value end - return nil, err_tab_basic(self) .. translate("HTTPS not supported") .. " !" - end - function https.write(self, section, value) - if value == "1" then - return self.map:set(section, self.option, value) - else - self.map:del(section, "cacert") - return self.map:del(section, self.option) - end - end -end - --- IPv4/IPv6 - cacert (NEW) -- ################################################# -if has_ssl then - cert = ns:taboption("basic", Value, "cacert", - translate("Path to CA-Certificate"), - translate("directory or path/file") .. "<br />" .. - translate("or") .. bold_on .. " IGNORE " .. bold_off .. - translate("to run HTTPS without verification of server certificates (insecure)") ) - cert:depends("use_https", "1") - cert.rmempty = false -- force validate function - cert.default = "/etc/ssl/certs" - function cert.validate(self, value) - if https:formvalue(section) == "0" then - return "" -- supress validate error if NOT https - end - if value then -- otherwise errors in datatype check - if DTYP.directory(value) - or DTYP.file(value) - or value == "IGNORE" then - return value - end - end - return nil, err_tab_basic(self) .. - translate("file or directory not found or not 'IGNORE'") .. " !" - end -end - --- TAB: Advanced ################################################################################## --- IPv4 - ip_source -- ######################################################### -src4 = ns:taboption("advanced", ListValue, "ipv4_source", - translate("IP address source") .. " [IPv4]", - translate("Defines the source to read systems IPv4-Address from, that will be send to the DDNS provider") ) -src4:depends("use_ipv6", "0") -- IPv4 selected -src4.default = "network" -src4:value("network", translate("Network")) -src4:value("web", translate("URL")) -src4:value("interface", translate("Interface")) -src4:value("script", translate("Script")) -function src4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_source") -end -function src4.validate(self, value) - if usev6:formvalue(section) == "1" then - return "" -- ignore on IPv6 selected - elseif not _verify_ip_source() then - return nil, err_tab_adv(self) .. - translate("can not detect local IP. Please select a different Source combination") - else - return value - end -end -function src4.write(self, section, value) - if usev6:formvalue(section) == "1" then - return true -- ignore on IPv6 selected - elseif value == "network" then - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "web" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "interface" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_url") - self.map:del(section, "ip_script") - elseif value == "script" then - self.map:del(section, "ip_network") - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - end - self.map:del(section, self.option) -- delete "ipv4_source" helper - return self.map:set(section, "ip_source", value) -- and write "ip_source -end - --- IPv6 - ip_source -- ######################################################### -src6 = ns:taboption("advanced", ListValue, "ipv6_source", - translate("IP address source") .. " [IPv6]", - translate("Defines the source to read systems IPv6-Address from, that will be send to the DDNS provider") ) -src6:depends("use_ipv6", 1) -- IPv6 selected -src6.default = "network" -src6:value("network", translate("Network")) -src6:value("web", translate("URL")) -src6:value("interface", translate("Interface")) -src6:value("script", translate("Script")) -if not has_ipv6 then - src6.description = err_ipv6_other -end -function src6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_source") -end -function src6.validate(self, value) - if usev6:formvalue(section) == "0" then - return "" -- ignore on IPv4 selected - elseif not has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - elseif not _verify_ip_source() then - return nil, err_tab_adv(self) .. - translate("can not detect local IP. Please select a different Source combination") - else - return value - end -end -function src6.write(self, section, value) - if usev6:formvalue(section) == "0" then - return true -- ignore on IPv4 selected - elseif value == "network" then - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "web" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "interface" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_url") - self.map:del(section, "ip_script") - elseif value == "script" then - self.map:del(section, "ip_network") - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - end - self.map:del(section, self.option) -- delete "ipv4_source" helper - return self.map:set(section, "ip_source", value) -- and write "ip_source -end - --- IPv4 - ip_network (default "wan") -- ######################################## -ipn4 = ns:taboption("advanced", ListValue, "ipv4_network", - translate("Network") .. " [IPv4]", - translate("Defines the network to read systems IPv4-Address from") ) -ipn4:depends("ipv4_source", "network") -ipn4.default = "wan" -WADM.cbi_add_networks(ipn4) -function ipn4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_network") -end -function ipn4.validate(self, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "network" then - -- ignore if IPv6 selected OR - -- ignore everything except "network" - return "" - else - return value - end -end -function ipn4.write(self, section, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "network" then - -- ignore if IPv6 selected OR - -- ignore everything except "network" - return true - else - -- set also as "interface" for monitoring events changes/hot-plug - self.map:set(section, "interface", value) - self.map:del(section, self.option) -- delete "ipv4_network" helper - return self.map:set(section, "ip_network", value) -- and write "ip_network" - end -end - --- IPv6 - ip_network (default "wan6") -- ####################################### -ipn6 = ns:taboption("advanced", ListValue, "ipv6_network", - translate("Network") .. " [IPv6]" ) -ipn6:depends("ipv6_source", "network") -ipn6.default = "wan6" -WADM.cbi_add_networks(ipn6) -if has_ipv6 then - ipn6.description = translate("Defines the network to read systems IPv6-Address from") -else - ipn6.description = err_ipv6_other -end -function ipn6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_network") -end -function ipn6.validate(self, value) - if usev6:formvalue(section) == "0" - or src6:formvalue(section) ~= "network" then - -- ignore if IPv4 selected OR - -- ignore everything except "network" - return "" - elseif has_ipv6 then - return value - else - return nil, err_tab_adv(self) .. err_ipv6_plain - end -end -function ipn6.write(self, section, value) - if usev6:formvalue(section) == "0" - or src6:formvalue(section) ~= "network" then - -- ignore if IPv4 selected OR - -- ignore everything except "network" - return true - else - -- set also as "interface" for monitoring events changes/hotplug - self.map:set(section, "interface", value) - self.map:del(section, self.option) -- delete "ipv6_network" helper - return self.map:set(section, "ip_network", value) -- and write "ip_network" - end -end - --- IPv4 - ip_url (default "checkip.dyndns.com") -- ############################# -iurl4 = ns:taboption("advanced", Value, "ipv4_url", - translate("URL to detect") .. " [IPv4]", - translate("Defines the Web page to read systems IPv4-Address from") ) -iurl4:depends("ipv4_source", "web") -iurl4.default = "http://checkip.dyndns.com" -function iurl4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_url") -end -function iurl4.validate(self, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "web" then - -- ignore if IPv6 selected OR - -- ignore everything except "web" - return "" - elseif not value or #value == 0 then - return nil, err_tab_adv(self) .. translate("missing / required") - end - - local url = DDNS.parse_url(value) - if not (url.scheme == "http" or url.scheme == "https") then - return nil, err_tab_adv(self) .. translate("must start with 'http://'") - elseif not url.host then - return nil, err_tab_adv(self) .. "<HOST> " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[>/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_adv(self) .. translate("can not resolve host: ") .. url.host - else - return value - end -end -function iurl4.write(self, section, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "web" then - -- ignore if IPv6 selected OR - -- ignore everything except "web" - return true - else - self.map:del(section, self.option) -- delete "ipv4_url" helper - return self.map:set(section, "ip_url", value) -- and write "ip_url" - end -end - --- IPv6 - ip_url (default "checkipv6.dyndns.com") -- ########################### -iurl6 = ns:taboption("advanced", Value, "ipv6_url", - translate("URL to detect") .. " [IPv6]" ) -iurl6:depends("ipv6_source", "web") -iurl6.default = "http://checkipv6.dyndns.com" -if has_ipv6 then - iurl6.description = translate("Defines the Web page to read systems IPv6-Address from") -else - iurl6.description = err_ipv6_other -end -function iurl6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_url") -end -function iurl6.validate(self, value) - if usev6:formvalue(section) == "0" - or src6:formvalue(section) ~= "web" then - -- ignore if IPv4 selected OR - -- ignore everything except "web" - return "" - elseif not has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - elseif not value or #value == 0 then - return nil, err_tab_adv(self) .. translate("missing / required") - end - - local url = DDNS.parse_url(value) - if not (url.scheme == "http" or url.scheme == "https") then - return nil, err_tab_adv(self) .. translate("must start with 'http://'") - elseif not url.host then - return nil, err_tab_adv(self) .. "<HOST> " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[>/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_adv(self) .. translate("can not resolve host: ") .. url.host - else - return value - end -end -function iurl6.write(self, section, value) - if usev6:formvalue(section) == "0" - or src6:formvalue(section) ~= "web" then - -- ignore if IPv4 selected OR - -- ignore everything except "web" - return true - else - self.map:del(section, self.option) -- delete "ipv6_url" helper - return self.map:set(section, "ip_url", value) -- and write "ip_url" - end -end - --- IPv4 + IPv6 - ip_interface -- ############################################### -ipi = ns:taboption("advanced", ListValue, "ip_interface", - translate("Interface"), - translate("Defines the interface to read systems IP-Address from") ) -ipi:depends("ipv4_source", "interface") -- IPv4 -ipi:depends("ipv6_source", "interface") -- or IPv6 -for _, v in pairs(SYS.net.devices()) do - -- show only interface set to a network - -- and ignore loopback - net = WADM.iface_get_network(v) - if net and net ~= "loopback" then - ipi:value(v) - end -end -function ipi.validate(self, value) - if (usev6:formvalue(section) == "0" and src4:formvalue(section) ~= "interface") - or (usev6:formvalue(section) == "1" and src6:formvalue(section) ~= "interface") then - return "" - else - return value - end -end -function ipi.write(self, section, value) - if (usev6:formvalue(section) == "0" and src4:formvalue(section) ~= "interface") - or (usev6:formvalue(section) == "1" and src6:formvalue(section) ~= "interface") then - return true - else - -- get network from device to - -- set also as "interface" for monitoring events changes/hotplug - local net = WADM.iface_get_network(value) - self.map:set(section, "interface", net) - return self.map:set(section, self.option, value) - end -end - --- IPv4 + IPv6 - ip_script (NEW) -- ############################################ -ips = ns:taboption("advanced", Value, "ip_script", - translate("Script"), - translate("User defined script to read systems IP-Address") ) -ips:depends("ipv4_source", "script") -- IPv4 -ips:depends("ipv6_source", "script") -- or IPv6 -ips.rmempty = false -ips.placeholder = "/path/to/script.sh" -function ips.validate(self, value) - local split - if value then split = UTIL.split(value, " ") end - - if (usev6:formvalue(section) == "0" and src4:formvalue(section) ~= "script") - or (usev6:formvalue(section) == "1" and src6:formvalue(section) ~= "script") then - return "" - elseif not value or not (#value > 0) or not FS.access(split[1], "x") then - return nil, err_tab_adv(self) .. - translate("not found or not executable - Sample: '/path/to/script.sh'") - else - return value - end -end -function ips.write(self, section, value) - if (usev6:formvalue(section) == "0" and src4:formvalue(section) ~= "script") - or (usev6:formvalue(section) == "1" and src6:formvalue(section) ~= "script") then - return true - else - return self.map:set(section, self.option, value) - end -end - --- IPv4 - interface - default "wan" -- ######################################### --- event network to monitor changes/hotplug/dynamic_dns_updater.sh --- only needs to be set if "ip_source"="web" or "script" --- if "ip_source"="network" or "interface" we use their network -eif4 = ns:taboption("advanced", ListValue, "ipv4_interface", - translate("Event Network") .. " [IPv4]", - translate("Network on which the ddns-updater scripts will be started") ) -eif4:depends("ipv4_source", "web") -eif4:depends("ipv4_source", "script") -eif4.default = "wan" -WADM.cbi_add_networks(eif4) -function eif4.cfgvalue(self, section) - return DDNS.read_value(self, section, "interface") -end -function eif4.validate(self, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) == "network" - or src4:formvalue(section) == "interface" then - return "" -- ignore IPv6, network, interface - else - return value - end -end -function eif4.write(self, section, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) == "network" - or src4:formvalue(section) == "interface" then - return true -- ignore IPv6, network, interface - else - self.map:del(section, self.option) -- delete "ipv4_interface" helper - return self.map:set(section, "interface", value) -- and write "interface" - end -end - --- IPv6 - interface (NEW) - default "wan6" -- ################################## --- event network to monitor changes/hotplug (NEW) --- only needs to be set if "ip_source"="web" or "script" --- if "ip_source"="network" or "interface" we use their network -eif6 = ns:taboption("advanced", ListValue, "ipv6_interface", - translate("Event Network") .. " [IPv6]" ) -eif6:depends("ipv6_source", "web") -eif6:depends("ipv6_source", "script") -eif6.default = "wan6" -WADM.cbi_add_networks(eif6) -if not has_ipv6 then - eif6.description = err_ipv6_other -else - eif6.description = translate("Network on which the ddns-updater scripts will be started") -end -function eif6.cfgvalue(self, section) - return DDNS.read_value(self, section, "interface") -end -function eif6.validate(self, value) - if usev6:formvalue(section) == "0" - or src4:formvalue(section) == "network" - or src4:formvalue(section) == "interface" then - return "" -- ignore IPv4, network, interface - elseif not has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - else - return value - end -end -function eif6.write(self, section, value) - if usev6:formvalue(section) == "0" - or src4:formvalue(section) == "network" - or src4:formvalue(section) == "interface" then - return true -- ignore IPv4, network, interface - else - self.map:del(section, self.option) -- delete "ipv6_interface" helper - return self.map:set(section, "interface", value) -- and write "interface" - end -end - --- IPv4 + IPv6 - force_ipversion (NEW) -- ###################################### --- optional to force wget/curl and host to use only selected IP version --- command parameter "-4" or "-6" -if has_force or ( ( m:get(section, "force_ipversion") or "0" ) ~= "0" ) then - fipv = ns:taboption("advanced", Flag, "force_ipversion", - translate("Force IP Version") ) - fipv.orientation = "horizontal" - function fipv.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not has_force and value ~= "0" then - self.description = bold_on .. font_red .. - translate("Force IP Version not supported") .. font_off .. "<br />" .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("OPTIONAL: Force the usage of pure IPv4/IPv6 only communication.") - end - return value - end - function fipv.validate(self, value) - if (value == "1" and has_force) or value == "0" then return value end - return nil, err_tab_adv(self) .. translate("Force IP Version not supported") - end - function fipv.parse(self, section) - DDNS.flag_parse(self, section) - end - function fipv.write(self, section, value) - if value == "1" then - return self.map:set(section, self.option, value) - else - return self.map:del(section, self.option) - end - end -end - --- IPv4 + IPv6 - dns_server (NEW) -- ########################################### --- optional DNS Server to use resolving my IP if "ip_source"="web" -dns = ns:taboption("advanced", Value, "dns_server", - translate("DNS-Server"), - translate("OPTIONAL: Use non-default DNS-Server to detect 'Registered IP'.") .. "<br />" .. - translate("Format: IP or FQDN")) -dns.placeholder = "mydns.lan" -function dns.validate(self, value) - -- if .datatype is set, then it is checked before calling this function - if not value then - return "" -- ignore on empty - elseif not DTYP.host(value) then - return nil, err_tab_adv(self) .. translate("use hostname, FQDN, IPv4- or IPv6-Address") - else - local ipv6 = usev6:formvalue(section) - local force = (fipv) and fipv:formvalue(section) or "0" - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_dns ]] .. - value .. [[ ]] .. ipv6 .. [[ ]] .. force - 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") - elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect") - elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched") - else return nil, err_tab_adv(self) .. translate("unspecific error") - end - end -end - --- IPv4 + IPv6 - force_dnstcp (NEW) -- ######################################### -if has_dnstcp or ( ( m:get(section, "force_dnstcp") or "0" ) ~= "0" ) then - tcp = ns:taboption("advanced", Flag, "force_dnstcp", - translate("Force TCP on DNS") ) - tcp.orientation = "horizontal" - function tcp.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not has_dnstcp and value ~= "0" then - self.description = bold_on .. font_red .. - translate("DNS requests via TCP not supported") .. font_off .. "<br />" .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("OPTIONAL: Force the use of TCP instead of default UDP on DNS requests.") - end - return value - end - function tcp.validate(self, value) - if (value == "1" and has_dnstcp ) or value == "0" then - return value - end - return nil, err_tab_adv(self) .. translate("DNS requests via TCP not supported") - end - function tcp.parse(self, section) - DDNS.flag_parse(self, section) - end -end - --- IPv4 + IPv6 - proxy (NEW) -- ################################################ --- optional Proxy to use for http/https requests [user:password@]proxyhost[:port] -if has_proxy or ( ( m:get(section, "proxy") or "" ) ~= "" ) then - pxy = ns:taboption("advanced", Value, "proxy", - translate("PROXY-Server") ) - pxy.placeholder="user:password@myproxy.lan:8080" - function pxy.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not has_proxy and value ~= "" then - self.description = bold_on .. font_red .. - translate("PROXY-Server not supported") .. font_off .. "<br />" .. - translate("please remove entry") .. "!" .. bold_off - else - self.description = translate("OPTIONAL: Proxy-Server for detection and updates.") .. "<br />" .. - translate("Format") .. ": " .. bold_on .. "[user:password@]proxyhost:port" .. bold_off .. "<br />" .. - translate("IPv6 address must be given in square brackets") .. ": " .. - bold_on .. " [2001:db8::1]:8080" .. bold_off - end - return value - end - function pxy.validate(self, value) - -- if .datatype is set, then it is checked before calling this function - if not value then - return "" -- ignore on empty - elseif has_proxy then - local ipv6 = usev6:formvalue(section) or "0" - local force = (fipv) and fipv:formvalue(section) or "0" - local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_proxy ]] .. - value .. [[ ]] .. ipv6 .. [[ ]] .. force - 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") - elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect") - elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched") - elseif ret == 5 then return nil, err_tab_adv(self) .. translate("proxy port missing") - else return nil, err_tab_adv(self) .. translate("unspecific error") - end - else - return nil, err_tab_adv(self) .. translate("PROXY-Server not supported") - end - end -end - --- use_syslog -- ############################################################### -slog = ns:taboption("advanced", ListValue, "use_syslog", - translate("Log to syslog"), - translate("Writes log messages to syslog. Critical Errors will always be written to syslog.") ) -slog.default = "2" -slog:value("0", translate("No logging")) -slog:value("1", translate("Info")) -slog:value("2", translate("Notice")) -slog:value("3", translate("Warning")) -slog:value("4", translate("Error")) - --- use_logfile (NEW) -- ######################################################## -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"]] ) -logf.orientation = "horizontal" -logf.rmempty = false -- we want to save in /etc/config/ddns file on "0" because -logf.default = "1" -- if not defined write to log by default -function logf.parse(self, section) - DDNS.flag_parse(self, section) -end - --- TAB: Timer ##################################################################################### --- check_interval -- ########################################################### -ci = ns:taboption("timer", Value, "check_interval", - translate("Check Interval") ) -ci.template = "ddns/detail_value" -ci.default = 10 -ci.rmempty = false -- validate ourselves for translatable error messages -function ci.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 1 then - return nil, err_tab_timer(self) .. translate("minimum value 5 minutes == 300 seconds") - end - - local secs = DDNS.calc_seconds(value, cu:formvalue(section)) - if secs >= 300 then - return value - else - return nil, err_tab_timer(self) .. translate("minimum value 5 minutes == 300 seconds") - end -end -function ci.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(value, cu:formvalue(section)) - if secs ~= 600 then --default 10 minutes - return self.map:set(section, self.option, value) - else - self.map:del(section, "check_unit") - return self.map:del(section, self.option) - end -end - --- check_unit -- ############################################################### -cu = ns:taboption("timer", ListValue, "check_unit", "not displayed, but needed otherwise error", - translate("Interval to check for changed IP" .. "<br />" .. - "Values below 5 minutes == 300 seconds are not supported") ) -cu.template = "ddns/detail_lvalue" -cu.default = "minutes" -cu.rmempty = false -- want to control write process -cu:value("seconds", translate("seconds")) -cu:value("minutes", translate("minutes")) -cu:value("hours", translate("hours")) ---cu:value("days", translate("days")) -function cu.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(ci:formvalue(section), value) - if secs ~= 600 then --default 10 minutes - return self.map:set(section, self.option, value) - else - return true - end -end - --- force_interval (modified) -- ################################################ -fi = ns:taboption("timer", Value, "force_interval", - translate("Force Interval") ) -fi.template = "ddns/detail_value" -fi.default = 72 -- see dynamic_dns_updater.sh script -fi.rmempty = false -- validate ourselves for translatable error messages -function fi.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 0 then - return nil, err_tab_timer(self) .. translate("minimum value '0'") - end - - local force_s = DDNS.calc_seconds(value, fu:formvalue(section)) - if force_s == 0 then - return value - end - - local ci_value = ci:formvalue(section) - if not DTYP.uinteger(ci_value) then - return "" -- ignore because error in check_interval above - end - - local check_s = DDNS.calc_seconds(ci_value, cu:formvalue(section)) - if force_s >= check_s then - return value - end - - return nil, err_tab_timer(self) .. translate("must be greater or equal 'Check Interval'") -end -function fi.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(value, fu:formvalue(section)) - if secs ~= 259200 then --default 72 hours == 3 days - return self.map:set(section, self.option, value) - else - self.map:del(section, "force_unit") - return self.map:del(section, self.option) - end -end - --- force_unit -- ############################################################### -fu = ns:taboption("timer", ListValue, "force_unit", "not displayed, but needed otherwise error", - translate("Interval to force updates send to DDNS Provider" .. "<br />" .. - "Setting this parameter to 0 will force the script to only run once" .. "<br />" .. - "Values lower 'Check Interval' except '0' are not supported") ) -fu.template = "ddns/detail_lvalue" -fu.default = "hours" -fu.rmempty = false -- want to control write process ---fu:value("seconds", translate("seconds")) -fu:value("minutes", translate("minutes")) -fu:value("hours", translate("hours")) -fu:value("days", translate("days")) -function fu.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(fi:formvalue(section), value) - if secs ~= 259200 and secs ~= 0 then --default 72 hours == 3 days - return self.map:set(section, self.option, value) - else - return true - end -end - --- retry_count (NEW) -- ######################################################## -rc = ns:taboption("timer", Value, "retry_count", - translate("Error Retry Counter"), - translate("On Error the script will stop execution after given number of retrys") ) -rc.default = 5 -rc.rmempty = false -- validate ourselves for translatable error messages -function rc.validate(self, value) - if not DTYP.uinteger(value) then - return nil, err_tab_timer(self) .. translate("minimum value '0'") - else - return value - end -end -function rc.write(self, section, value) - -- simulate rmempty=true remove default - if tonumber(value) ~= self.default then - return self.map:set(section, self.option, value) - else - return self.map:del(section, self.option) - end -end - --- retry_interval -- ########################################################### -ri = ns:taboption("timer", Value, "retry_interval", - translate("Error Retry Interval") ) -ri.template = "ddns/detail_value" -ri.default = 60 -ri.rmempty = false -- validate ourselves for translatable error messages -function ri.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 1 then - return nil, err_tab_timer(self) .. translate("minimum value '1'") - else - return value - end -end -function ri.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(value, ru:formvalue(section)) - if secs ~= 60 then --default 60seconds - return self.map:set(section, self.option, value) - else - self.map:del(section, "retry_unit") - return self.map:del(section, self.option) - end -end - --- retry_unit -- ############################################################### -ru = ns:taboption("timer", ListValue, "retry_unit", "not displayed, but needed otherwise error", - translate("On Error the script will retry the failed action after given time") ) -ru.template = "ddns/detail_lvalue" -ru.default = "seconds" -ru.rmempty = false -- want to control write process -ru:value("seconds", translate("seconds")) -ru:value("minutes", translate("minutes")) ---ru:value("hours", translate("hours")) ---ru:value("days", translate("days")) -function ru.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(ri:formvalue(section), value) - if secs ~= 60 then --default 60seconds - return self.map:set(section, self.option, value) - else - return true -- will be deleted by retry_interval - end -end - --- TAB: LogView (NEW) ############################################################################# -lv = ns:taboption("logview", DummyValue, "_logview") -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" - if FS.access(lfile) then - return lfile .. "\n" .. translate("Please press [Read] button") - end - return lfile .. "\n" .. translate("File not found or empty") -end - -return m diff --git a/applications/luci-ddns/luasrc/model/cbi/ddns/hints.lua b/applications/luci-ddns/luasrc/model/cbi/ddns/hints.lua deleted file mode 100644 index dfbc7468cd..0000000000 --- a/applications/luci-ddns/luasrc/model/cbi/ddns/hints.lua +++ /dev/null @@ -1,147 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local CTRL = require "luci.controller.ddns" -- this application's controller -local DISP = require "luci.dispatcher" -local SYS = require "luci.sys" -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- check supported options -- ################################################## --- saved to local vars here because doing multiple os calls slow down the system -has_ssl = DDNS.check_ssl() -- HTTPS support -has_proxy = DDNS.check_proxy() -- Proxy support -has_dnstcp = DDNS.check_bind_host() -- DNS TCP support -need_update = CTRL.update_needed() -- correct ddns-scripts version - --- html constants -font_red = [[<font color="red">]] -font_off = [[</font>]] -bold_on = [[<strong>]] -bold_off = [[</strong>]] - --- cbi-map definition -- ####################################################### -m = Map("ddns") - --- first need to close <a> from cbi map template our <a> closed by template -m.title = [[</a><a href="]] .. DISP.build_url("admin", "services", "ddns") .. [[">]] .. - translate("Dynamic DNS") - -m.description = translate("Dynamic DNS allows that your router can be reached with " .. - "a fixed hostname while having a dynamically changing " .. - "IP address.") - -m.redirect = DISP.build_url("admin", "services", "ddns") - --- SimpleSection definition -- ################################################# --- show Hints to optimize installation and script usage -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 -if need_update then - local dv = s:option(DummyValue, "_update_needed") - dv.titleref = DISP.build_url("admin", "system", "packages") - dv.rawhtml = true - dv.title = font_red .. bold_on .. - translate("Software update required") .. bold_off .. font_off - dv.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") .. - "<br />" .. - translate("Please update to the current version!") -end - --- DDNS Service disabled -if not SYS.init.enabled("ddns") then - local dv = s:option(DummyValue, "_not_enabled") - dv.titleref = DISP.build_url("admin", "system", "startup") - dv.rawhtml = true - dv.title = bold_on .. - translate("DDNS Autostart disabled") .. bold_off - dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" .. - "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" ) -end - --- No IPv6 support -if not DDNS.check_ipv6() then - local dv = s:option(DummyValue, "_no_ipv6") - dv.titleref = 'http://www.openwrt.org" target="_blank' - dv.rawhtml = true - dv.title = bold_on .. - translate("IPv6 not supported") .. bold_off - dv.value = translate("IPv6 is currently not (fully) supported by this system" .. "<br />" .. - "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "<br />" .. - "or update your system to the latest OpenWrt Release") -end - --- No HTTPS support -if not has_ssl then - local dv = s:option(DummyValue, "_no_https") - dv.titleref = DISP.build_url("admin", "system", "packages") - dv.rawhtml = true - dv.title = bold_on .. - translate("HTTPS not supported") .. bold_off - dv.value = translate("Neither GNU Wget with SSL nor cURL installed to support updates via HTTPS protocol.") .. - "<br />- " .. - translate("You should install GNU Wget with SSL (prefered) or cURL package.") .. - "<br />- " .. - translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") -end - --- cURL without proxy support -if has_ssl and not has_proxy then - local dv = s:option(DummyValue, "_no_proxy") - dv.titleref = DISP.build_url("admin", "system", "packages") - dv.rawhtml = true - dv.title = bold_on .. - translate("cURL without Proxy Support") .. bold_off - dv.value = translate("cURL is installed, but libcurl was compiled without proxy support.") .. - "<br />- " .. - translate("You should install GNU Wget with SSL or replace libcurl.") .. - "<br />- " .. - translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") -end - --- "Force IP Version not supported" -if not (has_ssl and has_dnstcp) then - local dv = s:option(DummyValue, "_no_force_ip") - dv.titleref = DISP.build_url("admin", "system", "packages") - dv.rawhtml = true - dv.title = bold_on .. - 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 has_ssl then - value = value .. "<br />- " .. - translate("You should install GNU Wget with SSL (prefered) or cURL package.") - end - if not has_dnstcp then - value = value .. "<br />- " .. - translate("You should install BIND host package for DNS requests.") - end - dv.value = value -end - --- "DNS requests via TCP not supported" -if not has_dnstcp then - local dv = s:option(DummyValue, "_no_dnstcp") - dv.titleref = DISP.build_url("admin", "system", "packages") - dv.rawhtml = true - dv.title = bold_on .. - translate("DNS requests via TCP not supported") .. bold_off - dv.value = translate("BusyBox's nslookup does 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.") -end - -return m diff --git a/applications/luci-ddns/luasrc/model/cbi/ddns/overview.lua b/applications/luci-ddns/luasrc/model/cbi/ddns/overview.lua deleted file mode 100644 index 5d24ee5a04..0000000000 --- a/applications/luci-ddns/luasrc/model/cbi/ddns/overview.lua +++ /dev/null @@ -1,256 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -local NXFS = require "nixio.fs" -local CTRL = require "luci.controller.ddns" -- this application's controller -local DISP = require "luci.dispatcher" -local HTTP = require "luci.http" -local SYS = require "luci.sys" -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- show hints ? -show_hints = not (DDNS.check_ipv6() -- IPv6 support - and DDNS.check_ssl() -- HTTPS support - and DDNS.check_proxy() -- Proxy support - and DDNS.check_bind_host() -- DNS TCP support - ) -need_update = CTRL.update_needed() -- correct ddns-scripts version - --- html constants -font_red = [[<font color="red">]] -font_off = [[</font>]] -bold_on = [[<strong>]] -bold_off = [[</strong>]] - --- cbi-map definition -- ####################################################### -m = Map("ddns") - --- first need to close <a> from cbi map template our <a> closed by template ---m.title = [[</a><a href="javascript:alert(']] .. CTRL.show_versions() ..[[')">]] .. --- translate("Dynamic DNS") -m.title = [[</a><a href="#" onclick="onclick_maptitle();">]] .. - translate("Dynamic DNS") - -m.description = translate("Dynamic DNS allows that your router can be reached with " .. - "a fixed hostname while having a dynamically changing " .. - "IP address.") - -m.on_after_commit = function(self) - if self.changed then -- changes ? - if SYS.init.enabled("ddns") then -- ddns service enabled, restart all - os.execute("/etc/init.d/ddns restart") - else -- ddns service disabled, send SIGHUP to running - os.execute("killall -1 dynamic_dns_updater.sh") - end - end -end - --- SimpleSection definiton -- ################################################## --- with all the JavaScripts we need for "a good Show" -a = m:section( SimpleSection ) -a.template = "ddns/overview_status" - --- SimpleSection definition -- ################################################# --- show Hints to optimize installation and script usage --- only show if service not enabled --- or no IPv6 support --- or not GNU Wget and not cURL (for https support) --- or not GNU Wget but cURL without proxy support --- or not BIND's host --- or ddns-scripts package need update -if show_hints or need_update or not SYS.init.enabled("ddns") then - s = m:section( SimpleSection, translate("Hints") ) - - -- 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") - dv.rawhtml = true - dv.title = font_red .. bold_on .. - translate("Software update required") .. bold_off .. font_off - dv.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") .. - "<br />" .. - translate("Please update to the current version!") - end - - -- DDNS Service disabled - if not SYS.init.enabled("ddns") then - local dv = s:option(DummyValue, "_not_enabled") - dv.titleref = DISP.build_url("admin", "system", "startup") - dv.rawhtml = true - dv.title = bold_on .. - translate("DDNS Autostart disabled") .. bold_off - dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" .. - "You can start/stop each configuration here. It will run until next reboot.") - end - - -- Show more hints on a separate page - if show_hints then - local dv = s:option(DummyValue, "_separate") - dv.titleref = DISP.build_url("admin", "services", "ddns", "hints") - dv.rawhtml = true - dv.title = bold_on .. - translate("Show more") .. bold_off - dv.value = translate("Follow this link" .. "<br />" .. - "You will find more hints to optimize your system to run DDNS scripts with all options") - end -end - --- TableSection definition -- ################################################## -ts = m:section( TypedSection, "service", - translate("Overview"), - translate("Below is a list of configured DDNS configurations and their current state." .. "<br />" .. - "If you want to send updates for IPv4 and IPv6 you need to define two separate Configurations " .. - "i.e. 'myddns_ipv4' and 'myddns_ipv6'") ) -ts.sectionhead = translate("Configuration") -ts.template = "cbi/tblsection" -ts.addremove = true -ts.extedit = DISP.build_url("admin", "services", "ddns", "detail", "%s") -function ts.create(self, name) - AbstractSection.create(self, name) - HTTP.redirect( self.extedit:format(name) ) -end - --- Domain and registered IP -- ################################################# -dom = ts:option(DummyValue, "_domainIP", - translate("Hostname/Domain") .. "<br />" .. translate("Registered IP") ) -dom.template = "ddns/overview_doubleline" -function dom.set_one(self, section) - local domain = self.map:get(section, "domain") or "" - if domain ~= "" then - return domain - else - return [[<em>]] .. translate("config error") .. [[</em>]] - end -end -function dom.set_two(self, section) - local domain = self.map:get(section, "domain") or "" - if domain == "" 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 ]] .. domain .. [[ ]] .. use_ipv6 .. - [[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp .. [[ ]] .. dnsserver - local ip = SYS.exec(command) - if ip == "" then ip = translate("no data") end - return ip -end - --- enabled -ena = ts:option( Flag, "enabled", - translate("Enabled")) -ena.template = "ddns/overview_enabled" -ena.rmempty = false -function ena.parse(self, section) - DDNS.flag_parse(self, section) -end - --- show PID and next update -upd = ts:option( DummyValue, "_update", - translate("Last Update") .. "<br />" .. translate("Next Update")) -upd.template = "ddns/overview_doubleline" -function upd.set_one(self, section) -- fill Last Update - -- get/validate last update - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp and cleared on reboot - lasttime = 0 - end - - -- no last update happen - if lasttime == 0 then - return translate("never") - - -- we read last update - else - -- calc last update - -- os.epoch - sys.uptime + lastupdate(uptime) - local epoch = os.time() - uptime + lasttime - -- use linux date to convert epoch - return DDNS.epoch2date(epoch) - end -end -function upd.set_two(self, section) -- fill Next Update - -- get enabled state - local enabled = tonumber(self.map:get(section, "enabled") or 0) - local datenext = translate("unknown error") -- formatted date of next update - - -- get force seconds - local force_interval = tonumber(self.map:get(section, "force_interval") or 72) - local force_unit = self.map:get(section, "force_unit") or "hours" - local force_seconds = DDNS.calc_seconds(force_interval, force_unit) - - -- get last update and get/validate PID - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp and cleared on reboot - lasttime = 0 - end - local pid = DDNS.get_pid(section) - - -- calc next update - if lasttime > 0 then - local epoch = os.time() - uptime + lasttime + force_seconds - -- use linux date to convert epoch - datelast = DDNS.epoch2date(epoch) - end - - -- process running but update needs to happen - if pid > 0 and ( lasttime + force_seconds - uptime ) < 0 then - datenext = translate("Verify") - - -- run once - elseif force_seconds == 0 then - datenext = translate("Run once") - - -- no process running and NOT enabled - elseif pid == 0 and enabled == 0 then - datenext = translate("Disabled") - - -- no process running and NOT - elseif pid == 0 and enabled ~= 0 then - datenext = translate("Stopped") - end - - return datenext -end - --- start/stop button -btn = ts:option( Button, "_startstop", - translate("Process ID") .. "<br />" .. translate("Start / Stop") ) -btn.template = "ddns/overview_startstop" -function btn.cfgvalue(self, section) - local pid = DDNS.get_pid(section) - if pid > 0 then - btn.inputtitle = "PID: " .. pid - btn.inputstyle = "reset" - btn.disabled = false - elseif (self.map:get(section, "enabled") or "0") ~= "0" then - btn.inputtitle = translate("Start") - btn.inputstyle = "apply" - btn.disabled = false - else - btn.inputtitle = "----------" - btn.inputstyle = "button" - btn.disabled = true - end - return true -end - -return m diff --git a/applications/luci-ddns/luasrc/tools/ddns.lua b/applications/luci-ddns/luasrc/tools/ddns.lua deleted file mode 100644 index ad7b5e86f2..0000000000 --- a/applications/luci-ddns/luasrc/tools/ddns.lua +++ /dev/null @@ -1,295 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -shared module for luci-app-ddns -Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> - -function parse_url copied from https://svn.nmap.org/nmap/nselib/url.lua -Parses a URL and returns a table with all its parts according to RFC 2396. -@author Diego Nehab @author Eddie Bell <ejlbell@gmail.com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.tools.ddns", package.seeall) - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local OPKG = require "luci.model.ipkg" -local UCI = require "luci.model.uci" -local SYS = require "luci.sys" -local UTIL = require "luci.util" - --- function to calculate seconds from given interval and unit -function calc_seconds(interval, unit) - if not tonumber(interval) then - return nil - elseif unit == "days" then - return (tonumber(interval) * 86400) -- 60 sec * 60 min * 24 h - elseif unit == "hours" then - return (tonumber(interval) * 3600) -- 60 sec * 60 min - elseif unit == "minutes" then - return (tonumber(interval) * 60) -- 60 sec - elseif unit == "seconds" then - return tonumber(interval) - else - return nil - end -end - --- check if IPv6 supported by OpenWrt -function check_ipv6() - return NXFS.access("/proc/net/ipv6_route") - and NXFS.access("/usr/sbin/ip6tables") -end - --- check if Wget with SSL support or cURL installed -function check_ssl() - if (SYS.call([[ grep -iq "\+ssl" /usr/bin/wget 2>/dev/null ]]) == 0) then - return true - else - return NXFS.access("/usr/bin/curl") - end -end - --- check if Wget with SSL or cURL with proxy support installed -function check_proxy() - -- we prefere GNU Wget for communication - if (SYS.call([[ grep -iq "\+ssl" /usr/bin/wget 2>/dev/null ]]) == 0) then - return true - - -- if not installed cURL must support proxy - elseif NXFS.access("/usr/bin/curl") then - return (SYS.call([[ grep -iq all_proxy /usr/lib/libcurl.so* 2>/dev/null ]]) == 0) - - -- only BusyBox Wget is installed - else - return NXFS.access("/usr/bin/wget") - end -end - --- check if BIND host installed -function check_bind_host() - return NXFS.access("/usr/bin/host") -end - --- convert epoch date to given format -function epoch2date(epoch, format) - if not format or #format < 2 then - local uci = UCI.cursor() - format = uci:get("ddns", "global", "date_format") or "%F %R" - uci:unload("ddns") - end - format = format:gsub("%%n", "<br />") -- replace newline - format = format:gsub("%%t", " ") -- replace tab - return os.date(format, epoch) -end - --- read lastupdate from [section].update file -function get_lastupd(section) - local uci = UCI.cursor() - local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns" - local etime = tonumber(NXFS.readfile("%s/%s.update" % { run_dir, section } ) or 0 ) - uci:unload("ddns") - return etime -end - --- read PID from run file and verify if still running -function get_pid(section) - local uci = UCI.cursor() - local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns" - local pid = tonumber(NXFS.readfile("%s/%s.pid" % { run_dir, section } ) or 0 ) - if pid > 0 and not NX.kill(pid, 0) then - pid = 0 - end - uci:unload("ddns") - return pid -end - --- read version information for given package if installed -function ipkg_version(package) - if not package then - return nil - end - local info = OPKG.info(package) - local data = {} - local version = "" - local i = 0 - for k, v in pairs(info) do - if v.Package == package and v.Status.installed then - version = v.Version - i = i + 1 - end - end - if i > 1 then -- more then one valid record - return data - end - local sver = UTIL.split(version, "[%.%-]", nil, true) - data = { - version = version, - major = tonumber(sver[1]) or 0, - minor = tonumber(sver[2]) or 0, - patch = tonumber(sver[3]) or 0, - build = tonumber(sver[4]) or 0 - } - return data -end - --- replacement of build-in read of UCI option --- modified AbstractValue.cfgvalue(self, section) from cbi.lua --- needed to read from other option then current value definition -function read_value(self, section, option) - local value - if self.tag_error[section] then - value = self:formvalue(section) - else - value = self.map:get(section, option) - end - - if not value then - return nil - elseif not self.cast or self.cast == type(value) then - return value - elseif self.cast == "string" then - if type(value) == "table" then - return value[1] - end - elseif self.cast == "table" then - return { value } - end -end - --- replacement of build-in Flag.parse of cbi.lua --- modified to mark section as changed if value changes --- current parse did not do this, but it is done AbstaractValue.parse() -function flag_parse(self, section) - local fexists = self.map:formvalue( - luci.cbi.FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option) - - if fexists then - local fvalue = self:formvalue(section) and self.enabled or self.disabled - local cvalue = self:cfgvalue(section) - if fvalue ~= self.default or (not self.optional and not self.rmempty) then - self:write(section, fvalue) - else - self:remove(section) - end - if (fvalue ~= cvalue) then self.section.changed = true end - else - self:remove(section) - self.section.changed = true - end -end - ------------------------------------------------------------------------------ --- copied from https://svn.nmap.org/nmap/nselib/url.lua --- @author Diego Nehab --- @author Eddie Bell <ejlbell@gmail.com> ---[[ - URI parsing, composition and relative URL resolution - LuaSocket toolkit. - Author: Diego Nehab - RCS ID: $Id: url.lua,v 1.37 2005/11/22 08:33:29 diego Exp $ - parse_query and build_query added For nmap (Eddie Bell <ejlbell@gmail.com>) -]]-- ---- --- Parses a URL and returns a table with all its parts according to RFC 2396. --- --- The following grammar describes the names given to the URL parts. --- <code> --- <url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment> --- <authority> ::= <userinfo>@<host>:<port> --- <userinfo> ::= <user>[:<password>] --- <path> :: = {<segment>/}<segment> --- </code> --- --- The leading <code>/</code> in <code>/<path></code> is considered part of --- <code><path></code>. --- @param url URL of request. --- @param default Table with default values for each field. --- @return A table with the following fields, where RFC naming conventions have --- been preserved: --- <code>scheme</code>, <code>authority</code>, <code>userinfo</code>, --- <code>user</code>, <code>password</code>, <code>host</code>, --- <code>port</code>, <code>path</code>, <code>params</code>, --- <code>query</code>, and <code>fragment</code>. ------------------------------------------------------------------------------ -function parse_url(url) --, default) - -- initialize default parameters - local parsed = {} --- for i,v in base.pairs(default or parsed) do --- parsed[i] = v --- end - - -- remove whitespace --- url = string.gsub(url, "%s", "") - -- get fragment - url = string.gsub(url, "#(.*)$", - function(f) - parsed.fragment = f - return "" - end) - -- get scheme. Lower-case according to RFC 3986 section 3.1. - url = string.gsub(url, "^([%w][%w%+%-%.]*)%:", - function(s) - parsed.scheme = string.lower(s); - return "" - end) - -- get authority - url = string.gsub(url, "^//([^/]*)", - function(n) - parsed.authority = n - return "" - end) - -- get query stringing - url = string.gsub(url, "%?(.*)", - function(q) - parsed.query = q - return "" - end) - -- get params - url = string.gsub(url, "%;(.*)", - function(p) - parsed.params = p - return "" - end) - -- path is whatever was left - parsed.path = url - - local authority = parsed.authority - if not authority then - return parsed - end - authority = string.gsub(authority,"^([^@]*)@", - function(u) - parsed.userinfo = u; - return "" - end) - authority = string.gsub(authority, ":([0-9]*)$", - function(p) - if p ~= "" then - parsed.port = p - end; - return "" - end) - if authority ~= "" then - parsed.host = authority - end - - local userinfo = parsed.userinfo - if not userinfo then - return parsed - end - userinfo = string.gsub(userinfo, ":([^:]*)$", - function(p) - parsed.password = p; - return "" - end) - parsed.user = userinfo - return parsed -end diff --git a/applications/luci-ddns/luasrc/view/admin_status/index/ddns.htm b/applications/luci-ddns/luasrc/view/admin_status/index/ddns.htm deleted file mode 100644 index 9791065083..0000000000 --- a/applications/luci-ddns/luasrc/view/admin_status/index/ddns.htm +++ /dev/null @@ -1 +0,0 @@ -<%+ddns/system_status%> diff --git a/applications/luci-ddns/luasrc/view/ddns/detail_logview.htm b/applications/luci-ddns/luasrc/view/ddns/detail_logview.htm deleted file mode 100644 index 494b7435cd..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/detail_logview.htm +++ /dev/null @@ -1,56 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ detail_logview.htm ++ --> -<script type="text/javascript">//<![CDATA[ - function onclick_logview(section, bottom) { - // get elements - var txt = document.getElementById("cbid.ddns." + section + "._logview.txt"); // TextArea - if ( !txt ) { return; } // security check - - XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "logview")%>/' + section, null, - function(x) { - if (x.responseText == "_nodata_") - txt.value = "<%:File not found or empty%>"; - else - txt.value = x.responseText; - if (bottom) - txt.scrollTop = txt.scrollHeight; - else - txt.scrollTop = 0; } - ); - } -//]]></script> - -<%+cbi/valueheader%> - -<br /> - -<% --- one button on top, one at the buttom -%> -<input class="cbi-button cbi-input-button" style="align: center; width: 100%" type="button" onclick="onclick_logview(this.name, false)" -<%= -attr("name", section) .. attr("id", cbid .. ".btn1") .. attr("value", self.inputtitle) -%> /> - -<br /><br /> - -<% --- set a readable style taken from openwrt theme for textarea#syslog --- in openwrt theme there are problems with a width of 100 so we check for theme and set to lower value -%> -<textarea style="width: <%if media == "/luci-static/openwrt.org" then%>98.7%<%else%>100%<%end%> ; min-height: 500px; border: 3px solid #cccccc; padding: 5px; font-family: monospace; resize: none;" wrap="off" readonly="readonly" -<%= -attr("name", cbid .. ".txt") .. attr("id", cbid .. ".txt") .. ifattr(self.rows, "rows") -%> > -<%-=pcdata(self:cfgvalue(section))-%> -</textarea> -<br /><br /> - -<% --- one button on top, one at the buttom -%> -<input class="cbi-button cbi-input-button" style="align: center; width: 100%" type="button" onclick="onclick_logview(this.name, true)" -<%= attr("name", section) .. attr("id", cbid .. ".btn2") .. attr("value", self.inputtitle) %> /> - -<%+cbi/valuefooter%> -<!-- ++ END ++ Dynamic DNS ++ detail_logview.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/detail_lvalue.htm b/applications/luci-ddns/luasrc/view/ddns/detail_lvalue.htm deleted file mode 100644 index d516837b2b..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/detail_lvalue.htm +++ /dev/null @@ -1,22 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ detail_lvalue.htm ++ --> -<!-- no value header to supress next line --> -  -<% if self.widget == "select" then %> - <select class="cbi-input-select" onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>> - <% for i, key in pairs(self.keylist) do -%> - <option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr(tostring(self:cfgvalue(section) or self.default) == key, "selected", "selected") %>><%=striptags(self.vallist[i])%></option> - <%- end %> - </select> -<% elseif self.widget == "radio" then - local c = 0 - for i, key in pairs(self.keylist) do - c = c + 1 -%> - <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked") %> /> - <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label> -<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %> <% else %><br /><% end %> -<% end end %> -<% end %> -<%+cbi/valuefooter%> -<!-- ++ END ++ Dynamic DNS ++ detail_lvalue.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/detail_value.htm b/applications/luci-ddns/luasrc/view/ddns/detail_value.htm deleted file mode 100644 index 7cb28e282e..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/detail_value.htm +++ /dev/null @@ -1,9 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ detail_value.htm ++ --> -<%+cbi/valueheader%> - <input type="text" class="cbi-input-text" style="width: 10em;" onchange="cbi_d_update(this.id)"<%= - attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) .. - ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") - %> /> -<!-- no value footer to supress next line --> -<!-- ++ END ++ Dynamic DNS ++ detail_value.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/overview_doubleline.htm b/applications/luci-ddns/luasrc/view/ddns/overview_doubleline.htm deleted file mode 100644 index 1d1b4be019..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/overview_doubleline.htm +++ /dev/null @@ -1,10 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ overview_doubleline.htm ++ --> -<%+cbi/valueheader%> - -<span id="<%=cbid%>.one"><%=self:set_one(section)%></span> -<br /> -<span id="<%=cbid%>.two"><%=self:set_two(section)%></span> - -<%+cbi/valuefooter%> -<!-- ++ END ++ Dynamic DNS ++ overview_doubleline.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/overview_enabled.htm b/applications/luci-ddns/luasrc/view/ddns/overview_enabled.htm deleted file mode 100644 index 64b3dae455..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/overview_enabled.htm +++ /dev/null @@ -1,15 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ overview_enabled.htm ++ --> -<%+cbi/valueheader%> - -<input type="hidden" value="1"<%= - attr("name", "cbi.cbe." .. self.config .. "." .. section .. "." .. self.option) -%> /> - <!-- modified to call own function --> -<input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="onchange_enabled(this.id)" type="checkbox"<%= - attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) .. - ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") -%> /> - -<%+cbi/valuefooter%> -<!-- ++ END ++ Dynamic DNS ++ overview_enabled.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/overview_startstop.htm b/applications/luci-ddns/luasrc/view/ddns/overview_startstop.htm deleted file mode 100644 index 8255aa63f3..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/overview_startstop.htm +++ /dev/null @@ -1,17 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ overview_startstop.htm ++ --> -<%+cbi/valueheader%> - -<% if self:cfgvalue(section) ~= false then --- We need to garantie that function cfgvalue run first to set missing parameters -%> - <!-- style="font-size: 100%;" needed for openwrt theme to fix font size --> - <!-- type="button" onclick="..." enable standard onclick functionalty --> - <input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)" - <%= - attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled") - %> /> -<% end %> - -<%+cbi/valuefooter%> -<!-- ++ END ++ Dynamic DNS ++ overview_startstop.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/overview_status.htm b/applications/luci-ddns/luasrc/view/ddns/overview_status.htm deleted file mode 100644 index 37c54be25f..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/overview_status.htm +++ /dev/null @@ -1,208 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ overview_status.htm ++ --> -<script type="text/javascript">//<![CDATA[ - - // variables to store version information - var luci_version - var luci_build - var ddns_version - var ddns_required - - // helper to extract section from objects id - // cbi.ddns.SECTION._xyz - function _id2section(id) { - var x = id.split("."); - return x[2]; - } - - // helper to move status data to the relevant - // screen objects - // called by XHR.poll and onclick_startstop - function _data2elements(data) { - // DDNS Service - // fill Version informations - luci_version = data[0].luci_ver - luci_build = data[0].luci_build - ddns_version = data[0].script_ver - ddns_required = data[0].script_min - - // Service sections - for( i = 1; i < data.length; i++ ) - { - var section = data[i].section // Section to handle - var cbx = document.getElementById("cbid.ddns." + section + ".enabled"); // Enabled - var btn = document.getElementById("cbid.ddns." + section + "._startstop"); // Start/Stop button - var rip = document.getElementById("cbid.ddns." + section + "._domainIP.two"); // Registered IP - var lup = document.getElementById("cbid.ddns." + section + "._update.one"); // Last Update - var nup = document.getElementById("cbid.ddns." + section + "._update.two"); // Next Update - if ( !(cbx && btn && rip && lup && nup) ) { return; } // security check - - // process id - if (data[i].pid > 0) { - // stop always possible if process running - btn.value = "PID: " + data[i].pid; - btn.className = "cbi-button cbi-input-reset"; - } else { - // default Start / enabled - btn.value = "<%:Start%>"; - btn.className = "cbi-button cbi-input-apply"; - } - btn.disabled = false; // button enabled - - // last update - switch (data[i].datelast) { - case "_empty_": - lup.innerHTML = '<em><%:Unknown error%></em>' ; - break; - case "_never_": - lup.innerHTML = '<em><%:Never%></em>' ; - break; - default: - lup.innerHTML = data[i].datelast; - break; - } - - // next update - switch (data[i].datenext) { - case "_empty_": - nup.innerHTML = '<em><%:Unknown error%></em>' ; - break; - case "_verify_": - nup.innerHTML = '<em><%:Verify%></em>'; - break; - case "_runonce_": - case "_stopped_": - case "_disabled_": - if (cbx.checked && data[i].datenext == "_runonce_") { - nup.innerHTML = '<em><%:Run once%></em>'; - } else if (cbx.checked) { - nup.innerHTML = '<em><%:Stopped%></em>'; - } else { - nup.innerHTML = '<em><%:Disabled%></em>'; - btn.value = '----------'; - btn.className = "cbi-button cbi-input-button"; // no image - btn.disabled = true; // disabled - } - break; - default: - nup.innerHTML = data[i].datenext; - break; - } - - // domain - // (data[i].domain ignored here - - // registered IP - // rip.innerHTML = "Registered IP"; - if (data[i].domain == "_nodomain_") - rip.innerHTML = ''; - else if (data[i].reg_ip == "_nodata_") - rip.innerHTML = '<em><%:No data%></em>'; - else - rip.innerHTML = data[i].reg_ip; - - // monitored interfacce - // data[i].iface ignored here - } - } - - // event handler for enabled checkbox - function onchange_enabled(id) { - // run original function in cbi.js - // whatever is done there - cbi_d_update(id); - - var section = _id2section(id); - var cbx = document.getElementById("cbid.ddns." + section + ".enabled"); - var btn = document.getElementById("cbid.ddns." + section + "._startstop"); - if ( !(cbx && btn) ) { return; } // security check - - var pid_txt = btn.value; - var pid_found = ( pid_txt.search("PID") >= 0 ) ? true : false; - - if (pid_found) { - // btn.value = "PID: 0000"; - btn.className = "cbi-button cbi-button-reset"; - btn.disabled = false; - } else if (cbx.checked) { - btn.value = "<%:Start%>"; - btn.className = "cbi-button cbi-button-apply"; - btn.disabled = false; - } else { - btn.value = '----------'; - btn.className = "cbi-button cbi-input-button"; // no image - btn.disabled = true; // disabled - } - } - - // event handler for map.title link - function onclick_maptitle() { - var str = "<%:Version Information%>"; - str += "\n\nluci-app-ddns:"; - str += "\n\t<%:Version%>:\t" + luci_version; - str += "\n\t<%:Build%>:\t" + luci_build; - str += "\n\nddns-scripts <%:required%>:"; - str += "\n\t<%:Version%>:\t" + ddns_required + " <%:or greater%>"; - str += "\n\nddns-scripts <%:installed%>:"; - str += "\n\t<%:Version%>:\t" + ddns_version; - str += "\n\n" - alert(str); - } - - // event handler for start/stop button - function onclick_startstop(id) { - // extract section - var section = _id2section(id); - // get elements - var cbx = document.getElementById("cbid.ddns." + section + ".enabled"); // Enabled - var obj = document.getElementById("cbi-ddns-overview-status-legend"); // objext defined below to make in-/visible - if ( !(obj && cbx) ) { return; } // security check - - // make me visible - obj.parentNode.style.display = "block"; - - // do start/stop - var btnXHR = new XHR(); - btnXHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "startstop")%>/' + section + '/' + cbx.checked, null, - function(x, data) { - if (x.responseText == "_uncommited_") { - // we need a trick to display Ampersand "&" in stead of "&" or "&" - // after translation - txt="<%:Please [Save & Apply] your changes first%>"; - alert( txt.replace(new RegExp("<%:&%>", "g"), "&") ); - } else { - // should have data because status changed - // so update screen - if (data) - _data2elements(data); - } - // make me invisible - obj.parentNode.style.display = "none"; - } - ); - } - - // force to immediate show status on page load (not waiting for XHR.poll) - XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) { - _data2elements(data); - } - ); - - // define only ONE XHR.poll in a page because if one is running it blocks the other one - // optimum is to define on Map or Section Level from here you can reach all elements - // we need update every 15 seconds only - XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) { - _data2elements(data); - } - ); - -//]]></script> - -<fieldset class="cbi-section" style="display:none"> - <legend id="cbi-ddns-overview-status-legend"><%:Applying changes%></legend> - <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> - <span id="cbi-ddns-overview-status-text"><%:Waiting for changes to be applied...%></span> -</fieldset> -<!-- ++ END ++ Dynamic DNS ++ overview_status.htm ++ --> diff --git a/applications/luci-ddns/luasrc/view/ddns/system_status.htm b/applications/luci-ddns/luasrc/view/ddns/system_status.htm deleted file mode 100644 index db9d1d1a01..0000000000 --- a/applications/luci-ddns/luasrc/view/ddns/system_status.htm +++ /dev/null @@ -1,158 +0,0 @@ - -<!-- ++ BEGIN ++ Dynamic DNS ++ system_status.htm ++ --> -<script type="text/javascript">//<![CDATA[ - // helper to move status data to the relevant - // screen objects - // called by XHR.poll and XHR.get - function _data2elements(x, data) { - var tbl = document.getElementById('ddns_status_table'); - // security check - if ( !(tbl) ) { return; } - - // clear all rows - while (tbl.rows.length > 1) - tbl.deleteRow(1); - - // variable for Modulo-Division use to set cbi-rowstyle-? (0 or 1) - var x = -1; - var i = 1; - - // no data => no ddns-scripts Version 2 installed - if ( !data ) { - var txt = '<br /><strong><font color="red"><%:Old version of ddns-scripts installed%></font>' ; - var url = '<a href="' ; - url += '<%=luci.dispatcher.build_url("admin", "system", "packages")%>' ; - url += '"><%:install update here%></a></strong>' ; - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); - var td = tr.insertCell(-1); - td.colSpan = 2 ; - td.innerHTML = txt + " - " + url - tr.insertCell(-1).colSpan = 3 ; - return; - } - - // DDNS Service disabled - if (data[0].enabled == 0) { - var txt = '<strong><font color="red"><%:DDNS Autostart disabled%></font>' ; - var url = '<a href="' + data[0].url_up + '"><%:enable here%></a></strong>' ; - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); - var td = tr.insertCell(-1); - td.colSpan = 2 ; - td.innerHTML = txt + " - " + url - tr.insertCell(-1).colSpan = 3 ; - x++ ; - } - - for( i = 1; i < data.length; i++ ) - { - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1) ; - - // configuration - tr.insertCell(-1).innerHTML = '<strong>' + data[i].section + '</strong>' ; - - // pid - // data[i].pid ignored here - - // last update - // data[i].datelast ignored here - - // next update - switch (data[i].datenext) { - case "_empty_": - tr.insertCell(-1).innerHTML = '<em><%:Unknown error%></em>' ; - break; - case "_stopped_": - tr.insertCell(-1).innerHTML = '<em><%:Stopped%></em>' ; - break; - case "_disabled_": - tr.insertCell(-1).innerHTML = '<em><%:Disabled%></em>' ; - break; - case "_noupdate_": - tr.insertCell(-1).innerHTML = '<em><%:Update error%></em>' ; - break; - case "_runonce_": - tr.insertCell(-1).innerHTML = '<em><%:Run once%></em>' ; - break; - case "_verify_": - tr.insertCell(-1).innerHTML = '<em><%:Verify%></em>'; - break; - default: - tr.insertCell(-1).innerHTML = data[i].datenext ; - break; - } - - // domain - if (data[i].domain == "_nodomain_") - tr.insertCell(-1).innerHTML = '<em><%:config error%></em>'; - else - tr.insertCell(-1).innerHTML = data[i].domain; - - // registered IP - switch (data[i].reg_ip) { - case "_nodomain_": - tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>'; - break; - case "_nodata_": - tr.insertCell(-1).innerHTML = '<em><%:No data%></em>'; - break; - case "_noipv6_": - tr.insertCell(-1).innerHTML = '<em><%:IPv6 not supported%></em>'; - break; - default: - tr.insertCell(-1).innerHTML = data[i].reg_ip; - break; - } - - // monitored interfacce - if (data[i].iface == "_nonet_") - tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>'; - else - tr.insertCell(-1).innerHTML = data[i].iface; - } - - if (tbl.rows.length == 1 || (data[0].enabled == 0 && tbl.rows.length == 2) ) { - var br = '<br />'; - if (tbl.rows.length > 1) - br = ''; - var tr = tbl.insertRow(-1); - tr.className = "cbi-section-table-row"; - var td = tr.insertCell(-1); - td.colSpan = 5; - td.innerHTML = '<em>' + br + '<%:There is no service configured.%></em>' ; - } - } - - // force to immediate show status (not waiting for XHR.poll) - XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) { - _data2elements(x, data); - } - ); - - XHR.poll(10, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) { - _data2elements(x, data); - } - ); -//]]></script> - -<fieldset class="cbi-section" id="ddns_status_section"> - <legend><a href="<%=luci.dispatcher.build_url([[admin]], [[services]], [[ddns]])%>"><%:Dynamic DNS%></a></legend> - - <table class="cbi-section-table" id="ddns_status_table"> - <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Configuration%></th> - <th class="cbi-section-table-cell"><%:Next Update%></th> - <th class="cbi-section-table-cell"><%:Hostname/Domain%></th> - <th class="cbi-section-table-cell"><%:Registered IP%></th> - <th class="cbi-section-table-cell"><%:Network%></th> - </tr> - <tr class="cbi-section-table-row"> - <td colspan="5"><em><br /><%:Collecting data...%></em></td> - </tr> - </table> -</fieldset> -<!-- ++ END ++ Dynamic DNS ++ system_status.htm ++ --> diff --git a/applications/luci-ddns/root/etc/uci-defaults/luci-ddns b/applications/luci-ddns/root/etc/uci-defaults/luci-ddns deleted file mode 100755 index 4849e59b7f..0000000000 --- a/applications/luci-ddns/root/etc/uci-defaults/luci-ddns +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# no longer needed for "Save and Apply" to restart ddns -uci -q batch <<-EOF >/dev/null - delete ucitrack.@ddns[-1] - commit ucitrack -EOF - -# make helper script executable -chmod 755 /usr/lib/ddns/dynamic_dns_lucihelper.sh - -# update application section for luci-app-ddns -uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns' -uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R' -uci -q get ddns.global.log_lines > /dev/null || uci -q set ddns.global.log_lines='250' -uci -q commit ddns - -rm -f /tmp/luci-indexcache -exit 0 |