Ignore:
Timestamp:
06/17/05 16:42:45 (20 years ago)
Author:
Kris Deugau
Message:

/branches/dns

Update branch base with trunk changes from r216:261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dns/cgi-bin/extras/db2rwhois.pl

    r146 r262  
    1717use NetAddr::IP;
    1818use MyIPDB;
     19use Digest::MD5 qw(md5_hex);
    1920
    2021$ENV{"PATH"} = "/bin;/usr/bin";
     
    4142# Note that this ASS-U-MEs that we do not add master IP blocks-
    4243# there should probably be a separate system for doing that.
    43 my $sth = $dbh->prepare("select * from masterblocks;");
     44my $sth = $dbh->prepare("select cidr,ctime from masterblocks;");
    4445$sth->execute;
    4546my $i=0;
    4647GETMASTERS: while (my @data = $sth->fetchrow_array()) {
    4748
    48   if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) {
    49     next GETMASTERS;
    50   }
     49#  if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) {
     50#    next GETMASTERS;
     51#  }
    5152  $masterblocks[$i] = new NetAddr::IP $data[0];
    5253
     
    5556  my $date;
    5657  chomp ($date = `/bin/date +"%Y%m%d"`);
     58  my ($ctime,undef) = split /\s+/, $data[1];
    5759
    5860# Whew!  Ugly little varmint.
     
    7375        "Admin-Contact: ISP-ARIN-HANDLE\n".
    7476        "Abuse-Contact: abuse\@example.com\n".
    75         "Created: 20040308\n".
     77        "Created: $ctime\n".
    7678        "Updated: $date\n".
    7779        "Updated-By: noc\@example.com\n";
     
    8789# Make sure to remove the private netblocks from this.
    8890# No use or point in broadcasting our use of them.
    89 $sth = $dbh->prepare("select * from allocations where not (cidr <<= '192.168.0.0/16') and not (cidr <<= '172.16.0.0/12') and not (cidr <<= '10.0.0.0/8') and custid='6750400'");
     91#$sth = $dbh->prepare("select * from allocations where not (cidr <<= '192.168.0.0/16') and not (cidr <<= '172.16.0.0/12') and not (cidr <<= '10.0.0.0/8')");
     92# cidr,custid,type,city,description,notes,maskbits,circuitid,createstamp,modifystamp,newcustid
     93
     94$sth = $dbh->prepare("select cidr,custid,type,city,description,createstamp,modifystamp from allocations");
    9095$sth->execute;
    9196
    92 while (my @data = $sth->fetchrow_array()) {
     97while (my ($cidr,$custid,$type,$city,$description,$ctime,$mtime) = $sth->fetchrow_array()) {
    9398
    9499# We get master block info from @masterblocks.
     
    105110 # Updated-By: noc@example.com
    106111
    107   # Get the "full" network number
    108   my $net = new NetAddr::IP $data[0];
     112  # Get the "full" network number - just in case.
     113  my $net = new NetAddr::IP $cidr;
    109114
    110115# Assumptions:  All data in ipdb is public
     
    121126        or print "File open error: '$!' on '$rwhoisDataPath/$masterfilename'\n";
    122127
    123 # cidr custid type city description notes maskbits
    124 
    125 # Creation date in record to eventually be "correct";  near-term will
    126 # be master's creation date;  immediate is today's date.
    127 my $date;
    128       chomp ($date = `/bin/date +"%Y%m%d"`);
    129128if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; }
     129print "$type-type $net for $custid, created $ctime, modified $mtime\n";
    130130      print MASTERFILE "---\nID: NETBLK-ISP.$master\n".
    131131        "Auth-Area: $master\n".
     
    133133        "IP-Network: $net\n".
    134134        "IP-Network-Block: ".$net->range."\n".
    135         "Organization: $data[4]\n".
     135        "Organization: $description\n".
    136136#       "Tech-Contact: $data[9]\n".
    137137        "Tech-Contact: abuse\@example.com\n".
    138138        "Admin-Contact: ISP-ARIN-HANDLE\n".
    139         "Created: $date\n".
    140         "Updated: $date\n".
     139        "Created: $ctime\n".
     140        "Updated: $mtime\n".
    141141        "Updated-By: noc\@example.com\n";
    142142    }
     
    154154
    155155$dbh->disconnect;
     156
     157# This doesn't work, with a vengeance.
     158#print qx{ /usr/bin/rwhois_indexer -c /etc/rwhoisd/rwhoisd.conf -i -v -s txt };
Note: See TracChangeset for help on using the changeset viewer.