Changeset 452 for trunk/DNSDB.pm


Ignore:
Timestamp:
01/11/13 12:21:13 (11 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/DNSDB.pm

    r451 r452  
    5252        &addRec &updateRec &delRec
    5353        &getLogCount &getLogEntries
     54        &getRevPattern
    5455        &getTypelist
    5556        &parentID
    5657        &isParent
    57         &zoneStatus &importAXFR
     58        &zoneStatus &getZonesByCIDR &importAXFR
    5859        &export
    5960        &mailNotify
     
    7980                &addRec &updateRec &delRec
    8081                &getLogCount &getLogEntries
     82                &getRevPattern
    8183                &getTypelist
    8284                &parentID
    8385                &isParent
    84                 &zoneStatus &importAXFR
     86                &zoneStatus &getZonesByCIDR &importAXFR
    8587                &export
    8688                &mailNotify
     
    39263928
    39273929
     3930## IPDB::getRevPattern()
     3931# Get the narrowest template pattern applicable to a passed CIDR address (may be a netblock or an IP)
     3932sub 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
    39283944## DNSDB::getTypelist()
    39293945# Get a list of record types for various UI dropdowns
     
    41534169  return $status;
    41544170} # 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.
     4175sub 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()
    41554183
    41564184
Note: See TracChangeset for help on using the changeset viewer.