X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-ddns%2Fluasrc%2Fmodel%2Fcbi%2Fddns%2Fglobal.lua;h=9dc08575096525cf8dd9d535364ca9a1b710a81e;hp=25d09b73bb3225420a3e6d312536c3fb852fdad0;hb=HEAD;hpb=49a7c5bd03f1b5cdbd6a8d7a05562dd7d5f012a5
diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua
index 25d09b73b..9dc085750 100644
--- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua
+++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua
@@ -5,22 +5,19 @@ local NX = require "nixio"
local NXFS = require "nixio.fs"
local DISP = require "luci.dispatcher"
local SYS = require "luci.sys"
+local CTRL = require "luci.controller.ddns" -- this application's controller
local DDNS = require "luci.tools.ddns" -- ddns multiused functions
-- cbi-map definition -- #######################################################
local m = Map("ddns")
-
-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.redirect = DISP.build_url("admin", "services", "ddns")
+m.title = CTRL.app_title_back()
+m.description = CTRL.app_description()
+m.redirect = DISP.build_url("admin", "services", "ddns")
function m.commit_handler(self)
if self.changed then -- changes ?
- os.execute("/etc/init.d/ddns reload &") -- reload configuration
+ local command = CTRL.luci_helper .. " -- reload"
+ os.execute(command) -- reload configuration
end
end
@@ -44,34 +41,23 @@ function ns.cfgvalue(self, section)
return self.map:get(section)
end
--- allow_local_ip -- ##########################################################
-local ali = ns:option(Flag, "allow_local_ip")
+-- upd_privateip -- ###########################################################
+local ali = ns:option(Flag, "upd_privateip")
ali.title = translate("Allow non-public IP's")
ali.description = translate("Non-public and by default blocked IP's") .. ":"
.. [[
IPv4: ]]
.. "0/8, 10/8, 100.64/10, 127/8, 169.254/16, 172.16/12, 192.168/16"
.. [[
IPv6: ]]
.. "::/32, f000::/4"
-ali.reempty = true
ali.default = "0"
-function ali.parse(self, section)
- DDNS.flag_parse(self, section)
-end
-function ali.validate(self, value)
- if value == self.default then
- return "" -- default = empty
- end
- return value
-end
--- date_format -- #############################################################
-local df = ns:option(Value, "date_format")
+-- ddns_dateformat -- #########################################################
+local df = ns:option(Value, "ddns_dateformat")
df.title = translate("Date format")
df.description = [[]]
.. translate("For supported codes look here")
.. [[]]
df.template = "ddns/global_value"
-df.rmempty = true
df.default = "%F %R"
df.date_string = ""
function df.cfgvalue(self, section)
@@ -80,55 +66,45 @@ function df.cfgvalue(self, section)
self.date_string = DDNS.epoch2date(epoch, value)
return value
end
-function df.validate(self, value)
- if value == self.default then
- return "" -- default = empty
- end
- return value
+function df.parse(self, section, novld)
+ DDNS.value_parse(self, section, novld)
end
--- run_dir -- #################################################################
-local rd = ns:option(Value, "run_dir")
+-- ddns_rundir -- #############################################################
+local rd = ns:option(Value, "ddns_rundir")
rd.title = translate("Status directory")
rd.description = translate("Directory contains PID and other status information for each running section")
-rd.rmempty = true
rd.default = "/var/run/ddns"
-function rd.validate(self, value)
- if value == self.default then
- return "" -- default = empty
- end
- return value
+-- no need to validate. if empty default is used everything else created by dns-scripts
+function rd.parse(self, section, novld)
+ DDNS.value_parse(self, section, novld)
end
--- log_dir -- #################################################################
-local ld = ns:option(Value, "log_dir")
+-- ddns_logdir -- #############################################################
+local ld = ns:option(Value, "ddns_logdir")
ld.title = translate("Log directory")
ld.description = translate("Directory contains Log files for each running section")
-ld.rmempty = true
ld.default = "/var/log/ddns"
-function ld.validate(self, value)
- if value == self.default then
- return "" -- default = empty
- end
- return value
+-- no need to validate. if empty default is used everything else created by dns-scripts
+function ld.parse(self, section, novld)
+ DDNS.value_parse(self, section, novld)
end
--- log_lines -- ###############################################################
-local ll = ns:option(Value, "log_lines")
+-- ddns_loglines -- ###########################################################
+local ll = ns:option(Value, "ddns_loglines")
ll.title = translate("Log length")
ll.description = translate("Number of last lines stored in log files")
-ll.rmempty = true
ll.default = "250"
function ll.validate(self, value)
local n = tonumber(value)
if not n or math.floor(n) ~= n or n < 1 then
return nil, self.title .. ": " .. translate("minimum value '1'")
end
- if value == self.default then
- return "" -- default = empty
- end
return value
end
+function ll.parse(self, section, novld)
+ DDNS.value_parse(self, section, novld)
+end
-- use_curl -- ################################################################
if (SYS.call([[ grep -i "\+ssl" /usr/bin/wget >/dev/null 2>&1 ]]) == 0)
@@ -139,17 +115,7 @@ and NXFS.access("/usr/bin/curl") then
.. [[
]]
.. translate("To use cURL activate this option.")
pc.orientation = "horizontal"
- pc.rmempty = true
pc.default = "0"
- function pc.parse(self, section)
- DDNS.flag_parse(self, section)
- end
- function pc.validate(self, value)
- if value == self.default then
- return "" -- default = empty
- end
- return value
- end
end
return m