source: trunk/dns-rpc.cgi@ 494

Last change on this file since 494 was 490, checked in by Kris Deugau, 12 years ago

/trunk

Tweak RPC to run as FastCGI, and add another config option to control
the number of requests to handle before respawning

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 20.9 KB
Line 
1#!/usr/bin/perl -w -T
2# XMLRPC interface to manipulate most DNS DB entities
3##
4# $Id: dns-rpc.cgi 490 2013-04-09 19:18:00Z kdeugau $
5# Copyright 2012 Kris Deugau <kdeugau@deepnet.cx>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19##
20
21use strict;
22use warnings;
23
24# don't remove! required for GNU/FHS-ish install from tarball
25use lib '.'; ##uselib##
26use DNSDB;
27
28use FCGI;
29#use Frontier::RPC2;
30use Frontier::Responder;
31
32## We need to handle a couple of things globally, rather than pasting the same bit into *every* sub.
33## So, let's subclass Frontier::RPC2 + Frontier::Responder, so we can override the single sub in each
34## that needs kicking
35#### hmm. put this in a separate file?
36#package DNSDB::RPC;
37#our @ISA = ("Frontier::RPC2", "Frontier::Responder");
38#package main;
39
40my $dnsdb = DNSDB->new();
41
42my $methods = {
43 'dnsdb.addDomain' => \&addDomain,
44 'dnsdb.delZone' => \&delZone,
45 'dnsdb.addRDNS' => \&addRDNS,
46 'dnsdb.addGroup' => \&addGroup,
47 'dnsdb.delGroup' => \&delGroup,
48 'dnsdb.addUser' => \&addUser,
49 'dnsdb.updateUser' => \&updateUser,
50 'dnsdb.delUser' => \&delUser,
51 'dnsdb.getLocDropdown' => \&getLocDropdown,
52 'dnsdb.getSOA' => \&getSOA,
53 'dnsdb.getRecLine' => \&getRecLine,
54 'dnsdb.getDomRecs' => \&getDomRecs,
55 'dnsdb.getRecCount' => \&getRecCount,
56 'dnsdb.addRec' => \&addRec,
57 'dnsdb.updateRec' => \&updateRec,
58 'dnsdb.addOrUpdateRevRec' => \&addOrUpdateRevRec,
59 'dnsdb.delRec' => \&delRec,
60 'dnsdb.delByCIDR' => \&delByCIDR,
61#sub getLogCount {}
62#sub getLogEntries {}
63 'dnsdb.getRevPattern' => \&getRevPattern,
64 'dnsdb.zoneStatus' => \&zoneStatus,
65 'dnsdb.getZonesByCIDR' => \&getZonesByCIDR,
66
67 'dnsdb.getMethods' => \&get_method_list
68};
69
70my $reqcnt = 0;
71
72while (FCGI::accept >= 0) {
73 my $res = Frontier::Responder->new(
74 methods => $methods
75 );
76
77 # "Can't do that" errors
78 if (!$dnsdb) {
79 print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $dnsdb->err);
80 } else {
81 print $res->answer;
82 }
83 last if $reqcnt++ > $dnsdb->{maxfcgi};
84} # while FCGI::accept
85
86
87exit;
88
89##
90## Subs below here
91##
92
93# Check RPC ACL
94sub _aclcheck {
95 my $subsys = shift;
96 return 1 if grep /$ENV{REMOTE_ADDR}/, @{$dnsdb->{rpcacl}{$subsys}};
97 return 0;
98}
99
100# Let's see if we can factor these out of the RPC method subs
101sub _commoncheck {
102 my $argref = shift;
103 my $needslog = shift;
104
105 die "Missing remote system name\n" if !$argref->{rpcsystem};
106 die "Access denied\n" if !_aclcheck($argref->{rpcsystem});
107 if ($needslog) {
108 die "Missing remote username\n" if !$argref->{rpcuser};
109 die "Couldn't set userdata for logging\n"
110 unless $dnsdb->initRPC(username => $argref->{rpcuser}, rpcsys => $argref->{rpcsystem},
111 fullname => ($argref->{fullname} ? $argref->{fullname} : $argref->{rpcuser}) );
112 }
113}
114
115# set location to the zone's default location if none is specified
116sub _loccheck {
117 my $argref = shift;
118 if (!$argref->{location} && $argref->{defrec} eq 'n') {
119 $argref->{location} = $dnsdb->getZoneLocation($argref->{revrec}, $argref->{parent_id});
120 }
121}
122
123# set ttl to zone defailt minttl if none is specified
124sub _ttlcheck {
125 my $argref = shift;
126 if (!$argref->{ttl}) {
127 my $tmp = $dnsdb->getSOA($argref->{defrec}, $argref->{revrec}, $argref->{parent_id});
128 $argref->{ttl} = $tmp->{minttl};
129 }
130}
131
132#sub connectDB {
133#sub finish {
134#sub initGlobals {
135#sub initPermissions {
136#sub getPermissions {
137#sub changePermissions {
138#sub comparePermissions {
139#sub changeGroup {
140#sub _log {
141
142sub addDomain {
143 my %args = @_;
144
145 _commoncheck(\%args, 'y');
146
147 my ($code, $msg) = $dnsdb->addDomain($args{domain}, $args{group}, $args{state});
148 die $msg if $code eq 'FAIL';
149 return $msg; # domain ID
150}
151
152sub delZone {
153 my %args = @_;
154
155 _commoncheck(\%args, 'y');
156 die "Need forward/reverse zone flag\n" if !$args{revrec};
157
158 my ($code,$msg);
159 # Let's be nice; delete based on zone id OR zone name. Saves an RPC call round-trip, maybe.
160 if ($args{zone} =~ /^\d+$/) {
161 ($code,$msg) = $dnsdb->delZone($args{zone}, $args{revrec});
162 } else {
163 my $zoneid;
164 $zoneid = $dnsdb->domainID($args{zone}) if $args{revrec} eq 'n';
165 $zoneid = $dnsdb->revID($args{zone}) if $args{revrec} eq 'y';
166 die "Can't find zone: $dnsdb->errstr\n" if !$zoneid;
167 ($code,$msg) = $dnsdb->delZone($zoneid, $args{revrec});
168 }
169 die $msg if $code eq 'FAIL';
170 return $msg;
171}
172
173#sub domainName {}
174#sub revName {}
175#sub domainID {}
176#sub revID {}
177
178sub addRDNS {
179 my %args = @_;
180
181 _commoncheck(\%args, 'y');
182
183 my ($code, $msg) = $dnsdb->addRDNS($args{revzone}, $args{revpatt}, $args{group}, $args{state}, $args{defloc});
184 die "$msg\n" if $code eq 'FAIL';
185 return $msg; # domain ID
186}
187
188#sub getZoneCount {}
189#sub getZoneList {}
190#sub getZoneLocation {}
191
192sub addGroup {
193 my %args = @_;
194
195 _commoncheck(\%args, 'y');
196 die "Missing new group name\n" if !$args{groupname};
197 die "Missing parent group ID\n" if !$args{parent_id};
198
199# not sure how to usefully represent permissions via RPC. :/
200# not to mention, permissions are checked at the UI layer, not the DB layer.
201 my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1,
202 record_edit => 1, record_create => 1, record_delete => 1
203 };
204## optional $inhert arg?
205 my ($code,$msg) = $dnsdb->addGroup($args{groupname}, $args{parent_id}, $perms);
206 die $msg if $code eq 'FAIL';
207 return $msg;
208}
209
210sub delGroup {
211 my %args = @_;
212
213 _commoncheck(\%args, 'y');
214 die "Missing group ID or name to remove\n" if !$args{group};
215
216 my ($code,$msg);
217 # Let's be nice; delete based on groupid OR group name. Saves an RPC call round-trip, maybe.
218 if ($args{group} =~ /^\d+$/) {
219 ($code,$msg) = $dnsdb->delGroup($args{group});
220 } else {
221 my $grpid = $dnsdb->groupID($args{group});
222 die "Can't find group\n" if !$grpid;
223 ($code,$msg) = $dnsdb->delGroup($grpid);
224 }
225 die $msg if $code eq 'FAIL';
226 return $msg;
227}
228
229#sub getChildren {}
230#sub groupName {}
231#sub getGroupCount {}
232#sub getGroupList {}
233#sub groupID {}
234
235sub addUser {
236 my %args = @_;
237
238 _commoncheck(\%args, 'y');
239
240# not sure how to usefully represent permissions via RPC. :/
241# not to mention, permissions are checked at the UI layer, not the DB layer.
242 # bend and twist; get those arguments in in the right order!
243 $args{type} = 'u' if !$args{type};
244 $args{permstring} = 'i' if !defined($args{permstring});
245 my @userargs = ($args{username}, $args{group}, $args{pass}, $args{state}, $args{type}, $args{permstring});
246 for my $argname ('fname','lname','phone') {
247 last if !$args{$argname};
248 push @userargs, $args{$argname};
249 }
250 my ($code,$msg) = $dnsdb->addUser(@userargs);
251 die $msg if $code eq 'FAIL';
252 return $msg;
253}
254
255#sub getUserCount {}
256#sub getUserList {}
257#sub getUserDropdown {}
258#sub checkUser {}
259
260sub updateUser {
261 my %args = @_;
262
263 _commoncheck(\%args, 'y');
264
265 die "Missing UID\n" if !$args{uid};
266
267 # bend and twist; get those arguments in in the right order!
268 $args{type} = 'u' if !$args{type};
269 my @userargs = ($args{uid}, $args{username}, $args{group}, $args{pass}, $args{state}, $args{type});
270 for my $argname ('fname','lname','phone') {
271 last if !$args{$argname};
272 push @userargs, $args{$argname};
273 }
274##fixme: also underlying in DNSDB::updateUser(): no way to just update this or that attribute;
275# have to pass them all in to be overwritten
276 my ($code,$msg) = $dnsdb->updateUser(@userargs);
277 die $msg if $code eq 'FAIL';
278 return $msg;
279}
280
281sub delUser {
282 my %args = @_;
283
284 _commoncheck(\%args, 'y');
285
286 die "Missing UID\n" if !$args{uid};
287 my ($code,$msg) = $dnsdb->delUser($args{uid});
288 die $msg if $code eq 'FAIL';
289 return $msg;
290}
291
292#sub userFullName {}
293#sub userStatus {}
294#sub getUserData {}
295
296#sub addLoc {}
297#sub updateLoc {}
298#sub delLoc {}
299#sub getLoc {}
300#sub getLocCount {}
301#sub getLocList {}
302
303sub getLocDropdown {
304 my %args = @_;
305
306 _commoncheck(\%args);
307 $args{defloc} = '' if !$args{defloc};
308
309 my $ret = $dnsdb->getLocDropdown($args{group}, $args{defloc});
310 return $ret;
311}
312
313sub getSOA {
314 my %args = @_;
315
316 _commoncheck(\%args);
317
318 my $ret = $dnsdb->getSOA($args{defrec}, $args{revrec}, $args{id});
319 if (!$ret) {
320 if ($args{defrec} eq 'y') {
321 die "No default SOA record in group\n";
322 } else {
323 die "No SOA record in zone\n";
324 }
325 }
326 return $ret;
327}
328
329#sub updateSOA {}
330
331sub getRecLine {
332 my %args = @_;
333
334 _commoncheck(\%args);
335
336 my $ret = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id});
337
338 die $dnsdb->errstr if !$ret;
339
340 return $ret;
341}
342
343sub getDomRecs {
344 my %args = @_;
345
346 _commoncheck(\%args);
347
348 # set some optional args
349 $args{nrecs} = 'all' if !$args{nrecs};
350 $args{nstart} = 0 if !$args{nstart};
351## for order, need to map input to column names
352 $args{order} = 'host' if !$args{order};
353 $args{direction} = 'ASC' if !$args{direction};
354
355 my $ret = $dnsdb->getDomRecs(defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id},
356 offset => $args{offset}, sortby => $args{sortby}, sortorder => $args{sortorder},
357 filter => $args{filter});
358
359 die $dnsdb->errstr if !$ret;
360
361 return $ret;
362}
363
364sub getRecCount {
365 my %args = @_;
366
367 _commoncheck(\%args);
368
369 # set some optional args
370 $args{nrecs} = 'all' if !$args{nrecs};
371 $args{nstart} = 0 if !$args{nstart};
372## for order, need to map input to column names
373 $args{order} = 'host' if !$args{order};
374 $args{direction} = 'ASC' if !$args{direction};
375
376 my $ret = $dnsdb->getRecCount($args{defrec}, $args{revrec}, $args{id}, $args{filter});
377
378 die $dnsdb->errstr if !$ret;
379
380 return $ret;
381}
382
383sub addRec {
384 my %args = @_;
385
386 _commoncheck(\%args, 'y');
387
388 _loccheck(\%args);
389 _ttlcheck(\%args);
390
391 my @recargs = ($args{defrec}, $args{revrec}, $args{parent_id},
392 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location});
393 if ($args{type} == $DNSDB::reverse_typemap{MX} or $args{type} == $DNSDB::reverse_typemap{SRV}) {
394 push @recargs, $args{distance};
395 if ($args{type} == $DNSDB::reverse_typemap{SRV}) {
396 push @recargs, $args{weight};
397 push @recargs, $args{port};
398 }
399 }
400
401 my ($code, $msg) = $dnsdb->addRec(@recargs);
402
403 die $msg if $code eq 'FAIL';
404 return $msg;
405}
406
407sub updateRec {
408 my %args = @_;
409
410 _commoncheck(\%args, 'y');
411
412 # get old line, so we can update only the bits that the caller passed to change
413 # note we subbed address for val since it's a little more caller-friendly
414 my $oldrec = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id});
415 foreach my $field (qw(name type address ttl location distance weight port)) {
416 $args{$field} = $oldrec->{$field} if !$args{$field} && defined($oldrec->{$field});
417 }
418
419 # note dist, weight, port are not required on all types; will be ignored if not needed.
420 # parent_id is the "primary" zone we're updating; necessary for forward/reverse voodoo
421 my ($code, $msg) = $dnsdb->updateRec($args{defrec}, $args{revrec}, $args{id}, $args{parent_id},
422 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location},
423 $args{distance}, $args{weight}, $args{port});
424
425 die $msg if $code eq 'FAIL';
426 return $msg;
427}
428
429# Takes a passed CIDR block and DNS pattern; adds a new record or updates the record(s) affected
430sub addOrUpdateRevRec {
431 my %args = @_;
432
433 _commoncheck(\%args, 'y');
434 my $cidr = new NetAddr::IP $args{cidr};
435
436 my $zonelist = $dnsdb->getZonesByCIDR(%args);
437 if (scalar(@$zonelist) == 0) {
438 # enhh.... WTF?
439 } elsif (scalar(@$zonelist) == 1) {
440 # check if the single zone returned is bigger than the CIDR. if so, we can just add a record
441 my $zone = new NetAddr::IP $zonelist->[0]->{revnet};
442 if ($zone->contains($cidr)) {
443 # We need to strip the CIDR mask on IPv4 /32 assignments, or we just add a new record all the time.
444 my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr);
445 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y',
446 id => $zonelist->[0]->{rdns_id}, filter => $filt);
447 if (scalar(@$reclist) == 0) {
448 # Aren't Magic Numbers Fun? See pseudotype list in dnsadmin.
449 my $type = ($cidr->{isv6} ? 65284 : ($cidr->masklen == 32 ? 65280 : 65283) );
450 addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type,
451 address => "$cidr", %args);
452 } else {
453 my $flag = 0;
454 foreach my $rec (@$reclist) {
455 # pure PTR plus composite types
456 next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281
457 || $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
458 next unless $rec->{val} eq $filt; # make sure we really update the record we want to update.
459 $dnsdb->updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},
460 parent_id => $zonelist->[0]->{rdns_id}, %args);
461 $flag = 1;
462 last; # only do one record.
463 }
464 unless ($flag) {
465 # Nothing was updated, so we didn't really have a match. Add as per @$reclist==0
466 # Aren't Magic Numbers Fun? See pseudotype list in dnsadmin.
467 my $type = ($cidr->{isv6} ? 65282 : ($cidr->masklen == 32 ? 65280 : 65283) );
468 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type,
469 address => "$cidr", %args);
470 }
471 }
472 } else {
473 # ebbeh? CIDR is only partly represented in DNS. This needs manual intervention.
474 } # done single-zone-contains-$cidr
475 } else {
476 # Overlapping reverse zones shouldn't be possible, so if we're here we've got a CIDR
477 # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones)
478 foreach my $zdata (@$zonelist) {
479 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y',
480 id => $zdata->{rdns_id}, filter => $zdata->{revnet});
481 if (scalar(@$reclist) == 0) {
482 my $type = ($args{cidr}->{isv6} ? 65282 : ($args{cidr}->masklen == 32 ? 65280 : 65283) );
483 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type,
484 address => "$args{cidr}", %args);
485 } else {
486 foreach my $rec (@$reclist) {
487 # only the composite and/or template types; pure PTR or nontemplate composite
488 # types are nominally impossible here.
489 next unless $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
490 $dnsdb->updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},
491 parent_id => $zdata->{rdns_id}, %args);
492 last; # only do one record.
493 }
494 }
495 } # iterate zones within $cidr
496 } # done $cidr-contains-zones
497}
498
499sub delRec {
500 my %args = @_;
501
502 _commoncheck(\%args, 'y');
503
504 my ($code, $msg) = $dnsdb->delRec($args{defrec}, $args{recrev}, $args{id});
505
506 die $msg if $code eq 'FAIL';
507 return $msg;
508}
509
510sub delByCIDR {
511 my %args = @_;
512
513 _commoncheck(\%args, 'y');
514
515 # much like addOrUpdateRevRec()
516 my $zonelist = $dnsdb->getZonesByCIDR(%args);
517 my $cidr = new NetAddr::IP $args{cidr};
518
519 if (scalar(@$zonelist) == 0) {
520 # enhh.... WTF?
521 } elsif (scalar(@$zonelist) == 1) {
522
523 # check if the single zone returned is bigger than the CIDR
524 my $zone = new NetAddr::IP $zonelist->[0]->{revnet};
525 if ($zone->contains($cidr)) {
526
527 if ($args{delsubs}) {
528 # Delete ALL EVARYTHING!!one11!! in $args{cidr}
529 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', id => $zonelist->[0]->{rdns_id});
530 foreach my $rec (@$reclist) {
531 my $reccidr = new NetAddr::IP $rec->{val};
532 next unless $cidr->contains($reccidr);
533 next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
534 $rec->{type} == 65282 || $rec->{type} == 65283 ||$rec->{type} == 65284;
535 ##fixme: multiple records, wanna wax'em all, how to report errors?
536 if ($args{delforward} ||
537 $rec->{type} == 12 || $rec->{type} == 65282 ||
538 $rec->{type} == 65283 || $rec->{type} == 65284) {
539 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
540 } else {
541 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
542 }
543 }
544 if ($args{parpatt} && $zone == $cidr) {
545 # Edge case; we've just gone and axed all the records in the reverse zone.
546 # Re-add one to match the parent if we've been given a pattern to use.
547 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id},
548 type => ($zone->{isv6} ? 65284 : 65283), address => "$cidr", %args);
549 }
550
551 } else {
552 # Selectively delete only exact matches on $args{cidr}
553
554 # We need to strip the CIDR mask on IPv4 /32 assignments, or we can't find single-IP records
555 my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr);
556 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y',
557 id => $zonelist->[0]->{rdns_id}, filter => $filt, sortby => 'val', sortorder => 'DESC');
558 foreach my $rec (@$reclist) {
559 my $reccidr = new NetAddr::IP $rec->{val};
560 next unless $cidr == $reccidr;
561 next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
562 $rec->{type} == 65282 || $rec->{type} == 65283 ||$rec->{type} == 65284;
563 if ($args{delforward} || $rec->{type} == 12) {
564 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
565 die $msg if $code eq 'FAIL';
566 return $msg;
567 } else {
568 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
569 die $dnsdb->errstr if !$ret;
570 return "A+PTR for $args{cidr} split and PTR removed";
571 }
572 } # foreach @$reclist
573 }
574
575 } else { # $cidr > $zone but we only have one zone
576 # ebbeh? CIDR is only partly represented in DNS. This needs manual intervention.
577 return "Warning: $args{cidr} is only partly represented in DNS. Check and remove DNS records manually.";
578 } # done single-zone-contains-$cidr
579
580 } else { # multiple zones nominally "contain" $cidr
581 # Overlapping reverse zones shouldn't be possible, so if we're here we've got a CIDR
582 # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones)
583 foreach my $zdata (@$zonelist) {
584 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', id => $zdata->{rdns_id});
585 if (scalar(@$reclist) == 0) {
586# nothing to do? or do we (re)add a record based on the parent?
587# yes, yes we do, past the close of the else
588# my $type = ($args{cidr}->{isv6} ? 65282 : ($args{cidr}->masklen == 32 ? 65280 : 65283) );
589# addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type,
590# address => "$args{cidr}", %args);
591 } else {
592 foreach my $rec (@$reclist) {
593 next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
594 $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
595 # Template types are only useful when attached to a reverse zone.
596##fixme ..... or ARE THEY?
597 if ($args{delforward} ||
598 $rec->{type} == 12 || $rec->{type} == 65282 ||
599 $rec->{type} == 65283 || $rec->{type} == 65284) {
600 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
601 } else {
602 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
603 }
604 } # foreach @$reclist
605 } # nrecs != 0
606 if ($args{parpatt}) {
607 # We've just gone and axed all the records in the reverse zone.
608 # Re-add one to match the parent if we've been given a pattern to use.
609 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id},
610 type => ($cidr->{isv6} ? 65284 : 65283),
611 address => $zdata->{revnet}, name => $args{parpatt}, %args);
612 }
613 } # iterate zones within $cidr
614 } # done $cidr-contains-zones
615
616} # end delByCIDR()
617
618#sub getLogCount {}
619#sub getLogEntries {}
620
621sub getRevPattern {
622 my %args = @_;
623
624 _commoncheck(\%args, 'y');
625
626 return $dnsdb->getRevPattern($args{cidr}, $args{group});
627}
628
629#sub getTypelist {}
630#sub parentID {}
631#sub isParent {}
632
633sub zoneStatus {
634 my %args = @_;
635
636 _commoncheck(\%args, 'y');
637
638 my @arglist = ($args{zoneid});
639 push @arglist, $args{status} if defined($args{status});
640
641 my $status = $dnsdb->zoneStatus(@arglist);
642}
643
644# Get a list of hashes referencing the reverse zone(s) for a passed CIDR block
645sub getZonesByCIDR {
646 my %args = @_;
647
648 _commoncheck(\%args, 'y');
649
650 return $dnsdb->getZonesByCIDR(%args);
651}
652
653#sub importAXFR {}
654#sub importBIND {}
655#sub import_tinydns {}
656#sub export {}
657#sub __export_tiny {}
658#sub _printrec_tiny {}
659#sub mailNotify {}
660
661sub get_method_list {
662 my @methods = keys %{$methods};
663 return \@methods;
664}
Note: See TracBrowser for help on using the repository browser.