[216] | 1 | #!/usr/bin/perl -w -T
|
---|
[262] | 2 | # XMLRPC interface to manipulate most DNS DB entities
|
---|
| 3 | ##
|
---|
[200] | 4 | # $Id: dns-rpc.cgi 678 2015-01-22 23:27:21Z kdeugau $
|
---|
[496] | 5 | # Copyright 2012,2013 Kris Deugau <kdeugau@deepnet.cx>
|
---|
[262] | 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 | ##
|
---|
[119] | 20 |
|
---|
| 21 | use strict;
|
---|
| 22 | use warnings;
|
---|
[216] | 23 |
|
---|
| 24 | # don't remove! required for GNU/FHS-ish install from tarball
|
---|
| 25 | use lib '.'; ##uselib##
|
---|
[490] | 26 | use DNSDB;
|
---|
[216] | 27 |
|
---|
[490] | 28 | use FCGI;
|
---|
[119] | 29 | #use Frontier::RPC2;
|
---|
| 30 | use 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 |
|
---|
[468] | 40 | my $dnsdb = DNSDB->new();
|
---|
[191] | 41 |
|
---|
[119] | 42 | my $methods = {
|
---|
[515] | 43 | #sub getPermissions {
|
---|
| 44 | #sub changePermissions {
|
---|
| 45 | #sub comparePermissions {
|
---|
| 46 | #sub changeGroup {
|
---|
[119] | 47 | 'dnsdb.addDomain' => \&addDomain,
|
---|
[401] | 48 | 'dnsdb.delZone' => \&delZone,
|
---|
[515] | 49 | #sub domainName {
|
---|
| 50 | #sub revName {
|
---|
[500] | 51 | 'dnsdb.domainID' => \&domainID,
|
---|
[515] | 52 | #sub revID {
|
---|
[405] | 53 | 'dnsdb.addRDNS' => \&addRDNS,
|
---|
[515] | 54 | #sub getZoneCount {
|
---|
| 55 | #sub getZoneList {
|
---|
| 56 | #sub getZoneLocation {
|
---|
[121] | 57 | 'dnsdb.addGroup' => \&addGroup,
|
---|
| 58 | 'dnsdb.delGroup' => \&delGroup,
|
---|
[515] | 59 | #sub getChildren {
|
---|
| 60 | #sub groupName {
|
---|
| 61 | #sub getGroupCount {
|
---|
| 62 | #sub getGroupList {
|
---|
| 63 | #sub groupID {
|
---|
[121] | 64 | 'dnsdb.addUser' => \&addUser,
|
---|
[515] | 65 | #sub getUserCount {
|
---|
| 66 | #sub getUserList {
|
---|
| 67 | #sub getUserDropdown {
|
---|
[121] | 68 | 'dnsdb.updateUser' => \&updateUser,
|
---|
| 69 | 'dnsdb.delUser' => \&delUser,
|
---|
[515] | 70 | #sub userFullName {
|
---|
| 71 | #sub userStatus {
|
---|
| 72 | #sub getUserData {
|
---|
| 73 | #sub addLoc {
|
---|
| 74 | #sub updateLoc {
|
---|
| 75 | #sub delLoc {
|
---|
| 76 | #sub getLoc {
|
---|
| 77 | #sub getLocCount {
|
---|
| 78 | #sub getLocList {
|
---|
[447] | 79 | 'dnsdb.getLocDropdown' => \&getLocDropdown,
|
---|
[121] | 80 | 'dnsdb.getSOA' => \&getSOA,
|
---|
[515] | 81 | #sub updateSOA {
|
---|
[123] | 82 | 'dnsdb.getRecLine' => \&getRecLine,
|
---|
[495] | 83 | 'dnsdb.getRecList' => \&getRecList,
|
---|
[123] | 84 | 'dnsdb.getRecCount' => \&getRecCount,
|
---|
[659] | 85 | 'dnsdb.addRec' => \&rpc_addRec,
|
---|
[675] | 86 | 'dnsdb.updateRec' => \&rpc_updateRec,
|
---|
[515] | 87 | #sub downconvert {
|
---|
[453] | 88 | 'dnsdb.addOrUpdateRevRec' => \&addOrUpdateRevRec,
|
---|
[676] | 89 | 'dnsdb.updateRevSet' => \&updateRevSet,
|
---|
[123] | 90 | 'dnsdb.delRec' => \&delRec,
|
---|
[459] | 91 | 'dnsdb.delByCIDR' => \&delByCIDR,
|
---|
[452] | 92 | #sub getLogCount {}
|
---|
| 93 | #sub getLogEntries {}
|
---|
| 94 | 'dnsdb.getRevPattern' => \&getRevPattern,
|
---|
[673] | 95 | 'dnsdb.getRevSet' => \&getRevSet,
|
---|
[506] | 96 | 'dnsdb.getTypelist' => \&getTypelist,
|
---|
[504] | 97 | 'dnsdb.getTypemap' => \&getTypemap,
|
---|
| 98 | 'dnsdb.getReverse_typemap' => \&getReverse_typemap,
|
---|
[515] | 99 | #sub parentID {
|
---|
| 100 | #sub isParent {
|
---|
[405] | 101 | 'dnsdb.zoneStatus' => \&zoneStatus,
|
---|
[452] | 102 | 'dnsdb.getZonesByCIDR' => \&getZonesByCIDR,
|
---|
[515] | 103 | #sub importAXFR {
|
---|
| 104 | #sub importBIND {
|
---|
| 105 | #sub import_tinydns {
|
---|
| 106 | #sub export {
|
---|
| 107 | #sub mailNotify {
|
---|
[121] | 108 |
|
---|
[119] | 109 | 'dnsdb.getMethods' => \&get_method_list
|
---|
| 110 | };
|
---|
| 111 |
|
---|
[490] | 112 | my $reqcnt = 0;
|
---|
| 113 |
|
---|
| 114 | while (FCGI::accept >= 0) {
|
---|
| 115 | my $res = Frontier::Responder->new(
|
---|
[119] | 116 | methods => $methods
|
---|
| 117 | );
|
---|
| 118 |
|
---|
[490] | 119 | # "Can't do that" errors
|
---|
| 120 | if (!$dnsdb) {
|
---|
| 121 | print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $dnsdb->err);
|
---|
| 122 | } else {
|
---|
| 123 | print $res->answer;
|
---|
| 124 | }
|
---|
| 125 | last if $reqcnt++ > $dnsdb->{maxfcgi};
|
---|
| 126 | } # while FCGI::accept
|
---|
[119] | 127 |
|
---|
| 128 |
|
---|
| 129 | exit;
|
---|
| 130 |
|
---|
| 131 | ##
|
---|
| 132 | ## Subs below here
|
---|
| 133 | ##
|
---|
| 134 |
|
---|
[490] | 135 | # Check RPC ACL
|
---|
[401] | 136 | sub _aclcheck {
|
---|
| 137 | my $subsys = shift;
|
---|
[486] | 138 | return 1 if grep /$ENV{REMOTE_ADDR}/, @{$dnsdb->{rpcacl}{$subsys}};
|
---|
[505] | 139 | warn "$subsys/$ENV{REMOTE_ADDR} not in ACL\n"; # a bit of logging
|
---|
[401] | 140 | return 0;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[405] | 143 | # Let's see if we can factor these out of the RPC method subs
|
---|
| 144 | sub _commoncheck {
|
---|
| 145 | my $argref = shift;
|
---|
| 146 | my $needslog = shift;
|
---|
| 147 |
|
---|
| 148 | die "Missing remote system name\n" if !$argref->{rpcsystem};
|
---|
| 149 | die "Access denied\n" if !_aclcheck($argref->{rpcsystem});
|
---|
| 150 | if ($needslog) {
|
---|
| 151 | die "Missing remote username\n" if !$argref->{rpcuser};
|
---|
| 152 | die "Couldn't set userdata for logging\n"
|
---|
[486] | 153 | unless $dnsdb->initRPC(username => $argref->{rpcuser}, rpcsys => $argref->{rpcsystem},
|
---|
| 154 | fullname => ($argref->{fullname} ? $argref->{fullname} : $argref->{rpcuser}) );
|
---|
[405] | 155 | }
|
---|
| 156 | }
|
---|
| 157 |
|
---|
[511] | 158 | # check for defrec and revrec; only call on subs that deal with records
|
---|
| 159 | sub _reccheck {
|
---|
| 160 | my $argref = shift;
|
---|
| 161 | die "Missing defrec and/or revrec flags\n" if !($argref->{defrec} || $argref->{revrec});
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[453] | 164 | # set location to the zone's default location if none is specified
|
---|
| 165 | sub _loccheck {
|
---|
| 166 | my $argref = shift;
|
---|
| 167 | if (!$argref->{location} && $argref->{defrec} eq 'n') {
|
---|
[477] | 168 | $argref->{location} = $dnsdb->getZoneLocation($argref->{revrec}, $argref->{parent_id});
|
---|
[453] | 169 | }
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | # set ttl to zone defailt minttl if none is specified
|
---|
| 173 | sub _ttlcheck {
|
---|
| 174 | my $argref = shift;
|
---|
| 175 | if (!$argref->{ttl}) {
|
---|
[486] | 176 | my $tmp = $dnsdb->getSOA($argref->{defrec}, $argref->{revrec}, $argref->{parent_id});
|
---|
[453] | 177 | $argref->{ttl} = $tmp->{minttl};
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
[119] | 181 | #sub connectDB {
|
---|
| 182 | #sub finish {
|
---|
| 183 | #sub initGlobals {
|
---|
| 184 | #sub initPermissions {
|
---|
| 185 | #sub getPermissions {
|
---|
| 186 | #sub changePermissions {
|
---|
| 187 | #sub comparePermissions {
|
---|
| 188 | #sub changeGroup {
|
---|
| 189 | #sub _log {
|
---|
| 190 |
|
---|
| 191 | sub addDomain {
|
---|
| 192 | my %args = @_;
|
---|
| 193 |
|
---|
[405] | 194 | _commoncheck(\%args, 'y');
|
---|
[119] | 195 |
|
---|
[516] | 196 | my ($code, $msg) = $dnsdb->addDomain($args{domain}, $args{group}, $args{state}, $args{location});
|
---|
[511] | 197 | die "$msg\n" if $code eq 'FAIL';
|
---|
[119] | 198 | return $msg; # domain ID
|
---|
| 199 | }
|
---|
| 200 |
|
---|
[401] | 201 | sub delZone {
|
---|
[119] | 202 | my %args = @_;
|
---|
| 203 |
|
---|
[405] | 204 | _commoncheck(\%args, 'y');
|
---|
| 205 | die "Need forward/reverse zone flag\n" if !$args{revrec};
|
---|
[119] | 206 |
|
---|
[121] | 207 | my ($code,$msg);
|
---|
[405] | 208 | # Let's be nice; delete based on zone id OR zone name. Saves an RPC call round-trip, maybe.
|
---|
| 209 | if ($args{zone} =~ /^\d+$/) {
|
---|
[477] | 210 | ($code,$msg) = $dnsdb->delZone($args{zone}, $args{revrec});
|
---|
[119] | 211 | } else {
|
---|
[405] | 212 | my $zoneid;
|
---|
[477] | 213 | $zoneid = $dnsdb->domainID($args{zone}) if $args{revrec} eq 'n';
|
---|
| 214 | $zoneid = $dnsdb->revID($args{zone}) if $args{revrec} eq 'y';
|
---|
[671] | 215 | die "Can't find zone: ".$dnsdb->errstr."\n" if !$zoneid;
|
---|
[477] | 216 | ($code,$msg) = $dnsdb->delZone($zoneid, $args{revrec});
|
---|
[119] | 217 | }
|
---|
[511] | 218 | die "$msg\n" if $code eq 'FAIL';
|
---|
[405] | 219 | return $msg;
|
---|
[119] | 220 | }
|
---|
| 221 |
|
---|
[405] | 222 | #sub domainName {}
|
---|
| 223 | #sub revName {}
|
---|
[500] | 224 |
|
---|
| 225 | sub domainID {
|
---|
| 226 | my %args = @_;
|
---|
| 227 |
|
---|
| 228 | _commoncheck(\%args, 'y');
|
---|
| 229 |
|
---|
| 230 | my $domid = $dnsdb->domainID($args{domain});
|
---|
[671] | 231 | die $dnsdb->errstr."\n" if !$domid;
|
---|
[500] | 232 | return $domid;
|
---|
| 233 | }
|
---|
| 234 |
|
---|
[405] | 235 | #sub revID {}
|
---|
[119] | 236 |
|
---|
[405] | 237 | sub addRDNS {
|
---|
| 238 | my %args = @_;
|
---|
| 239 |
|
---|
| 240 | _commoncheck(\%args, 'y');
|
---|
| 241 |
|
---|
[477] | 242 | my ($code, $msg) = $dnsdb->addRDNS($args{revzone}, $args{revpatt}, $args{group}, $args{state}, $args{defloc});
|
---|
[447] | 243 | die "$msg\n" if $code eq 'FAIL';
|
---|
[405] | 244 | return $msg; # domain ID
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | #sub getZoneCount {}
|
---|
| 248 | #sub getZoneList {}
|
---|
| 249 | #sub getZoneLocation {}
|
---|
| 250 |
|
---|
[119] | 251 | sub addGroup {
|
---|
| 252 | my %args = @_;
|
---|
| 253 |
|
---|
[405] | 254 | _commoncheck(\%args, 'y');
|
---|
[407] | 255 | die "Missing new group name\n" if !$args{groupname};
|
---|
| 256 | die "Missing parent group ID\n" if !$args{parent_id};
|
---|
[119] | 257 |
|
---|
[407] | 258 | # not sure how to usefully represent permissions via RPC. :/
|
---|
[121] | 259 | # not to mention, permissions are checked at the UI layer, not the DB layer.
|
---|
[119] | 260 | my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1,
|
---|
| 261 | record_edit => 1, record_create => 1, record_delete => 1
|
---|
| 262 | };
|
---|
| 263 | ## optional $inhert arg?
|
---|
[476] | 264 | my ($code,$msg) = $dnsdb->addGroup($args{groupname}, $args{parent_id}, $perms);
|
---|
[511] | 265 | die "$msg\n" if $code eq 'FAIL';
|
---|
[119] | 266 | return $msg;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | sub delGroup {
|
---|
| 270 | my %args = @_;
|
---|
| 271 |
|
---|
[405] | 272 | _commoncheck(\%args, 'y');
|
---|
[407] | 273 | die "Missing group ID or name to remove\n" if !$args{group};
|
---|
[119] | 274 |
|
---|
[121] | 275 | my ($code,$msg);
|
---|
[119] | 276 | # Let's be nice; delete based on groupid OR group name. Saves an RPC call round-trip, maybe.
|
---|
| 277 | if ($args{group} =~ /^\d+$/) {
|
---|
[476] | 278 | ($code,$msg) = $dnsdb->delGroup($args{group});
|
---|
[119] | 279 | } else {
|
---|
[486] | 280 | my $grpid = $dnsdb->groupID($args{group});
|
---|
[407] | 281 | die "Can't find group\n" if !$grpid;
|
---|
[476] | 282 | ($code,$msg) = $dnsdb->delGroup($grpid);
|
---|
[119] | 283 | }
|
---|
[511] | 284 | die "$msg\n" if $code eq 'FAIL';
|
---|
[407] | 285 | return $msg;
|
---|
[119] | 286 | }
|
---|
| 287 |
|
---|
[405] | 288 | #sub getChildren {}
|
---|
| 289 | #sub groupName {}
|
---|
| 290 | #sub getGroupCount {}
|
---|
| 291 | #sub getGroupList {}
|
---|
| 292 | #sub groupID {}
|
---|
[119] | 293 |
|
---|
| 294 | sub addUser {
|
---|
| 295 | my %args = @_;
|
---|
| 296 |
|
---|
[405] | 297 | _commoncheck(\%args, 'y');
|
---|
[119] | 298 |
|
---|
[409] | 299 | # not sure how to usefully represent permissions via RPC. :/
|
---|
[121] | 300 | # not to mention, permissions are checked at the UI layer, not the DB layer.
|
---|
[119] | 301 | # bend and twist; get those arguments in in the right order!
|
---|
| 302 | $args{type} = 'u' if !$args{type};
|
---|
| 303 | $args{permstring} = 'i' if !defined($args{permstring});
|
---|
| 304 | my @userargs = ($args{username}, $args{group}, $args{pass}, $args{state}, $args{type}, $args{permstring});
|
---|
| 305 | for my $argname ('fname','lname','phone') {
|
---|
| 306 | last if !$args{$argname};
|
---|
| 307 | push @userargs, $args{$argname};
|
---|
| 308 | }
|
---|
[479] | 309 | my ($code,$msg) = $dnsdb->addUser(@userargs);
|
---|
[511] | 310 | die "$msg\n" if $code eq 'FAIL';
|
---|
[119] | 311 | return $msg;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
[405] | 314 | #sub getUserCount {}
|
---|
| 315 | #sub getUserList {}
|
---|
| 316 | #sub getUserDropdown {}
|
---|
| 317 | #sub checkUser {}
|
---|
[119] | 318 |
|
---|
| 319 | sub updateUser {
|
---|
| 320 | my %args = @_;
|
---|
| 321 |
|
---|
[405] | 322 | _commoncheck(\%args, 'y');
|
---|
[119] | 323 |
|
---|
[401] | 324 | die "Missing UID\n" if !$args{uid};
|
---|
[121] | 325 |
|
---|
[119] | 326 | # bend and twist; get those arguments in in the right order!
|
---|
[411] | 327 | $args{type} = 'u' if !$args{type};
|
---|
[119] | 328 | my @userargs = ($args{uid}, $args{username}, $args{group}, $args{pass}, $args{state}, $args{type});
|
---|
| 329 | for my $argname ('fname','lname','phone') {
|
---|
| 330 | last if !$args{$argname};
|
---|
| 331 | push @userargs, $args{$argname};
|
---|
| 332 | }
|
---|
| 333 | ##fixme: also underlying in DNSDB::updateUser(): no way to just update this or that attribute;
|
---|
| 334 | # have to pass them all in to be overwritten
|
---|
[479] | 335 | my ($code,$msg) = $dnsdb->updateUser(@userargs);
|
---|
[511] | 336 | die "$msg\n" if $code eq 'FAIL';
|
---|
[412] | 337 | return $msg;
|
---|
[119] | 338 | }
|
---|
| 339 |
|
---|
| 340 | sub delUser {
|
---|
| 341 | my %args = @_;
|
---|
| 342 |
|
---|
[405] | 343 | _commoncheck(\%args, 'y');
|
---|
[119] | 344 |
|
---|
[401] | 345 | die "Missing UID\n" if !$args{uid};
|
---|
[479] | 346 | my ($code,$msg) = $dnsdb->delUser($args{uid});
|
---|
[511] | 347 | die "$msg\n" if $code eq 'FAIL';
|
---|
[412] | 348 | return $msg;
|
---|
[119] | 349 | }
|
---|
| 350 |
|
---|
[405] | 351 | #sub userFullName {}
|
---|
| 352 | #sub userStatus {}
|
---|
| 353 | #sub getUserData {}
|
---|
[119] | 354 |
|
---|
[405] | 355 | #sub addLoc {}
|
---|
| 356 | #sub updateLoc {}
|
---|
| 357 | #sub delLoc {}
|
---|
| 358 | #sub getLoc {}
|
---|
| 359 | #sub getLocCount {}
|
---|
| 360 | #sub getLocList {}
|
---|
| 361 |
|
---|
[447] | 362 | sub getLocDropdown {
|
---|
| 363 | my %args = @_;
|
---|
| 364 |
|
---|
| 365 | _commoncheck(\%args);
|
---|
| 366 | $args{defloc} = '' if !$args{defloc};
|
---|
| 367 |
|
---|
[480] | 368 | my $ret = $dnsdb->getLocDropdown($args{group}, $args{defloc});
|
---|
[447] | 369 | return $ret;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[119] | 372 | sub getSOA {
|
---|
| 373 | my %args = @_;
|
---|
| 374 |
|
---|
[405] | 375 | _commoncheck(\%args);
|
---|
[121] | 376 |
|
---|
[511] | 377 | _reccheck(\%args);
|
---|
| 378 |
|
---|
[481] | 379 | my $ret = $dnsdb->getSOA($args{defrec}, $args{revrec}, $args{id});
|
---|
[413] | 380 | if (!$ret) {
|
---|
| 381 | if ($args{defrec} eq 'y') {
|
---|
[401] | 382 | die "No default SOA record in group\n";
|
---|
[121] | 383 | } else {
|
---|
[413] | 384 | die "No SOA record in zone\n";
|
---|
[121] | 385 | }
|
---|
| 386 | }
|
---|
[413] | 387 | return $ret;
|
---|
[119] | 388 | }
|
---|
| 389 |
|
---|
[405] | 390 | #sub updateSOA {}
|
---|
| 391 |
|
---|
[119] | 392 | sub getRecLine {
|
---|
| 393 | my %args = @_;
|
---|
| 394 |
|
---|
[405] | 395 | _commoncheck(\%args);
|
---|
[123] | 396 |
|
---|
[511] | 397 | _reccheck(\%args);
|
---|
| 398 |
|
---|
[481] | 399 | my $ret = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id});
|
---|
[123] | 400 |
|
---|
[671] | 401 | die $dnsdb->errstr."\n" if !$ret;
|
---|
[123] | 402 |
|
---|
| 403 | return $ret;
|
---|
[119] | 404 | }
|
---|
| 405 |
|
---|
[495] | 406 | sub getRecList {
|
---|
[119] | 407 | my %args = @_;
|
---|
| 408 |
|
---|
[405] | 409 | _commoncheck(\%args);
|
---|
[123] | 410 |
|
---|
[500] | 411 | # deal gracefully with alternate calling convention for args{id}
|
---|
| 412 | $args{id} = $args{ID} if !$args{id} && $args{ID};
|
---|
| 413 | # ... and fail if we don't have one
|
---|
| 414 | die "Missing zone ID\n" if !$args{id};
|
---|
| 415 |
|
---|
[405] | 416 | # set some optional args
|
---|
[500] | 417 | $args{offset} = 0 if !$args{offset};
|
---|
[123] | 418 | ## for order, need to map input to column names
|
---|
| 419 | $args{order} = 'host' if !$args{order};
|
---|
| 420 | $args{direction} = 'ASC' if !$args{direction};
|
---|
[500] | 421 | $args{defrec} = 'n' if !$args{defrec};
|
---|
| 422 | $args{revrec} = 'n' if !$args{revrec};
|
---|
[123] | 423 |
|
---|
[500] | 424 | # convert zone name to zone ID, if needed
|
---|
| 425 | if ($args{defrec} eq 'n') {
|
---|
| 426 | if ($args{revrec} eq 'n') {
|
---|
| 427 | $args{id} = $dnsdb->domainID($args{id}) if $args{id} !~ /^\d+$/;
|
---|
| 428 | } else {
|
---|
| 429 | $args{id} = $dnsdb->revID($args{id}) if $args{id} !~ /^\d+$/
|
---|
| 430 | }
|
---|
| 431 | }
|
---|
| 432 |
|
---|
[502] | 433 | # fail if we *still* don't have a valid zone ID
|
---|
[671] | 434 | die $dnsdb->errstr."\n" if !$args{id};
|
---|
[502] | 435 |
|
---|
[500] | 436 | # and finally retrieve the records.
|
---|
[495] | 437 | my $ret = $dnsdb->getRecList(defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id},
|
---|
[500] | 438 | offset => $args{offset}, nrecs => $args{nrecs}, sortby => $args{sortby},
|
---|
| 439 | sortorder => $args{sortorder}, filter => $args{filter});
|
---|
[671] | 440 | die $dnsdb->errstr."\n" if !$ret;
|
---|
[123] | 441 |
|
---|
| 442 | return $ret;
|
---|
[119] | 443 | }
|
---|
| 444 |
|
---|
[123] | 445 | sub getRecCount {
|
---|
| 446 | my %args = @_;
|
---|
[119] | 447 |
|
---|
[405] | 448 | _commoncheck(\%args);
|
---|
[123] | 449 |
|
---|
[511] | 450 | _reccheck(\%args);
|
---|
| 451 |
|
---|
[405] | 452 | # set some optional args
|
---|
| 453 | $args{nrecs} = 'all' if !$args{nrecs};
|
---|
| 454 | $args{nstart} = 0 if !$args{nstart};
|
---|
| 455 | ## for order, need to map input to column names
|
---|
| 456 | $args{order} = 'host' if !$args{order};
|
---|
| 457 | $args{direction} = 'ASC' if !$args{direction};
|
---|
| 458 |
|
---|
[666] | 459 | my $ret = $dnsdb->getRecCount(defrec => $args{defrec}, revrec => $args{revrec},
|
---|
| 460 | id => $args{id}, filter => $args{filter});
|
---|
[405] | 461 |
|
---|
[671] | 462 | die $dnsdb->errstr."\n" if !$ret;
|
---|
[405] | 463 |
|
---|
| 464 | return $ret;
|
---|
[123] | 465 | }
|
---|
| 466 |
|
---|
[659] | 467 | sub rpc_addRec {
|
---|
[119] | 468 | my %args = @_;
|
---|
| 469 |
|
---|
[405] | 470 | _commoncheck(\%args, 'y');
|
---|
[123] | 471 |
|
---|
[511] | 472 | _reccheck(\%args);
|
---|
[453] | 473 | _loccheck(\%args);
|
---|
| 474 | _ttlcheck(\%args);
|
---|
[123] | 475 |
|
---|
[498] | 476 | # allow passing text types rather than DNS integer IDs
|
---|
[499] | 477 | $args{type} = $DNSDB::reverse_typemap{$args{type}} if $args{type} !~ /^\d+$/;
|
---|
[498] | 478 |
|
---|
[481] | 479 | my @recargs = ($args{defrec}, $args{revrec}, $args{parent_id},
|
---|
[543] | 480 | \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location},
|
---|
| 481 | $args{expires}, $args{stamp});
|
---|
[426] | 482 | if ($args{type} == $DNSDB::reverse_typemap{MX} or $args{type} == $DNSDB::reverse_typemap{SRV}) {
|
---|
| 483 | push @recargs, $args{distance};
|
---|
| 484 | if ($args{type} == $DNSDB::reverse_typemap{SRV}) {
|
---|
| 485 | push @recargs, $args{weight};
|
---|
| 486 | push @recargs, $args{port};
|
---|
| 487 | }
|
---|
| 488 | }
|
---|
| 489 |
|
---|
[481] | 490 | my ($code, $msg) = $dnsdb->addRec(@recargs);
|
---|
[426] | 491 |
|
---|
[511] | 492 | die "$msg\n" if $code eq 'FAIL';
|
---|
[426] | 493 | return $msg;
|
---|
[659] | 494 | } # rpc_addRec
|
---|
[119] | 495 |
|
---|
[675] | 496 | sub rpc_updateRec {
|
---|
[119] | 497 | my %args = @_;
|
---|
| 498 |
|
---|
[405] | 499 | _commoncheck(\%args, 'y');
|
---|
[123] | 500 |
|
---|
[511] | 501 | _reccheck(\%args);
|
---|
| 502 |
|
---|
[543] | 503 | # put some caller-friendly names in their rightful DB column places
|
---|
| 504 | $args{val} = $args{address};
|
---|
| 505 | $args{host} = $args{name};
|
---|
| 506 |
|
---|
[452] | 507 | # get old line, so we can update only the bits that the caller passed to change
|
---|
[481] | 508 | my $oldrec = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id});
|
---|
[543] | 509 | foreach my $field (qw(host type val ttl location expires distance weight port)) {
|
---|
[452] | 510 | $args{$field} = $oldrec->{$field} if !$args{$field} && defined($oldrec->{$field});
|
---|
| 511 | }
|
---|
[543] | 512 | # stamp has special handling when blank or 0. "undefined" from the caller should mean "don't change"
|
---|
[659] | 513 | $args{stamp} = $oldrec->{stamp} if !defined($args{stamp}) && $oldrec->{stampactive};
|
---|
[452] | 514 |
|
---|
[498] | 515 | # allow passing text types rather than DNS integer IDs
|
---|
[499] | 516 | $args{type} = $DNSDB::reverse_typemap{$args{type}} if $args{type} !~ /^\d+$/;
|
---|
[498] | 517 |
|
---|
[405] | 518 | # note dist, weight, port are not required on all types; will be ignored if not needed.
|
---|
[426] | 519 | # parent_id is the "primary" zone we're updating; necessary for forward/reverse voodoo
|
---|
[481] | 520 | my ($code, $msg) = $dnsdb->updateRec($args{defrec}, $args{revrec}, $args{id}, $args{parent_id},
|
---|
[543] | 521 | \$args{host}, \$args{type}, \$args{val}, $args{ttl}, $args{location},
|
---|
| 522 | $args{expires}, $args{stamp},
|
---|
[426] | 523 | $args{distance}, $args{weight}, $args{port});
|
---|
[123] | 524 |
|
---|
[511] | 525 | die "$msg\n" if $code eq 'FAIL';
|
---|
[426] | 526 | return $msg;
|
---|
[119] | 527 | }
|
---|
| 528 |
|
---|
[453] | 529 | # Takes a passed CIDR block and DNS pattern; adds a new record or updates the record(s) affected
|
---|
| 530 | sub addOrUpdateRevRec {
|
---|
| 531 | my %args = @_;
|
---|
| 532 |
|
---|
| 533 | _commoncheck(\%args, 'y');
|
---|
[459] | 534 | my $cidr = new NetAddr::IP $args{cidr};
|
---|
[453] | 535 |
|
---|
[477] | 536 | my $zonelist = $dnsdb->getZonesByCIDR(%args);
|
---|
[453] | 537 | if (scalar(@$zonelist) == 0) {
|
---|
| 538 | # enhh.... WTF?
|
---|
| 539 | } elsif (scalar(@$zonelist) == 1) {
|
---|
| 540 | # check if the single zone returned is bigger than the CIDR. if so, we can just add a record
|
---|
| 541 | my $zone = new NetAddr::IP $zonelist->[0]->{revnet};
|
---|
[459] | 542 | if ($zone->contains($cidr)) {
|
---|
[454] | 543 | # We need to strip the CIDR mask on IPv4 /32 assignments, or we just add a new record all the time.
|
---|
[459] | 544 | my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr);
|
---|
[495] | 545 | my $reclist = $dnsdb->getRecList(defrec => 'n', revrec => 'y',
|
---|
[454] | 546 | id => $zonelist->[0]->{rdns_id}, filter => $filt);
|
---|
[671] | 547 | ##fixme: Figure some new magic to automerge new incoming A(AAA)+PTR requests
|
---|
| 548 | # with existing A records to prevent duplication of A(AAA) records
|
---|
[453] | 549 | if (scalar(@$reclist) == 0) {
|
---|
| 550 | # Aren't Magic Numbers Fun? See pseudotype list in dnsadmin.
|
---|
[672] | 551 | my $type = ($cidr->{isv6} ? ($cidr->masklen == 128 ? 65281 : 65284) : ($cidr->masklen == 32 ? 65280 : 65283) );
|
---|
[659] | 552 | rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type,
|
---|
[459] | 553 | address => "$cidr", %args);
|
---|
[453] | 554 | } else {
|
---|
[459] | 555 | my $flag = 0;
|
---|
[453] | 556 | foreach my $rec (@$reclist) {
|
---|
[454] | 557 | # pure PTR plus composite types
|
---|
| 558 | next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281
|
---|
| 559 | || $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
|
---|
| 560 | next unless $rec->{val} eq $filt; # make sure we really update the record we want to update.
|
---|
[675] | 561 | rpc_updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},
|
---|
[672] | 562 | parent_id => $zonelist->[0]->{rdns_id}, address => "$cidr", %args);
|
---|
[459] | 563 | $flag = 1;
|
---|
[453] | 564 | last; # only do one record.
|
---|
| 565 | }
|
---|
[459] | 566 | unless ($flag) {
|
---|
| 567 | # Nothing was updated, so we didn't really have a match. Add as per @$reclist==0
|
---|
| 568 | # Aren't Magic Numbers Fun? See pseudotype list in dnsadmin.
|
---|
| 569 | my $type = ($cidr->{isv6} ? 65282 : ($cidr->masklen == 32 ? 65280 : 65283) );
|
---|
[659] | 570 | rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type,
|
---|
[459] | 571 | address => "$cidr", %args);
|
---|
| 572 | }
|
---|
[453] | 573 | }
|
---|
| 574 | } else {
|
---|
| 575 | # ebbeh? CIDR is only partly represented in DNS. This needs manual intervention.
|
---|
| 576 | } # done single-zone-contains-$cidr
|
---|
| 577 | } else {
|
---|
| 578 | # Overlapping reverse zones shouldn't be possible, so if we're here we've got a CIDR
|
---|
| 579 | # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones)
|
---|
| 580 | foreach my $zdata (@$zonelist) {
|
---|
[495] | 581 | my $reclist = $dnsdb->getRecList(defrec => 'n', revrec => 'y',
|
---|
[453] | 582 | id => $zdata->{rdns_id}, filter => $zdata->{revnet});
|
---|
| 583 | if (scalar(@$reclist) == 0) {
|
---|
| 584 | my $type = ($args{cidr}->{isv6} ? 65282 : ($args{cidr}->masklen == 32 ? 65280 : 65283) );
|
---|
[659] | 585 | rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type,
|
---|
[453] | 586 | address => "$args{cidr}", %args);
|
---|
| 587 | } else {
|
---|
| 588 | foreach my $rec (@$reclist) {
|
---|
[454] | 589 | # only the composite and/or template types; pure PTR or nontemplate composite
|
---|
| 590 | # types are nominally impossible here.
|
---|
[453] | 591 | next unless $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
|
---|
[678] | 592 | rpc_updateRec(defrec => 'n', revrec => 'y', id => $rec->{record_id},
|
---|
[453] | 593 | parent_id => $zdata->{rdns_id}, %args);
|
---|
| 594 | last; # only do one record.
|
---|
| 595 | }
|
---|
| 596 | }
|
---|
| 597 | } # iterate zones within $cidr
|
---|
| 598 | } # done $cidr-contains-zones
|
---|
[676] | 599 | ##fixme: what about errors? what about warnings?
|
---|
| 600 | } # done addOrUpdateRevRec()
|
---|
[453] | 601 |
|
---|
[676] | 602 | # Update rDNS on a whole batch of IP addresses. Presented as a separate sub via RPC
|
---|
| 603 | # since RPC calls can be s...l...o...w....
|
---|
| 604 | sub updateRevSet {
|
---|
| 605 | my %args = @_;
|
---|
| 606 |
|
---|
| 607 | _commoncheck(\%args, 'y');
|
---|
| 608 |
|
---|
| 609 | my @ret;
|
---|
| 610 | # loop over passed IP/hostname pairs
|
---|
| 611 | foreach my $key (keys %args) {
|
---|
[678] | 612 | next unless $key =~ m{^host_((?:[\d.]+|[\da-f:]+)(?:/\d+)?)$};
|
---|
[676] | 613 | my $ip = $1;
|
---|
| 614 | push @ret, addOrUpdateRevRec(cidr => $ip, name => $args{$key}, %args);
|
---|
| 615 | }
|
---|
| 616 | ##fixme: what about errors? what about warnings?
|
---|
| 617 | return \@ret;
|
---|
| 618 | } # done updateRevSet()
|
---|
| 619 |
|
---|
[119] | 620 | sub delRec {
|
---|
| 621 | my %args = @_;
|
---|
| 622 |
|
---|
[405] | 623 | _commoncheck(\%args, 'y');
|
---|
[123] | 624 |
|
---|
[511] | 625 | _reccheck(\%args);
|
---|
| 626 |
|
---|
[481] | 627 | my ($code, $msg) = $dnsdb->delRec($args{defrec}, $args{recrev}, $args{id});
|
---|
[123] | 628 |
|
---|
[511] | 629 | die "$msg\n" if $code eq 'FAIL';
|
---|
[426] | 630 | return $msg;
|
---|
[119] | 631 | }
|
---|
| 632 |
|
---|
[459] | 633 | sub delByCIDR {
|
---|
| 634 | my %args = @_;
|
---|
| 635 |
|
---|
| 636 | _commoncheck(\%args, 'y');
|
---|
| 637 |
|
---|
| 638 | # much like addOrUpdateRevRec()
|
---|
[477] | 639 | my $zonelist = $dnsdb->getZonesByCIDR(%args);
|
---|
[459] | 640 | my $cidr = new NetAddr::IP $args{cidr};
|
---|
| 641 |
|
---|
| 642 | if (scalar(@$zonelist) == 0) {
|
---|
| 643 | # enhh.... WTF?
|
---|
| 644 | } elsif (scalar(@$zonelist) == 1) {
|
---|
| 645 |
|
---|
| 646 | # check if the single zone returned is bigger than the CIDR
|
---|
| 647 | my $zone = new NetAddr::IP $zonelist->[0]->{revnet};
|
---|
| 648 | if ($zone->contains($cidr)) {
|
---|
| 649 |
|
---|
| 650 | if ($args{delsubs}) {
|
---|
| 651 | # Delete ALL EVARYTHING!!one11!! in $args{cidr}
|
---|
[495] | 652 | my $reclist = $dnsdb->getRecList(defrec => 'n', revrec => 'y', id => $zonelist->[0]->{rdns_id});
|
---|
[459] | 653 | foreach my $rec (@$reclist) {
|
---|
| 654 | my $reccidr = new NetAddr::IP $rec->{val};
|
---|
| 655 | next unless $cidr->contains($reccidr);
|
---|
[460] | 656 | next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
|
---|
| 657 | $rec->{type} == 65282 || $rec->{type} == 65283 ||$rec->{type} == 65284;
|
---|
[459] | 658 | ##fixme: multiple records, wanna wax'em all, how to report errors?
|
---|
| 659 | if ($args{delforward} ||
|
---|
| 660 | $rec->{type} == 12 || $rec->{type} == 65282 ||
|
---|
| 661 | $rec->{type} == 65283 || $rec->{type} == 65284) {
|
---|
[481] | 662 | my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
|
---|
[459] | 663 | } else {
|
---|
[481] | 664 | my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
|
---|
[459] | 665 | }
|
---|
| 666 | }
|
---|
[460] | 667 | if ($args{parpatt} && $zone == $cidr) {
|
---|
| 668 | # Edge case; we've just gone and axed all the records in the reverse zone.
|
---|
| 669 | # Re-add one to match the parent if we've been given a pattern to use.
|
---|
[659] | 670 | rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id},
|
---|
[672] | 671 | type => ($zone->{isv6} ? 65284 : 65283), address => "$cidr", name => $args{parpatt}, %args);
|
---|
[460] | 672 | }
|
---|
[459] | 673 |
|
---|
| 674 | } else {
|
---|
| 675 | # Selectively delete only exact matches on $args{cidr}
|
---|
| 676 |
|
---|
| 677 | # We need to strip the CIDR mask on IPv4 /32 assignments, or we can't find single-IP records
|
---|
| 678 | my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr);
|
---|
[495] | 679 | my $reclist = $dnsdb->getRecList(defrec => 'n', revrec => 'y',
|
---|
[459] | 680 | id => $zonelist->[0]->{rdns_id}, filter => $filt, sortby => 'val', sortorder => 'DESC');
|
---|
| 681 | foreach my $rec (@$reclist) {
|
---|
| 682 | my $reccidr = new NetAddr::IP $rec->{val};
|
---|
| 683 | next unless $cidr == $reccidr;
|
---|
[460] | 684 | next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
|
---|
| 685 | $rec->{type} == 65282 || $rec->{type} == 65283 ||$rec->{type} == 65284;
|
---|
[459] | 686 | if ($args{delforward} || $rec->{type} == 12) {
|
---|
[481] | 687 | my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
|
---|
[511] | 688 | die "$msg\n" if $code eq 'FAIL';
|
---|
[459] | 689 | return $msg;
|
---|
| 690 | } else {
|
---|
[481] | 691 | my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
|
---|
[671] | 692 | die $dnsdb->errstr."\n" if !$ret;
|
---|
[459] | 693 | return "A+PTR for $args{cidr} split and PTR removed";
|
---|
| 694 | }
|
---|
| 695 | } # foreach @$reclist
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | } else { # $cidr > $zone but we only have one zone
|
---|
| 699 | # ebbeh? CIDR is only partly represented in DNS. This needs manual intervention.
|
---|
| 700 | return "Warning: $args{cidr} is only partly represented in DNS. Check and remove DNS records manually.";
|
---|
| 701 | } # done single-zone-contains-$cidr
|
---|
| 702 |
|
---|
| 703 | } else { # multiple zones nominally "contain" $cidr
|
---|
| 704 | # Overlapping reverse zones shouldn't be possible, so if we're here we've got a CIDR
|
---|
| 705 | # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones)
|
---|
| 706 | foreach my $zdata (@$zonelist) {
|
---|
[495] | 707 | my $reclist = $dnsdb->getRecList(defrec => 'n', revrec => 'y', id => $zdata->{rdns_id});
|
---|
[459] | 708 | if (scalar(@$reclist) == 0) {
|
---|
[460] | 709 | # nothing to do? or do we (re)add a record based on the parent?
|
---|
| 710 | # yes, yes we do, past the close of the else
|
---|
| 711 | # my $type = ($args{cidr}->{isv6} ? 65282 : ($args{cidr}->masklen == 32 ? 65280 : 65283) );
|
---|
[659] | 712 | # rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type,
|
---|
[460] | 713 | # address => "$args{cidr}", %args);
|
---|
[459] | 714 | } else {
|
---|
| 715 | foreach my $rec (@$reclist) {
|
---|
[460] | 716 | next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281 ||
|
---|
| 717 | $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
|
---|
| 718 | # Template types are only useful when attached to a reverse zone.
|
---|
| 719 | ##fixme ..... or ARE THEY?
|
---|
| 720 | if ($args{delforward} ||
|
---|
| 721 | $rec->{type} == 12 || $rec->{type} == 65282 ||
|
---|
| 722 | $rec->{type} == 65283 || $rec->{type} == 65284) {
|
---|
[481] | 723 | my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id});
|
---|
[460] | 724 | } else {
|
---|
[481] | 725 | my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A});
|
---|
[460] | 726 | }
|
---|
[459] | 727 | } # foreach @$reclist
|
---|
[460] | 728 | } # nrecs != 0
|
---|
| 729 | if ($args{parpatt}) {
|
---|
| 730 | # We've just gone and axed all the records in the reverse zone.
|
---|
| 731 | # Re-add one to match the parent if we've been given a pattern to use.
|
---|
[659] | 732 | rpc_addRec(defrec => 'n', revrec => 'y', parent_id => $zdata->{rdns_id},
|
---|
[460] | 733 | type => ($cidr->{isv6} ? 65284 : 65283),
|
---|
| 734 | address => $zdata->{revnet}, name => $args{parpatt}, %args);
|
---|
[459] | 735 | }
|
---|
| 736 | } # iterate zones within $cidr
|
---|
| 737 | } # done $cidr-contains-zones
|
---|
| 738 |
|
---|
| 739 | } # end delByCIDR()
|
---|
| 740 |
|
---|
[405] | 741 | #sub getLogCount {}
|
---|
| 742 | #sub getLogEntries {}
|
---|
[452] | 743 |
|
---|
| 744 | sub getRevPattern {
|
---|
| 745 | my %args = @_;
|
---|
| 746 |
|
---|
| 747 | _commoncheck(\%args, 'y');
|
---|
| 748 |
|
---|
[483] | 749 | return $dnsdb->getRevPattern($args{cidr}, $args{group});
|
---|
[452] | 750 | }
|
---|
| 751 |
|
---|
[673] | 752 | sub getRevSet {
|
---|
| 753 | my %args = @_;
|
---|
| 754 |
|
---|
| 755 | _commoncheck(\%args, 'y');
|
---|
| 756 |
|
---|
| 757 | return $dnsdb->getRevSet($args{cidr}, $args{group});
|
---|
| 758 | }
|
---|
| 759 |
|
---|
[506] | 760 | sub getTypelist {
|
---|
| 761 | my %args = @_;
|
---|
| 762 | _commoncheck(\%args, 'y');
|
---|
[504] | 763 |
|
---|
[506] | 764 | $args{selected} = $reverse_typemap{A} if !$args{selected};
|
---|
| 765 |
|
---|
| 766 | return $dnsdb->getTypelist($args{recgroup}, $args{selected});
|
---|
| 767 | }
|
---|
| 768 |
|
---|
[504] | 769 | sub getTypemap {
|
---|
| 770 | my %args = @_;
|
---|
| 771 | _commoncheck(\%args, 'y');
|
---|
| 772 | return \%typemap;
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 | sub getReverse_typemap {
|
---|
| 776 | my %args = @_;
|
---|
| 777 | _commoncheck(\%args, 'y');
|
---|
| 778 | return \%reverse_typemap;
|
---|
| 779 | }
|
---|
| 780 |
|
---|
[405] | 781 | #sub parentID {}
|
---|
| 782 | #sub isParent {}
|
---|
[123] | 783 |
|
---|
[405] | 784 | sub zoneStatus {
|
---|
[123] | 785 | my %args = @_;
|
---|
| 786 |
|
---|
[405] | 787 | _commoncheck(\%args, 'y');
|
---|
[123] | 788 |
|
---|
[477] | 789 | my @arglist = ($args{zoneid});
|
---|
[123] | 790 | push @arglist, $args{status} if defined($args{status});
|
---|
| 791 |
|
---|
[477] | 792 | my $status = $dnsdb->zoneStatus(@arglist);
|
---|
[123] | 793 | }
|
---|
| 794 |
|
---|
[452] | 795 | # Get a list of hashes referencing the reverse zone(s) for a passed CIDR block
|
---|
| 796 | sub getZonesByCIDR {
|
---|
| 797 | my %args = @_;
|
---|
| 798 |
|
---|
| 799 | _commoncheck(\%args, 'y');
|
---|
| 800 |
|
---|
[477] | 801 | return $dnsdb->getZonesByCIDR(%args);
|
---|
[452] | 802 | }
|
---|
| 803 |
|
---|
[405] | 804 | #sub importAXFR {}
|
---|
| 805 | #sub importBIND {}
|
---|
| 806 | #sub import_tinydns {}
|
---|
| 807 | #sub export {}
|
---|
| 808 | #sub __export_tiny {}
|
---|
| 809 | #sub _printrec_tiny {}
|
---|
| 810 | #sub mailNotify {}
|
---|
[119] | 811 |
|
---|
| 812 | sub get_method_list {
|
---|
| 813 | my @methods = keys %{$methods};
|
---|
| 814 | return \@methods;
|
---|
| 815 | }
|
---|