Changeset 160 for trunk/DNSDB.pm


Ignore:
Timestamp:
11/02/11 18:12:35 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Use bind parameters in DNSDB::getDomRecs for filter
Make sure A records get an IPv4 address, and AAAA records get

a v6 address in DNSDB::addRec

Normalize and clean up handling for filtering and starts-with

  • common ops now done along with the rest of the global ops
  • filtering arguments now pushed into a global
  • use bind parameters in SQL (this should transfer OK to subs in DNSDB.pm later)

Add a couple new ##fixme's for scope checks
Force appending of domain or DOMAIN on record or default record

respectively, if they don't already have that at the end

Retrieve "old" info for logging record changes
Remove some stale commented fragments and ##fixme's

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r157 r160  
    12121212
    12131213  my $filter = shift || '';
    1214   # keep the nasties down, since we can't ?-sub this bit.  :/
    1215   # note this is chars allowed in DNS hostnames
    1216   $filter =~ s/[^a-zA-Z0-9_.:-]//g;
    12171214
    12181215  $type = 'y' if $type eq 'def';
     
    12281225  }
    12291226  $sql .= " AND NOT r.type=$reverse_typemap{SOA}";
    1230   $sql .= " AND host ILIKE '%$filter%'" if $filter;
     1227  $sql .= " AND host ~* ?" if $filter;
    12311228  # use alphaorder column for "correct" ordering of sort-by-type instead of DNS RR type number
    12321229  $sql .= " ORDER BY ".($order eq 'type' ? 't.alphaorder' : "r.$order")." $direction";
     
    12911288
    12921289  # Validation
     1290  if ($rectype == $reverse_typemap{A}) {
     1291    return ("FAIL", "IPv4 addresses must be in the format n.n.n.n")
     1292        unless $val =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
     1293  }
     1294  if ($rectype == $reverse_typemap{AAAA}) {
     1295    return ("FAIL", "IPv6 addresses must be in the format h:h:h::h")
     1296        unless $val =~ /^[a-fA-F0-9:]+$/
     1297  }
    12931298  if ($rectype == $reverse_typemap{A} or $rectype == $reverse_typemap{AAAA}) {
    12941299    my $tmpip = new NetAddr::IP $val or
Note: See TracChangeset for help on using the changeset viewer.