summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--unbound-controller.lua2
l---------[-rw-r--r--]unbound-logfile-html.lsp9
-rw-r--r--unbound-model.lua37
3 files changed, 28 insertions, 20 deletions
diff --git a/unbound-controller.lua b/unbound-controller.lua
index cca194e..46b38c9 100644
--- a/unbound-controller.lua
+++ b/unbound-controller.lua
@@ -15,7 +15,7 @@ function mymodule.expert(self)
end
function mymodule.logfile(self)
- return self.model.get_logfile()
+ return self.model.get_logfile(self, self.clientdata)
end
return mymodule
diff --git a/unbound-logfile-html.lsp b/unbound-logfile-html.lsp
index d718396..ac8854f 100644..120000
--- a/unbound-logfile-html.lsp
+++ b/unbound-logfile-html.lsp
@@ -1,8 +1 @@
-<% local data, viewlibrary = ...
-%>
-
-<% if viewlibrary and viewlibrary.dispatch_component then
- for i,logfile in ipairs(data.value) do
- viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename=logfile.path, grep=logfile.grep})
- end
-end %>
+../logfile-html.lsp \ No newline at end of file
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