summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-02-16 11:13:56 +0000
committerMika Havela <mika.havela@gmail.com>2008-02-16 11:13:56 +0000
commit335d503c6f8c54ab66a02fc8454525b628bb9255 (patch)
tree5b61fd65e6103065849e8b65f7a2d5df23604981
parent9be3927959b864d02284faea9dc383c2a6279eb3 (diff)
downloadacf-tinydns-335d503c6f8c54ab66a02fc8454525b628bb9255.tar.bz2
acf-tinydns-335d503c6f8c54ab66a02fc8454525b628bb9255.tar.xz
Added a sampleconfig that shows some output. Still a long way to go
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@728 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile1
-rwxr-xr-xsampleconfig.conf35
-rwxr-xr-xtinydns-config-html.lsp42
-rw-r--r--tinydns-model.lua88
-rw-r--r--tinydns-status-html.lsp64
5 files changed, 226 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index e7dd2dd..a91e4fc 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ VERSION=0.1
APP_DIST=\
tinydns* \
+ sampleconfig.conf \
EXTRA_DIST=README Makefile config.mk
diff --git a/sampleconfig.conf b/sampleconfig.conf
new file mode 100755
index 0000000..e3e7b7f
--- /dev/null
+++ b/sampleconfig.conf
@@ -0,0 +1,35 @@
+%ex:
+%in:192.168
+%se:192.168.1
+%se:192.168.2
+%se:192.168.5
+
+Zme.org:ns1.you.org:iseng.me.org:2007082204:1200:2048:864000:3600:::
+&me.org::ns1.you.org:3600::
+Zme.org:ns2.you.org.iseng.me.org:2007082204:1200:2048:864000:3600:::
+&me.org::ns2.you.org:3600::
+Zme.org:ns3.you.org.iseng.me.org:2007082204:1200:2048:864000:3600:::
+&me.org::ns3.you.org:3600::
+
++smtp.me.org:172.16.0.2:3600::in
+=srv.me.org:208.74.141.33:3600::
+=xproxy1.me.org:172.16.0.3:3600::in
+=xweb2.me.org:172.16.0.4:3600::in
+
+=www.me.org:208.74.141.33:3600::
+=me.org:208.74.141.33:3600::
+=test.me.org:208.74.141.33:3600::
+=www.test.me.org:208.74.141.33:3600::
+Cdownload.me.org:download.me.org.google.com:3600::
+
++mail1.se.me.org:213.234.126.132:3600::
++mail2.se.me.org:213.234.126.132:3600::
+
++mail1.us.me.org:208.74.141.33:3600::
++mail2.us.me.org:208.74.141.33:3600::
+
+@me.org:213.234.126.132:mx2.me.org:20:3600::ex
+@me.org:208.74.141.33:mx2.me.org:20:3600::in
+@me.org:213.234.126.132:mx1.me.org:60:3600::ex
+@me.org:208.74.141.33:mx1.me.org:60:3600::in
+
diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp
index eea9f6e..b3f9053 100755
--- a/tinydns-config-html.lsp
+++ b/tinydns-config-html.lsp
@@ -47,6 +47,48 @@ local tags = { "listen", }
displayinfo(myform,tags)
?>
+<H2>Locations</H2>
+<?
+local v = "locations"
+--displayinfo(myform,tags)
+io.write("<DL>")
+--for k,v in pairs(tags) do
+if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+
+
+ io.write("\t\t<DD>\n")
+ for k,v in pairs(myform[v]["value"]) do
+ io.write("<IMG SRC='/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>")
+ for kk,vv in pairs(v) do
+ io.write(tostring("<BR>" ..vv.option[3]).. "\n")
+ end
+ io.write("<BR>")
+ end
+
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+end
+--end
+io.write("</DL>")
+?>
+
+
+
+
+
+
+
+
+
+
<? ---[[ ?>
<H1>DEGUGGING</H1>
<?
diff --git a/tinydns-model.lua b/tinydns-model.lua
index a3f8a10..7a24740 100644
--- a/tinydns-model.lua
+++ b/tinydns-model.lua
@@ -3,6 +3,7 @@ module(..., package.seeall)
require("procps")
require("getopts")
require("fs")
+require("format")
local configdir
local datafile
@@ -37,15 +38,25 @@ local function get_version()
return cmd_output_result,cmd_output_error
end
---[[
-- This function could be used to check that valid parameters are used in different places
local function check_signs(sign)
local output = {}
- local output = {prefix={"Z", "&", "=", "+", "@", "C",}}
+ local output = {prefix={
+ ['.']="Name server for your domain",
+ ['&']="Name server",
+ ['=']="Host",
+ ['+']="Alias",
+ ['@']="Mail exchanger",
+ ['=']="Host",
+ ['^']="PTR record",
+ ['C']="Canonical Name",
+ ['Z']="SOA record",
+ [':']="Generic record",
+ ['%']="Client location",
+ }}
output = output[sign]
return output
end
---]]
-- Return a table with the config-content of a file
-- Commented/Blank lines are ignored
@@ -83,6 +94,22 @@ local function recursedir(path, filearray)
end
end
+-- Functin to split items into a table
+local function split_config_items(orgitem)
+ local delimiter = ":"
+ local output = {}
+ output = format.string_to_table(string.sub(orgitem,1,1) .. ":" .. string.sub(orgitem,2),delimiter)
+ output.type = check_signs("prefix")
+ output.type = output.type[string.sub(orgitem,1,1)] or "unknown"
+-- for k,v in pairs(cnffile) do
+-- local configcontent = get_value_from_file(v)
+-- if (configcontent) then
+-- table.insert(configfiles, v)
+-- end
+-- end
+ return output
+end
+
-- Feed the configfiles table with list of all availage configfiles
local function searchforconfigfiles()
local cnffile = {}
@@ -93,6 +120,10 @@ local function searchforconfigfiles()
table.insert(configfiles, v)
end
end
+
+ -- Debug option (adds the sampleconfig content)
+ table.insert(configfiles, "/usr/share/acf/app/tinydns/sampleconfig.conf")
+
end
searchforconfigfiles()
-- ################################################################################
@@ -102,6 +133,7 @@ searchforconfigfiles()
function getstatus()
local status = {}
local version,versionerrtxt = get_version()
+ local config = getconfig()
status.version = cfe({ name = "version",
label="Program version",
value=version,
@@ -111,12 +143,17 @@ function getstatus()
label="Program status",
value=procps.pidof(processname),
})
+
+ status.locations = config.locations
+
return status
end
-- Return config-information
function getconfig()
local config = {}
+ local configobjects = {}
+ local locations = {}
local version,versionerrtxt = get_version()
local listenaddr = getopts.getoptsfromfile_onperline(configfile,"IP") or {}
config.listen = cfe({
@@ -124,7 +161,49 @@ function getconfig()
label="IP address to listen on",
value=listenaddr.IP or "",
})
+ --Loop through all available configfiles
+ for k,v in pairs(configfiles) do
+ local filecontent, fileresult
+ fileresult, filecontent = get_value_from_file(v)
+ for kk,vv in pairs(filecontent) do
+ local filecontent_table = split_config_items(vv)
+
+ -- This is mostly for debugging
+ -- This table contains all available configs
+ table.insert(configobjects, cfe({
+ name=vv,
+ value=vv,
+ option=filecontent_table,
+ }))
+ -- Create a table with location items
+ -- Containing all objects that start with %
+ if (filecontent_table[1] == "%") then
+ if not (locations[filecontent_table[2]]) then
+ locations[filecontent_table[2]] = {}
+ end
+ table.insert(locations[filecontent_table[2]], cfe({
+ name=filecontent_table[2]..filecontent_table[3],
+ label=filecontent_table["type"],
+ value=vv,
+ option=filecontent_table,
+ }))
+ end
+
+ end
+ end
+ config.locations = cfe({
+ name = "locations",
+ label="Configured locations",
+ value=locations,
+ })
+---[[
+ config.configitems = cfe({
+ name = "configitems",
+ label="Config items",
+ value=configobjects,
+ })
+--]]
return config
end
@@ -172,13 +251,14 @@ function getdebug()
table.insert(configitems,vv)
end
end
+--[[
debug.configitems = cfe({
name = "configitems",
label="configitems",
option=configitems,
type="select",
})
-
+--]]
debug.configfiles = cfe({
name = "configfiles",
label="configfiles",
diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp
index b8ac060..27fe91a 100644
--- a/tinydns-status-html.lsp
+++ b/tinydns-status-html.lsp
@@ -39,6 +39,70 @@ local tags = { "status", "version", }
displayinfo(myform,tags,"viewonly")
?>
+<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
+<?
+local v = "locations"
+--displayinfo(myform,tags)
+io.write("<DL>")
+--for k,v in pairs(tags) do
+if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+
+
+ io.write("\t\t<DD>\n")
+ for k,v in pairs(myform[v]["value"]) do
+ io.write("<IMG SRC='/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>")
+ for kk,vv in pairs(v) do
+ io.write(tostring("<BR>" ..vv.option[3]).. "\n")
+ end
+ io.write("<BR>")
+ end
+
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+end
+--end
+io.write("</DL>")
+?>
+
+<?
+local v = "types"
+--displayinfo(myform,tags)
+io.write("<DL>")
+--for k,v in pairs(tags) do
+if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+
+
+ io.write("\t\t<DD>\n")
+ for k,v in pairs(myform[v]["value"]) do
+ io.write("<IMG SRC='/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>")
+ for kk,vv in pairs(v) do
+ io.write(tostring("<BR>" ..vv.option[3]).. "\n")
+ end
+ io.write("<BR>")
+ end
+
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+end
+--end
+io.write("</DL>")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")