summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-ddns/Makefile6
-rwxr-xr-xapplications/luci-app-ddns/luasrc/controller/ddns.lua39
-rw-r--r--applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua41
-rwxr-xr-xapplications/luci-app-ddns/luasrc/tools/ddns.lua19
4 files changed, 68 insertions, 37 deletions
diff --git a/applications/luci-app-ddns/Makefile b/applications/luci-app-ddns/Makefile
index 69f9880d4..50365e521 100644
--- a/applications/luci-app-ddns/Makefile
+++ b/applications/luci-app-ddns/Makefile
@@ -2,7 +2,7 @@
# Copyright 2008 Steven Barth <steven@midlink.org>
# Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
# Copyright 2013 Manuel Munz <freifunk at somakoma dot de>
-# Copyright 2014-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+# Copyright 2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#
# This is free software, licensed under the Apache License, Version 2.0
@@ -12,11 +12,11 @@ include $(TOPDIR)/rules.mk
# Version == major.minor.patch
# increase on new functionality (minor) or patches (patch)
-PKG_VERSION:=2.4.8
+PKG_VERSION:=2.4.9
# Release == build
# increase on changes of translation files
-PKG_RELEASE:=2
+PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
diff --git a/applications/luci-app-ddns/luasrc/controller/ddns.lua b/applications/luci-app-ddns/luasrc/controller/ddns.lua
index 1dfa62554..3d31e4e0b 100755
--- a/applications/luci-app-ddns/luasrc/controller/ddns.lua
+++ b/applications/luci-app-ddns/luasrc/controller/ddns.lua
@@ -1,7 +1,7 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
-- Copyright 2013 Manuel Munz <freifunk at somakoma dot de>
--- Copyright 2014-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+-- Copyright 2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.ddns", package.seeall)
@@ -20,11 +20,11 @@ local DDNS = require "luci.tools.ddns" -- ddns multiused functions
luci_helper = "/usr/lib/ddns/dynamic_dns_lucihelper.sh"
local srv_name = "ddns-scripts"
-local srv_ver_min = "2.7.6" -- minimum version of service required
+local srv_ver_min = "2.7.7" -- minimum version of service required
local srv_ver_cmd = luci_helper .. [[ -V | awk {'print $2'}]]
local app_name = "luci-app-ddns"
local app_title = "Dynamic DNS"
-local app_version = "2.4.8-2"
+local app_version = "2.4.9-1"
function index()
local nxfs = require "nixio.fs" -- global definitions not available
@@ -187,19 +187,26 @@ local function _get_status()
-- try to get registered IP
local lookup_host = s["lookup_host"] or "_nolookup_"
- 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 is_glue = tonumber(s["is_glue"] or 0)
- local command = luci_helper .. [[ -]]
- if (use_ipv6 == 1) then command = command .. [[6]] end
- if (force_ipversion == 1) then command = command .. [[f]] end
- if (force_dnstcp == 1) then command = command .. [[t]] end
- if (is_glue == 1) then command = command .. [[g]] end
- command = command .. [[l ]] .. lookup_host
- if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
- command = command .. [[ -- get_registered_ip]]
- local reg_ip = SYS.exec(command)
+ local chk_sec = DDNS.calc_seconds(
+ tonumber(s["check_interval"]) or 10,
+ s["check_unit"] or "minutes" )
+ local reg_ip = DDNS.get_regip(section, chk_sec)
+ if reg_ip == "NOFILE" then
+ 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 is_glue = tonumber(s["is_glue"] or 0)
+ local command = luci_helper .. [[ -]]
+ if (use_ipv6 == 1) then command = command .. [[6]] end
+ if (force_ipversion == 1) then command = command .. [[f]] end
+ if (force_dnstcp == 1) then command = command .. [[t]] end
+ if (is_glue == 1) then command = command .. [[g]] end
+ command = command .. [[l ]] .. lookup_host
+ command = command .. [[ -S ]] .. section
+ if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
+ command = command .. [[ -- get_registered_ip]]
+ reg_ip = SYS.exec(command)
+ end
if reg_ip == "" then
reg_ip = "_nodata_"
end
diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua
index 6ba3ea0dd..114f831c1 100644
--- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua
+++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua
@@ -1,4 +1,4 @@
--- Copyright 2014-2016 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+-- Copyright 2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-- Licensed to the public under the Apache License 2.0.
local NXFS = require "nixio.fs"
@@ -122,22 +122,29 @@ function dom.set_one(self, section)
end
end
function dom.set_two(self, section)
- local lookup_host = self.map:get(section, "lookup_host") or ""
- if lookup_host == "" then return "" end
- local dnsserver = self.map:get(section, "dnsserver") or ""
- local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0)
- local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0)
- local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0)
- local is_glue = tonumber(self.map:get(section, "is_glue") or 0)
- local command = CTRL.luci_helper .. [[ -]]
- if (use_ipv6 == 1) then command = command .. [[6]] end
- if (force_ipversion == 1) then command = command .. [[f]] end
- if (force_dnstcp == 1) then command = command .. [[t]] end
- if (is_glue == 1) then command = command .. [[g]] end
- command = command .. [[l ]] .. lookup_host
- if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
- command = command .. [[ -- get_registered_ip]]
- local ip = SYS.exec(command)
+ local chk_sec = DDNS.calc_seconds(
+ tonumber(self.map:get(section, "check_interval")) or 10,
+ self.map:get(section, "check_unit") or "minutes" )
+ local ip = DDNS.get_regip(section, chk_sec)
+ if ip == "NOFILE" then
+ local lookup_host = self.map:get(section, "lookup_host") or ""
+ if lookup_host == "" then return "" end
+ local dnsserver = self.map:get(section, "dnsserver") or ""
+ local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0)
+ local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0)
+ local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0)
+ local is_glue = tonumber(self.map:get(section, "is_glue") or 0)
+ local command = CTRL.luci_helper .. [[ -]]
+ if (use_ipv6 == 1) then command = command .. [[6]] end
+ if (force_ipversion == 1) then command = command .. [[f]] end
+ if (force_dnstcp == 1) then command = command .. [[t]] end
+ if (is_glue == 1) then command = command .. [[g]] end
+ command = command .. [[l ]] .. lookup_host
+ command = command .. [[ -S ]] .. section
+ if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
+ command = command .. [[ -- get_registered_ip]]
+ ip = SYS.exec(command)
+ end
if ip == "" then ip = translate("no data") end
return ip
end
diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua
index 209d9c3a4..690b9b30c 100755
--- a/applications/luci-app-ddns/luasrc/tools/ddns.lua
+++ b/applications/luci-app-ddns/luasrc/tools/ddns.lua
@@ -1,4 +1,4 @@
--- Copyright 2014-2016 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
+-- Copyright 2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-- Licensed to the public under the Apache License 2.0.
module("luci.tools.ddns", package.seeall)
@@ -74,6 +74,23 @@ function get_lastupd(section)
return etime
end
+-- read registered IP from [section].ip file
+function get_regip(section, chk_sec)
+ local uci = UCI.cursor()
+ local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns"
+ local ip = "NOFILE"
+ if NXFS.access("%s/%s.ip" % { rdir, section }) then
+ local ftime = NXFS.stat("%s/%s.ip" % { rdir, section }, "ctime") or 0
+ local otime = os.time()
+ -- give ddns-scripts time (9 sec) to update file
+ if otime < (ftime + chk_sec + 9) then
+ ip = NXFS.readfile("%s/%s.ip" % { rdir, section })
+ end
+ end
+ uci:unload("ddns")
+ return ip
+end
+
-- read PID from run file and verify if still running
function get_pid(section)
local uci = UCI.cursor()