diff options
Diffstat (limited to 'unbound-model.lua')
-rw-r--r-- | unbound-model.lua | 37 |
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 |