Changeset 452
- Timestamp:
- 01/11/13 12:21:13 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r451 r452 52 52 &addRec &updateRec &delRec 53 53 &getLogCount &getLogEntries 54 &getRevPattern 54 55 &getTypelist 55 56 &parentID 56 57 &isParent 57 &zoneStatus & importAXFR58 &zoneStatus &getZonesByCIDR &importAXFR 58 59 &export 59 60 &mailNotify … … 79 80 &addRec &updateRec &delRec 80 81 &getLogCount &getLogEntries 82 &getRevPattern 81 83 &getTypelist 82 84 &parentID 83 85 &isParent 84 &zoneStatus & importAXFR86 &zoneStatus &getZonesByCIDR &importAXFR 85 87 &export 86 88 &mailNotify … … 3926 3928 3927 3929 3930 ## IPDB::getRevPattern() 3931 # Get the narrowest template pattern applicable to a passed CIDR address (may be a netblock or an IP) 3932 sub getRevPattern { 3933 my $dbh = shift; 3934 my $cidr = shift; 3935 my $group = shift || 1; # just in case 3936 3937 my ($revpatt) = $dbh->selectrow_array("SELECT r.host FROM records r JOIN revzones z ON r.rdns_id=z.rdns_id ". 3938 "WHERE r.type=65282 OR r.type=65283 AND z.group_id=? AND CAST (r.val AS inet) >>= ? ". 3939 "ORDER BY CAST (r.val AS inet) DESC LIMIT 1", undef, ($group, $cidr) ); 3940 return $revpatt; 3941 } # end getRevPattern() 3942 3943 3928 3944 ## DNSDB::getTypelist() 3929 3945 # Get a list of record types for various UI dropdowns … … 4153 4169 return $status; 4154 4170 } # end zoneStatus() 4171 4172 4173 ## DNSDB::getZonesByCIDR() 4174 # Get a list of zone names and IDs that records for a passed CIDR block are within. 4175 sub getZonesByCIDR { 4176 my $dbh = shift; 4177 my %args = @_; 4178 4179 my $result = $dbh->selectall_arrayref("SELECT rdns_id,revnet FROM revzones WHERE revnet >>= ? OR revnet <<= ?", 4180 { Slice => {} }, ($args{cidr}, $args{cidr}) ); 4181 return $result; 4182 } # end getZonesByCIDR() 4155 4183 4156 4184 -
trunk/dns-rpc.cgi
r447 r452 64 64 'dnsdb.updateRec' => \&updateRec, 65 65 'dnsdb.delRec' => \&delRec, 66 #sub getLogCount {} 67 #sub getLogEntries {} 68 'dnsdb.getRevPattern' => \&getRevPattern, 66 69 'dnsdb.zoneStatus' => \&zoneStatus, 70 'dnsdb.getZonesByCIDR' => \&getZonesByCIDR, 67 71 68 72 'dnsdb.getMethods' => \&get_method_list … … 371 375 } 372 376 377 # callers may often not care about TTLs 378 if (!$args{ttl}) { 379 my $tmp = DNSDB::getSOA($dbh, $args{defrec}, $args{revrec}, $args{parent_id}); 380 $args{ttl} = $tmp->{minttl}; 381 } 382 373 383 my @recargs = ($dbh, $args{defrec}, $args{revrec}, $args{parent_id}, 374 384 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location}); … … 392 402 _commoncheck(\%args, 'y'); 393 403 404 # get old line, so we can update only the bits that the caller passed to change 405 # note we subbed address for val since it's a little more caller-friendly 406 my $oldrec = DNSDB::getRecLine($dbh, $args{defrec}, $args{revrec}, $args{id}); 407 foreach my $field (qw(name type address ttl location distance weight port)) { 408 $args{$field} = $oldrec->{$field} if !$args{$field} && defined($oldrec->{$field}); 409 } 410 394 411 # note dist, weight, port are not required on all types; will be ignored if not needed. 395 412 # parent_id is the "primary" zone we're updating; necessary for forward/reverse voodoo … … 415 432 #sub getLogCount {} 416 433 #sub getLogEntries {} 434 435 sub getRevPattern { 436 my %args = @_; 437 438 _commoncheck(\%args, 'y'); 439 440 return DNSDB::getRevPattern($dbh, $args{cidr}, $args{group}); 441 } 442 417 443 #sub getTypelist {} 418 444 #sub parentID {} … … 428 454 429 455 my $status = DNSDB::zoneStatus(@arglist); 456 } 457 458 # Get a list of hashes referencing the reverse zone(s) for a passed CIDR block 459 sub getZonesByCIDR { 460 my %args = @_; 461 462 _commoncheck(\%args, 'y'); 463 464 return DNSDB::getZonesByCIDR($dbh, %args); 430 465 } 431 466
Note:
See TracChangeset
for help on using the changeset viewer.