summaryrefslogtreecommitdiffstats
path: root/unbound-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2015-11-02 14:09:42 +0000
committerTed Trask <ttrask01@yahoo.com>2015-11-02 14:09:42 +0000
commit3d69b32a0b152ddbc90d272fb970a3e4781763b9 (patch)
treed6b7312b0c25b0b2f8925ca622486c29288c80a8 /unbound-model.lua
parent16ae49688035474711f4cc32d890ff4000bdee73 (diff)
downloadacf-unbound-3d69b32a0b152ddbc90d272fb970a3e4781763b9.tar.bz2
acf-unbound-3d69b32a0b152ddbc90d272fb970a3e4781763b9.tar.xz
Modify logfile to get logging info from the config and use common view
Diffstat (limited to 'unbound-model.lua')
-rw-r--r--unbound-model.lua37
1 files changed, 26 insertions, 11 deletions
diff --git a/unbound-model.lua b/unbound-model.lua
index 1743f72..49295ac 100644
--- a/unbound-model.lua
+++ b/unbound-model.lua
@@ -15,6 +15,24 @@ local config
-- ################################################################################
-- LOCAL FUNCTIONS
+local parseconfig = function()
+ if config then return config end
+ local temp = format.parse_linesandwords(fs.read_file(configfile) or "", "#")
+ config = {}
+ local cur = config
+ for i,line in ipairs(temp) do
+ local attr = string.match(line[1], "(.*):")
+ if #line == 1 then
+ config[attr] = {}
+ cur = config[attr]
+ else
+ table.remove(line, 1)
+ cur[attr] = table.concat(line, " ")
+ end
+ end
+ return config
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -39,19 +57,16 @@ function mymodule.update_filedetails(self, filedetails)
end
function mymodule.get_logfile(f)
+ local retval = cfe({ type="structure", value={}, label="Unbound Log Files" })
+ config = config or parseconfig()
-- Determine the log file from the config file
- -- TODO determine how best to parse the file
---[[
- config = config or format.parse_ini_file(fs.read_file(configfile) or "", "")
- local files = {}
- if config and config.logfile then
- files[#files+1] = {path = config.logfile}
- end
---]]
- if 0 == #files then
- files[#files+1] = {path = "/var/log/messages", grep = "unbound"}
+ if config.server and config.server.logfile and config.server.logfile ~= "" then
+ retval.value[#retval.value+1] = {filename=config.server.logfile}
+ else
+ -- report syslog even if use-syslog == "no"
+ retval.value[#retval.value+1] = {facility="daemon", grep="unbound"}
end
- return cfe({ value=files, label="Unbound Log Files" })
+ return retval
end
return mymodule