summaryrefslogtreecommitdiffstats
path: root/tinydns-controller.lua
blob: f6c5268f7a957ab5bf1f5fb09d9b0afb53c846c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
module(..., package.seeall)

local newrecordtxt = "[New]"

local list_redir = function (self)
	self.conf.action = "status"
	self.conf.type = "redir"
	error (self.conf)
end

mvc = {}
mvc.on_load = function(self, parent)
	if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
		self.worker[self.conf.action] = list_redir(self)
	end
end

local function getstatus(self)
	local status = self.model.getstatus()
	if (#status.status.value > 0) then
		status.status.value = "Enabled"
	else
		status.status.value = "Disabled"
	end

	return status
end

local function filtertable(t,limit,counter)
	if not (counter) then counter = 0 end		
	counter = counter + 1

	if (t) then
		for k,v in pairs(t) do
			if (counter > (limit + 2)) then
					t[k] = nil
			end
			if (type(t[k]) == "table") then
				filtertable(v,limit,counter)
			end
		end
	end
end

local function unpackoptions(t,array,descrfield)
	for k,v in pairs(t) do
		if not (v.option) then
			if (type(v) == "table") then
				unpackoptions(v,array,descrfield)
			end
		else
			if (v.option[descrfield]) and (v.option[descrfield].value) then
				table.insert(array, v.label .. " (" .. v.option[descrfield].value .. ")")
			else
				table.insert(array, v.label)
			end
		end
	end
end

local function unpackoptionstooriginal(t,array,filter)
	for k,v in pairs(t) do
		if not (v.option) then
			if (type(v) == "table") then
				unpackoptionstooriginal(v,array,filter)
			end
		else
			if (v.orgrecordtable) and (v.orgrecordtable[2] == filter) then
				table.insert(array, v.orgrecordtable)
			end
		end
	end
end


-- ################################################################################
-- PUBLIC FUNCTIONS

function status(self)
	local config = {}
	config.settings = {}
	local locations=self.model.getlocations(self)
	local availablesigns = self.model.check_signs("prefix")

	config.locations = cfe ({
		name="locations",
		label="Defining locations",
		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=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=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=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=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=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=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=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=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=domainoptions,
		})
	end
--[[
	-- This could be used for DEBUGGING
	config.settings.all = cfe ({
		name="generic",
		label="All available records",
		value=self.model.getconfigobjects(self),
		})
--]]
	local counter

	return { 
		status=getstatus(self), 
		config=config,
		}
end
function expert(self)
	local cmdmanagement, cmdmanagementresult
	if ( self.clientdata.cmdmanagement) then
		cmdmanagement = cfe({ 
			name="cmdmanagement", 
			value=string.lower(self.clientdata.cmdmanagement),
			})
		cmdmanagementresult, cmdmanagement = self.model:startstop_service( cmdmanagement )
	end

	local status = getstatus(self)
	local config = self.model:getfilelist()

	return { 	
		option={ script=ENV["SCRIPT_NAME"],
			prefix=self.conf.prefix,
			controller = self.conf.controller,
			action = "expert", 
			link = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, },
		cmdmanagement = cmdmanagement,
		management = management,
		config = config, 
		status = status,
		startstop = startstop,
		debugclientdata = self.clientdata,
		}

end

function edit(self)
	local cmdmanagement, cmdmanagementresult, modifications
	if ( self.clientdata.cmdmanagement) then
		cmdmanagement = cfe({ 
			name="cmdmanagement", 
			value=string.lower(self.clientdata.cmdmanagement),
			})
		cmdmanagementresult, cmdmanagement = self.model:startstop_service( cmdmanagement )
	end

	-- Save changes
	if ( self.clientdata.cmdsave) then
		local filetochange = cfe ({ name=self.clientdata.filename, value=self.clientdata.filecontent, })
		modifications = self.model:updatefilecontent(filetochange)
		self.clientdata.name = self.clientdata.filename
	end

	local status = getstatus(self)
	local file = self.model:get_filedetails(self.clientdata.name)

	-- Add a cmd button to the view
	file.cmdsave = cfe({ name="cmdsave",
		label="Save/Apply above settings",
		value="Save",
		type="submit",
		disabled="yes",
		})

	return { 	
		option={ script=ENV["SCRIPT_NAME"],
			prefix=self.conf.prefix,
			controller = self.conf.controller,
			action = "edit", 
			link = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, },
		cmdmanagement = cmdmanagement,
		modifications = modifications,
		management = management,
		file = file, 
		status = status,
		startstop = startstop,
		debugclientdata = self.clientdata,
		}

end
--[=[
function edit_records(self,types,record,errormessage)
	local recorddetails = {}
	local edit = {}
	local config=self.model:getconfig()

	-- Fetch the original record into a table
	local availablesigns = self.model.check_signs()
	local prefix = availablesigns["reverse"][types]
	local domainopts = {}
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptionstooriginal(domainoptions, domainopts,string.match(record, "^%S*"))
	domainopts=unpack(domainopts)

	-- Display the inputfields (with the original record)
	local numfields = math.max(#domainopts,#availablesigns["fieldlabels"][prefix])
	for fieldnum=2,tonumber(numfields) do
		edit[fieldnum] = cfe({ 
			name=fieldnum,
			value=domainopts[fieldnum],
			label=availablesigns["fieldlabels"][prefix][fieldnum] or "",
			})
	end

	table.insert(edit, cfe({ 
			name=#edit,
			label="DEBUG: Original record",
			value=domainopts.orgrecord,
			errtxt="This field will go away soon! It's only for debugging!"
			}))

	-- Adding select-boxes
	local locationselectbox
	local locationfileds = {
			['.']=7,
			['&']=7,
			['=']=6,
			['+']=6,
			['@']=8,
			['^']=6,
			['C']=6,
			['Z']=12,
			[':']=7,
			}
	locationselectbox = locationfileds[prefix]
	if (locationselectbox) then
		local locations=self.model.getlocations(self)
		edit[locationselectbox]["option"] = {}
		edit[locationselectbox]["type"] = "select"
		table.insert(edit[locationselectbox]["option"], "")
		for v in pairs(locations or {}) do
			table.insert(edit[locationselectbox]["option"], v)
		end
		-- IF the value is not one of the existing options, then warn and add this option.
		for k,v in pairs(edit[locationselectbox]["option"]) do
			edit[locationselectbox]["errtxt"] = "'" .. edit[locationselectbox]["value"] .. "' is defined as a location!"
			if (tostring(v) == tostring(edit[locationselectbox]["value"])) then
				edit[locationselectbox]["errtxt"] = ""
				break
			end
		end
		-- Now add this option to the list (just to show what it was)
		if (#edit[locationselectbox]["errtxt"] > 0) then
			table.insert(edit[locationselectbox]["option"], edit[locationselectbox]["value"])
		end
	end

	return {
		edit=edit,
		option={ script=ENV["SCRIPT_NAME"],
			prefix=self.conf.prefix,
			controller = self.conf.controller,
			action = "config", 
			link = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, },
		cmdsave=cmdsave,
		cmddelete=cmddelete,
		clientdata=clientdata,
		debugtypes=types,
		debugrecord=string.match(record, "^%S*"),
		}
end
function config(self,messages)
	local config = self.model.getconfig(self)
	local debug = self.model.getdebug(self)
	local availablesigns = self.model.check_signs("prefix")

	-- LISTEN _________________________________________________________
	-- Add button
	config.listen_cmd = cfe ({
		name="listen_cmd",
		label="Save above changes",
		value="Save",
		type="submit",
		disabled="yes",
		})


	-- LOCATIONS _________________________________________________________
	local locations=self.model.getlocations(self)
	config.locations = cfe ({
		name="locations",
		label="Locations",
		option={},
		type="select",
		})
	-- Add options
	for n in pairs(locations) do
		table.insert(config.locations.option, n)
	end
	-- Add a [New] record to the options
--	table.insert(config.locations.option, newrecordtxt)
	-- Set size of the inputbox
	config.locations.size = #config.locations.option
	if (#config.locations.option == 1) then
		config.locations.size = #config.locations.option + 1
	end

	-- Add button
	config.locations_cmd = cfe ({
		name="locations_cmd",
		label="Edit above location",
		value="Edit",
		descr="Mark a item in '" .. config.locations.label .. "'-list before pressing [Edit]",
		type="submit",
		disabled="yes",
		})

	-- Nameservers _________________________________________________________
	local prefix = "."
	local domainopts = {}
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.nsourdomain = cfe ({
		name="nsourdomain",
		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.",
		})
	-- Add a [New] record to the options
--	table.insert(config.nsourdomain.option, newrecordtxt)
	-- Set size of the inputbox
	config.nsourdomain.size = #config.nsourdomain.option
	if (#config.nsourdomain.option == 1) then
		config.nsourdomain.size = #config.nsourdomain.option + 1
	end

	-- Add button
	config.nsourdomain_cmd = cfe ({
		name="nsourdomain_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.nsourdomain.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- Nameservers _________________________________________________________
	local prefix = "&"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.nsdomain = cfe ({
		name="nsdomain",
		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.",
		})
	-- Add a [New] record to the options
--	table.insert(config.nsdomain.option, newrecordtxt)
	-- Set size of the inputbox
	config.nsdomain.size = #config.nsdomain.option
	if (#config.nsdomain.option == 1) then
		config.nsdomain.size = #config.nsdomain.option + 1
	end

	-- Add button
	config.nsdomain_cmd = cfe ({
		name="nsdomain_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.nsdomain.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- Host _________________________________________________________
	local prefix = "="
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.host = cfe ({
		name="host",
		label=availablesigns[prefix],
		type="select",
		option=domainopts,
--		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, newrecordtxt)
	-- Set size of the inputbox
	config.host.size = #config.host.option
	if (#config.host.option == 1) then
		config.host.size = #config.host.option + 1
	end

	-- Add button
	config.host_cmd = cfe ({
		name="host_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.host.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- Alias _________________________________________________________
	local prefix = "+"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.alias = cfe ({
		name="alias",
		label=availablesigns[prefix],
		type="select",
		option=domainopts,
--		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, newrecordtxt)
	-- Set size of the inputbox
	config.alias.size = #config.alias.option
	if (#config.alias.option == 1) then
		config.alias.size = #config.alias.option + 1
	end

	-- Add button
	config.alias_cmd = cfe ({
		name="alias_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.alias.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- MX _________________________________________________________
	local prefix = "@"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.mx = cfe ({
		name="mx",
		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.",
		})
	-- Add a [New] record to the options
--	table.insert(config.mx.option, newrecordtxt)
	-- Set size of the inputbox
	config.mx.size = #config.mx.option
	if (#config.mx.option == 1) then
		config.mx.size = #config.mx.option + 1
	end

	-- Add button
	config.mx_cmd = cfe ({
		name="mx_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.mx.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- PTR _________________________________________________________
	local prefix = "^"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.ptr = cfe ({
		name="ptr",
		label=availablesigns[prefix],
		type="select",
		option=domainopts,
--		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, newrecordtxt)
	-- Set size of the inputbox
	config.ptr.size = #config.ptr.option
	if (#config.ptr.option == 1) then
		config.ptr.size = #config.ptr.option + 1
	end

	-- Add button
	config.ptr_cmd = cfe ({
		name="ptr_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.ptr.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- Cname _________________________________________________________
	local prefix = "C"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.cname = cfe ({
		name="cname",
		label=availablesigns[prefix],
		type="select",
		option=domainopts,
--		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, newrecordtxt)
	-- Set size of the inputbox
	config.cname.size = #config.cname.option
	if (#config.cname.option == 1) then
		config.cname.size = #config.cname.option + 1
	end

	-- Add button
	config.cname_cmd = cfe ({
		name="cname_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.cname.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- SOA _________________________________________________________
	local prefix = "Z"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.soa = cfe ({
		name="soa",
		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.",
		})
	-- Add a [New] record to the options
--	table.insert(config.soa.option, newrecordtxt)
	-- Set size of the inputbox
	config.soa.size = #config.soa.option
	if (#config.soa.option == 1) then
		config.soa.size = #config.soa.option + 1
	end

	-- Add button
	config.soa_cmd = cfe ({
		name="soa_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.soa.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})

	-- GENERIC _________________________________________________________
	local prefix = ":"
	local domainoptions = self.model.getconfigobjects(self,prefix)
	local domainopts = {}
	-- Filter out options
	local descrfield = 2 	-- This is the filed that is shown as description (in the select-box)
	unpackoptions(domainoptions, domainopts,descrfield)
	config.generic = cfe ({
		name="generic",
		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.",
		})
	-- Add a [New] record to the options
--	table.insert(config.generic.option, newrecordtxt)
	-- Set size of the inputbox
	config.generic.size = #config.generic.option
	if (#config.generic.option == 1) then
		config.generic.size = #config.generic.option + 1
	end

	-- Add button
	config.generic_cmd = cfe ({
		name="generic_cmd",
		label="Edit above item",
		value="Edit",
		descr="Mark a item in '" .. config.generic.label .. "'-list before pressing [Edit]",
		type="submit",
--		disabled="yes",
		})


	-- 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,
		})
--]]


	-- Redirect if button is pressed ***********************************
	local tags = {"locations", "nsourdomain", "nsdomain", "host", "alias", "mx", "ptr", "cname", "soa", "generic", }
	for k,tag in pairs(tags) do
		if (self.clientdata[tag .. "_cmd"]) and (self.clientdata[tag]) then
			self.conf.action = "edit_records"
			self.conf.type = "redir"
			return edit_records(self,tag, self.clientdata[tag])
		elseif (self.clientdata[tag .. "_cmd"]) and not (self.clientdata[tag]) then
			config[tag .. "_cmd"]["errtxt"] = "You need to specify a record to edit!"
		end
	end


	return ({
		status=getstatus(self),
		config=config,
		option={ script=ENV["SCRIPT_NAME"],
			prefix=self.conf.prefix,
			controller = self.conf.controller,
			action = "config", 
			link = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, },

	 	})
end
--]=]