summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-ddns/luasrc/tools
diff options
context:
space:
mode:
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>2018-01-27 16:11:07 +0100
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>2018-01-27 16:11:07 +0100
commit1cd12c449830206f7406163f700553c26320d272 (patch)
treefa007d6772dcb38ef44c8aa14366ff14fcff387b /applications/luci-app-ddns/luasrc/tools
parent5e59ba3e0d1d557cf20561ce4d6964f96c22e2e1 (diff)
luci.app-ddns: Update to 2.4.9-1
Read registered IP from file, updated by ddns-scripts. Only read from DNS if file does not exist or outdated (check_interval). Require ddns-scripts v 2.7.7 Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Diffstat (limited to 'applications/luci-app-ddns/luasrc/tools')
-rwxr-xr-xapplications/luci-app-ddns/luasrc/tools/ddns.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua
index 209d9c3a41..690b9b30ce 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()