Changeset 468 for trunk/tiny-import.pl


Ignore:
Timestamp:
03/12/13 13:39:49 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Object conversion of DNSDB.pm, 4 of <mumble>. See #11.

  • Convert initialization of bundled callers to object calls
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tiny-import.pl

    r461 r468  
    2727
    2828use lib '.';
    29 use DNSDB qw(:ALL);
    30 
    31 if (!loadConfig()) {
    32   warn "Using default configuration;  unable to load custom settings: $DNSDB::errstr";
    33 }
     29use DNSDB;
     30
     31my $dnsdb = new DNSDB;
    3432
    3533usage() if !@ARGV;
     
    7775
    7876my $code;
    79 my ($dbh,$msg) = connectDB($config{dbname}, $config{dbuser}, $config{dbpass}, $config{dbhost});
    80 initGlobals($dbh) if $dbh;
     77my $dbh = $dnsdb->{dbh};
    8178
    8279$dbh->{AutoCommit} = 0;
     
    251248    my $nodefer = shift || 0;
    252249    my $impok = 1;
     250    my $msg;
    253251
    254252    $errstr = $rec;  # this way at least we have some idea what went <splat>
     
    269267      $loc = '' if !$loc;
    270268      $loc = '' if $loc =~ /^:+$/;
    271       my $fparent = DNSDB::_hostparent($dbh, $host);
     269      my $fparent = $dnsdb->_hostparent($host);
    272270      my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($ip));
    273271      if ($fparent && $rparent) {
     
    308306
    309307      } else {
    310         my $fparent = DNSDB::_hostparent($dbh, $host);
     308        my $fparent = $dnsdb->_hostparent($host);
    311309        if ($fparent) {
    312310          $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl, $loc);
     
    344342        }
    345343      } else {
    346         my $fparent = DNSDB::_hostparent($dbh, $zone);
     344        my $fparent = $dnsdb->_hostparent($zone);
    347345        if ($fparent) {
    348346          $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl, $loc);
     
    396394      $loc = '' if $loc =~ /^:+$/;
    397395
    398       my $domid = DNSDB::_hostparent($dbh, $host);
     396      my $domid = $dnsdb->_hostparent($host);
    399397      if ($domid) {
    400398        $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc);
     
    447445
    448446      # allow for subzone MXes, since it's perfectly legitimate to simply stuff it all in a single parent zone
    449       my $domid = DNSDB::_hostparent($dbh, $zone);
     447      my $domid = $dnsdb->_hostparent($zone);
    450448      if ($domid) {
    451449        $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl, $loc);
     
    473471        $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl, $loc);
    474472      } else {
    475         my $domid = DNSDB::_hostparent($dbh, $fqdn);
     473        my $domid = $dnsdb->_hostparent($fqdn);
    476474        if ($domid) {
    477475          $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl, $loc);
     
    588586#  }
    589587
    590         my $domid = DNSDB::_hostparent($dbh, $fqdn);
     588        my $domid = $dnsdb->_hostparent($fqdn);
    591589        if ($domid) {
    592590          $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl, $loc) if $domid;
     
    606604        my $val = NetAddr::IP->new(join(':', @v6));
    607605
    608         my $fparent = DNSDB::_hostparent($dbh, $fqdn);
     606        my $fparent = $dnsdb->_hostparent($fqdn);
    609607        if ($fparent) {
    610608          $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl, $loc);
     
    628626          }
    629627        } else {
    630           my $domid = DNSDB::_hostparent($dbh, $fqdn);
     628          my $domid = $dnsdb->_hostparent($fqdn);
    631629          if ($domid) {
    632630            $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl, $loc);
     
    656654          }
    657655        } else {
    658           my $domid = DNSDB::_hostparent($dbh, $fqdn);
     656          my $domid = $dnsdb->_hostparent($fqdn);
    659657          if ($domid) {
    660658            $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl, $loc);
     
    672670
    673671        # these do not make sense in a reverse zone, since they're logically attached to an A record
    674         my $domid = DNSDB::_hostparent($dbh, $fqdn);
     672        my $domid = $dnsdb->_hostparent($fqdn);
    675673        if ($domid) {
    676674          $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl, $loc);
Note: See TracChangeset for help on using the changeset viewer.