diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-03-03 17:02:17 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-03-03 17:02:17 +0000 |
commit | 1c2f8cc575dfd808e69487cb586c27d5b46a532c (patch) | |
tree | e6bb2514a6e96bfce2ae7d042d9c8471bf4b954f | |
parent | f5c7e2c77336d274e40b38407395c40e83149ae8 (diff) | |
download | acf-tinydns-1c2f8cc575dfd808e69487cb586c27d5b46a532c.tar.bz2 acf-tinydns-1c2f8cc575dfd808e69487cb586c27d5b46a532c.tar.xz |
Saving work for today. Filtering is starting to take shape.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@797 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | tinydns-controller.lua | 98 | ||||
-rw-r--r-- | tinydns-model.lua | 63 |
2 files changed, 92 insertions, 69 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 122470d..a5f804d 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -68,72 +68,97 @@ function status(self) value=locations, }) ----[[ local prefix = "." + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.nsourdomain = cfe ({ name="nsourdomain", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "&" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.nsdomain = cfe ({ name="nsdomain", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "=" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.host = cfe ({ name="host", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "+" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.alias = cfe ({ name="alias", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "@" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.mx = cfe ({ name="mx", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "^" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.ptr = cfe ({ name="ptr", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "C" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.cname = cfe ({ name="cname", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = "Z" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.soa = cfe ({ name="soa", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) + end local prefix = ":" + local domainoptions = self.model.getconfigobjects(self,prefix) + if (#domainoptions > 0) then config.settings.generic = cfe ({ name="generic", label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), + value=domainoptions, }) - ---]] + end --[[ + -- This could be used for DEBUGGING config.settings.all = cfe ({ name="generic", label="All available records", @@ -152,8 +177,6 @@ function config(self) local config = self.model.getconfig(self) local debug = self.model.getdebug(self) local availablesigns = self.model.check_signs("prefix") --- local debug = self..status(self) --- debug = self -- LISTEN _________________________________________________________ -- Add button @@ -207,7 +230,7 @@ function config(self) type="select", label=availablesigns[prefix], option=domainopts, - descr="Above records look like '.fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '.fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.nsourdomain.option, "[New]") @@ -238,12 +261,8 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like '&fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '&fqdn:ip:x:ttl:timestamp:lo' when they are in the config-file.", }) - -- Add options --- for n in pairs(locations) do --- table.insert(config.nsdomain.option, n) --- end -- Add a [New] record to the options table.insert(config.nsdomain.option, "[New]") -- Set size of the inputbox @@ -274,7 +293,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like '=fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '=fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.host.option, "[New]") @@ -306,7 +325,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like '+fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '+fqdn:ip:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.alias.option, "[New]") @@ -338,7 +357,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like '@fqdn:ip:x:dist:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '@fqdn:ip:x:dist:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.mx.option, "[New]") @@ -370,7 +389,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like '^fqdn:p:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like '^fqdn:p:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.ptr.option, "[New]") @@ -402,7 +421,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like 'Cfqdn:p:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like 'Cfqdn:p:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.cname.option, "[New]") @@ -434,7 +453,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like 'Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like 'Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.soa.option, "[New]") @@ -466,7 +485,7 @@ function config(self) label=availablesigns[prefix], type="select", option=domainopts, - descr="Above records look like ':fqdn:n:rdata:ttl:timestamp:lo' when they are in the config-file.", +-- descr="Above records look like ':fqdn:n:rdata:ttl:timestamp:lo' when they are in the config-file.", }) -- Add a [New] record to the options table.insert(config.generic.option, "[New]") @@ -487,12 +506,35 @@ function config(self) }) + -- DEBUGGING + local level1 = {} + local level2 = {} + local level3 = {} + local domainoptions = self.model.getconfigobjects(self) + for k1,v1 in pairs(domainoptions) do + table.insert(level1, v1.label) + for k2,v2 in pairs(v1) do + table.insert(level2, v2.label) + if (type(v2) == "table") then + for k3,v3 in pairs(v2) do + table.insert(level3, v3.label) + end + end + end + end + + config.debuglevels = cfe ({ + name="debuglevels", + label="Level1", + type="select", + option=domainoptions, + }) + return ({ status=getstatus(self), config=config, --- debug=debug, }) end diff --git a/tinydns-model.lua b/tinydns-model.lua index a68cda8..c45fb98 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -305,9 +305,24 @@ local function rebuild_table(t,domains_rebuilt) end end +-- This function removes all records that doesn't have the filter-value +local function filter_table(t1,domains_filtered,filter) + if not (type(t1) == "string") then + for k1,v1 in pairs(t1) do + for k2,v2 in pairs(v1) do + if (v2.label) then + if ( string.find(filter,v2.label) ) then + table.insert(domains_filtered, v2) + end + end + end + end + end +end + -- If you enter 'filter_type' (this should be one of the options found in local function check_signs() ) then -- the output will be filtered to only contain this type of data. -function getconfigobjects(self,filter_type) +function getconfigobjects(self,filter_type, filter_levels) local domains = {} --Loop through all available configfiles @@ -319,7 +334,7 @@ function getconfigobjects(self,filter_type) local filecontent_table = split_config_items(vv) -- Create domain information tables - local domain, level1, level2, level3, level4, level5, level6, levels + local domain -- * START * COMMONT SETTINGS *************************************************************************************** local descr=check_signs("prefix") @@ -526,13 +541,6 @@ function getconfigobjects(self,filter_type) option=domainoptions, }) ---[[ - table.insert(domainoptions, cfe ({ - name="debug", - label="Debug", - value=filter_type, - })) ---]] end -- * END * COMMONT SETTINGS *************************************************************************************** -- Inject the previous data into the right table @@ -560,39 +568,12 @@ function getconfigobjects(self,filter_type) local domains_rebuilt = {} rebuild_table(domains,domains_rebuilt) ---[==[ - for k1,v1 in pairsByKeys(domains) do - table.insert(domains_sorted, { name=k1 }) - for k2,v2 in pairsByKeys(v1) do - table.insert(domains_sorted[#domains_sorted], { name=k2 }) ----[=[ - if (v2) and (type(v2) == "table") then --- if not (v2.type) then - for k3,v3 in pairsByKeys(v2) do - if (v2[k3]["value"]) then - if not (domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"]) then - domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"] = {} - end --- table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"], domains[k1][k2] ) - else - table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]], { name=k3 }) - end - end --- else --- if not (domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"]) then --- domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"] = {} --- end --- table.insert(domains_sorted[#domains_sorted][#domains_sorted[#domains_sorted]]["value"], { name=v2, name=k3 } ) --- end - end ---]=] - end - end --- table.sort(domains_sorted) - ---]==] + -- Filter away not wanted records + local domains_filtered = {} + local filter_level2 = "cat.org" -- < This is DEBUG!!! REMOVE WHEN DONE! + filter_table(domains_rebuilt,domains_filtered,filter_level2) - return domains_rebuilt + return domains_filtered end |