Changeset 452 for trunk/dns-rpc.cgi


Ignore:
Timestamp:
01/11/13 12:21:13 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Continue tweaking RPC for actual usage. See #43.

  • Add and expose getRevPattern() to retrieve the narrowest template pattern applicable to a passed CIDR (netblock or IP)
  • Add and expose getZonesByCIDR() to retrieve a list of revzones and zone IDs for records within a passed CIDR block. Note the block may be larger than the zones, so we may return more than one revzone.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r447 r452  
    6464        'dnsdb.updateRec'       => \&updateRec,
    6565        'dnsdb.delRec'          => \&delRec,
     66#sub getLogCount {}
     67#sub getLogEntries {}
     68        'dnsdb.getRevPattern'   => \&getRevPattern,
    6669        'dnsdb.zoneStatus'      => \&zoneStatus,
     70        'dnsdb.getZonesByCIDR'  => \&getZonesByCIDR,
    6771
    6872        'dnsdb.getMethods'      => \&get_method_list
     
    371375  }
    372376
     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
    373383  my @recargs = ($dbh, $args{defrec}, $args{revrec}, $args{parent_id},
    374384        \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location});
     
    392402  _commoncheck(\%args, 'y');
    393403
     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
    394411  # note dist, weight, port are not required on all types;  will be ignored if not needed.
    395412  # parent_id is the "primary" zone we're updating;  necessary for forward/reverse voodoo
     
    415432#sub getLogCount {}
    416433#sub getLogEntries {}
     434
     435sub getRevPattern {
     436  my %args = @_;
     437
     438  _commoncheck(\%args, 'y');
     439
     440  return DNSDB::getRevPattern($dbh, $args{cidr}, $args{group});
     441}
     442
    417443#sub getTypelist {}
    418444#sub parentID {}
     
    428454
    429455  my $status = DNSDB::zoneStatus(@arglist);
     456}
     457
     458# Get a list of hashes referencing the reverse zone(s) for a passed CIDR block
     459sub getZonesByCIDR {
     460  my %args = @_;
     461
     462  _commoncheck(\%args, 'y');
     463
     464  return DNSDB::getZonesByCIDR($dbh, %args);
    430465}
    431466
Note: See TracChangeset for help on using the changeset viewer.