X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-ddns%2Fluasrc%2Fmodel%2Fcbi%2Fddns%2Foverview.lua;h=9a989bae41ac4faf09d485cc1645717c206321d8;hp=83b10e9366b26d0d135faa104a3b15633cf7a962;hb=6b627a934f525feebbaf72cd233c8f237d908918;hpb=0d541a4cbdeb51ac23d4a1ce7bc561e1c0790c77 diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua index 83b10e936..9a989bae4 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua @@ -1,21 +1,24 @@ --- Copyright 2014 Christian Schoenebeck +-- Copyright 2014-2016 Christian Schoenebeck -- Licensed to the public under the Apache License 2.0. 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 CTRL = require "luci.controller.ddns" -- this application's controller 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 +local show_hints = not (DDNS.has_ipv6 -- IPv6 support + and DDNS.has_ssl -- HTTPS support + and DDNS.has_proxy -- Proxy support + and DDNS.has_bindhost -- DNS TCP support + and DDNS.has_forceip -- Force IP version + and DDNS.has_dnsserver -- DNS server support + and DDNS.has_bindnet -- Bind to network/interface + and DDNS.has_cacerts -- certificates installed at /etc/ssl/certs ) --- correct ddns-scripts version -need_update = DDNS.ipkg_ver_compare(DDNS.ipkg_ver_installed("ddns-scripts"), "<<", CTRL.DDNS_MIN) +local not_enabled = not SYS.init.enabled("ddns") +local need_update = not CTRL.service_ok() -- html constants font_red = [[]] @@ -25,25 +28,8 @@ bold_off = [[]] -- cbi-map definition -- ####################################################### m = Map("ddns") - --- first need to close from cbi map template our closed by template ---m.title = [[]] .. --- translate("Dynamic DNS") -m.title = [[]] - .. 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.title = CTRL.app_title_main() +m.description = CTRL.app_description() m.on_after_commit = function(self) if self.changed then -- changes ? @@ -55,20 +41,15 @@ m.on_after_commit = function(self) end end --- SimpleSection definiton -- ################################################## +-- SimpleSection definition -- ################################################## -- with all the JavaScripts we need for "a good Show" a = m:section( SimpleSection ) a.template = "ddns/overview_status" -- 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 +if show_hints or need_update or not_enabled then + s = m:section( SimpleSection, translate("Hints") ) -- ddns_scripts needs to be updated for full functionality @@ -84,7 +65,7 @@ if show_hints or need_update or not SYS.init.enabled("ddns") then end -- DDNS Service disabled - if not SYS.init.enabled("ddns") then + if not_enabled then local dv = s:option(DummyValue, "_not_enabled") dv.titleref = DISP.build_url("admin", "system", "startup") dv.rawhtml = true @@ -109,9 +90,13 @@ end -- TableSection definition -- ################################################## ts = m:section( TypedSection, "service", translate("Overview"), - translate("Below is a list of configured DDNS configurations and their current state." .. "
" .. - "If you want to send updates for IPv4 and IPv6 you need to define two separate Configurations " .. - "i.e. 'myddns_ipv4' and 'myddns_ipv6'") ) + translate("Below is a list of configured DDNS configurations and their current state.") + .. "
" + .. translate("If you want to send updates for IPv4 and IPv6 you need to define two separate Configurations " + .. "i.e. 'myddns_ipv4' and 'myddns_ipv6'") + .. "
" + .. [[
]] + .. translate("To change global settings click here") .. [[]] ) ts.sectionhead = translate("Configuration") ts.template = "cbi/tblsection" ts.addremove = true @@ -121,21 +106,21 @@ function ts.create(self, name) HTTP.redirect( self.extedit:format(name) ) end --- Domain and registered IP -- ################################################# -dom = ts:option(DummyValue, "_domainIP", - translate("Hostname/Domain") .. "
" .. translate("Registered IP") ) +-- Lookup_Host and registered IP -- ################################################# +dom = ts:option(DummyValue, "_lookupIP", + translate("Lookup Hostname") .. "
" .. 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 + local lookup = self.map:get(section, "lookup_host") or "" + if lookup ~= "" then + return lookup else return [[]] .. translate("config error") .. [[]] end end function dom.set_two(self, section) - local domain = self.map:get(section, "domain") or "" - if domain == "" then return "" end + local lookup = self.map:get(section, "lookup_host") or "" + if lookup == "" 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) @@ -144,7 +129,7 @@ function dom.set_two(self, section) if not NXFS.access(command, "rwx", "rx", "rx") then NXFS.chmod(command, 755) end - command = command .. [[ get_registered_ip ]] .. domain .. [[ ]] .. use_ipv6 .. + command = command .. [[ get_registered_ip ]] .. lookup .. [[ ]] .. use_ipv6 .. [[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp .. [[ ]] .. dnsserver local ip = SYS.exec(command) if ip == "" then ip = translate("no data") end @@ -156,9 +141,6 @@ 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",