From 800060937ee9a859baa2157e4912a1e064ee6ca2 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 22 Feb 2008 15:11:01 +0000 Subject: Made some progress git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@765 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-model.lua | 58 +++++++++++++++++++++++++++++++++++++++++++++---- tinydns-status-html.lsp | 19 +++++++++++----- 2 files changed, 68 insertions(+), 9 deletions(-) diff --git a/tinydns-model.lua b/tinydns-model.lua index 4d08a57..a466f6b 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -122,7 +122,7 @@ local function searchforconfigfiles() end -- Debug option (adds the sampleconfig content) - table.insert(configfiles, "/usr/share/acf/app/tinydns/sampleconfig.conf") +-- table.insert(configfiles, "/usr/share/acf/app/tinydns/sampleconfig.conf") end searchforconfigfiles() @@ -149,7 +149,15 @@ local function recursedomains(t,array,maxn,currnum) currnum = currnum - 1 -- FIXME: The current level should hold information on previous level too! if not (currnum == 0) then + +-- if (array) and (type(array[t[currnum]]) == "table") then +-- local k,v = pairs(array[t[currnum]]) do +-- end +-- end + if not (array[t[currnum]]) then +-- if not (array[(table.concat(t,"."))]) then +-- array[t[currnum]] = {} array[t[currnum]] = {} end recursedomains(t,array[t[currnum]],maxn,currnum) @@ -273,11 +281,53 @@ function getconfig() if (filecontent_table[1] == "&") then local descr=check_signs("prefix") domain = format.string_to_table(filecontent_table[2], "%.") + + if (domain[#domain] ~= "arpa") then + -- We rebuild the table and add previous level-information to the current level + for i = table.maxn(domain),2,-1 do + domain[i-1] = domain[i-1] .. "." .. domain[i] + end + + -- This is the main information on each object domaindetails = cfe ({ - name=filecontent_table[2], - label=descr[filecontent_table[1]], - value=filecontent_table[2], + name=filecontent_table[4], + label=filecontent_table[4], }) + -- Add details to the previous object + table.insert(domaindetails, cfe ({ + name=type, + label="Type:", + value=descr[filecontent_table[1]], + })) + table.insert(domaindetails, cfe ({ + name=domain, + label="Domain:", + value=filecontent_table[2], + })) + table.insert(domaindetails, cfe ({ + name=ip, + label="IP address:", + value=filecontent_table[3], + })) + table.insert(domaindetails, cfe ({ + name=ns, + label="Name server:", + value=filecontent_table[4], + })) + table.insert(domaindetails, cfe ({ + name=ttl, + label="TimeToLive:", + value=filecontent_table[5], + })) + + + table.insert(domaindetails, cfe ({ + name=debug, + label="Debug:", + value=table.concat(filecontent_table,":"), + })) + end + end local value = filecontent_table[2] diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp index 5d5bd1d..024bb13 100644 --- a/tinydns-status-html.lsp +++ b/tinydns-status-html.lsp @@ -1,6 +1,6 @@ DEBUGGING

DEBUG INFO: CFE

") io.write(html.cfe_unpack(form)) io.write("
") @@ -78,11 +78,20 @@ local function recurseoutput(table,cnt) if not (cnt) then cnt=0 end cnt = cnt + 1 for k,v in pairs(table or {}) do - if (type(v) == "string") then - io.write(" ".. - tostring(v) .. "
") + if (type(v["name"]) == "string") then + io.write(" ".. tostring(v["label"]) .. "
") + if (#v > 0) then + io.write("") + for i=1,#v do + if (type(v[i]["label"]) == "string") then + io.write("") + end + end + io.write("
".. tostring(v[i]["label"]) .. "".. tostring(v[i]["value"]) .."
") + end else - io.write(" ".. + io.write(" ".. tostring(k) .. "
") recurseoutput(v,cnt) end -- cgit v1.2.3