Changeset 228


Ignore:
Timestamp:
02/08/12 15:14:30 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Refactoring record data validation, first pass.
Stub out validation subs for all supported types, and fill a hash

with function references for *all* types in initGlobals()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r226 r228  
    132132        );
    133133
     134## (Semi)private variables
     135# Hash of functions for validating record types.  Filled in initGlobals() since
     136# it relies on visibility flags from the rectypes table in the DB
     137my %validators;
     138
    134139
    135140##
     
    228233  # can't do nuttin' in forward zones
    229234} # end _ipparent()
     235
     236
     237##
     238## Record validation subs.
     239##
     240
     241# A record
     242sub _validate_1 {
     243  return ('OK','OK');
     244} # done A record
     245
     246# NS record
     247sub _validate_2 {
     248  return ('OK','OK');
     249} # done NS record
     250
     251# CNAME record
     252sub _validate_5 {
     253  return ('OK','OK');
     254} # done CNAME record
     255
     256# SOA record
     257sub _validate_6 {
     258  return ('OK','OK');
     259} # done SOA record
     260
     261# PTR record
     262sub _validate_12 {
     263  return ('OK','OK');
     264} # done PTR record
     265
     266# MX record
     267sub _validate_15 {
     268  return ('OK','OK');
     269} # done MX record
     270
     271# TXT record
     272sub _validate_16 {
     273  return ('OK','OK');
     274} # done TXT record
     275
     276# RP record
     277sub _validate_17 {
     278  return ('OK','OK');
     279} # done RP record
     280
     281# AAAA record
     282sub _validate_28 {
     283  return ('OK','OK');
     284} # done AAAA record
     285
     286# SRV record
     287sub _validate_33 {
     288  return ('OK','OK');
     289} # done SRV record
     290
     291# Now the custom types
     292
     293# A+PTR record
     294sub _validate_65280 {
     295  return ('OK','OK');
     296} # done A+PTR record
     297
     298# AAAA+PTR record
     299sub _validate_65281 {
     300  return ('OK','OK');
     301} # done AAAA+PTR record
     302
     303# PTR template record
     304sub _validate_65282 {
     305  return ('OK','OK');
     306} # done PTR template record
     307
     308# A+PTR template record
     309sub _validate_65283 {
     310  return ('OK','OK');
     311} # done AAAA+PTR template record
     312
     313# AAAA+PTR template record
     314sub _validate_65284 {
     315  return ('OK','OK');
     316} # done AAAA+PTR template record
     317
     318
    230319
    231320##
     
    415504
    416505# load record types from database
    417   my $sth = $dbh->prepare("select val,name from rectypes");
     506  my $sth = $dbh->prepare("SELECT val,name,stdflag FROM rectypes");
    418507  $sth->execute;
    419   while (my ($recval,$recname) = $sth->fetchrow_array()) {
     508  while (my ($recval,$recname,$stdflag) = $sth->fetchrow_array()) {
    420509    $typemap{$recval} = $recname;
    421510    $reverse_typemap{$recname} = $recval;
     511    # now we fill the record validation function hash
     512    if ($stdflag < 5) {
     513      my $fn = "_validate_$recval";
     514      $validators{$recval} = \&$fn;
     515    } else {
     516      my $fn = "sub { return ('FAIL','Type $recval ($recname) not supported'); }";
     517      $validators{$recval} = eval $fn;
     518    }
    422519  }
    423520} # end initGlobals
Note: See TracChangeset for help on using the changeset viewer.