Changeset 253 for branches


Ignore:
Timestamp:
05/30/05 16:09:05 (19 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Cleanup commit for db2rwhois.pl; looks like I forgot. :/
Changes are all of the "make it work (better)" variety.
Further significant changes require new billing system to
be completed for crosslinking.

File:
1 edited

Legend:

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

    r158 r253  
    4141# Note that this ASS-U-MEs that we do not add master IP blocks-
    4242# there should probably be a separate system for doing that.
    43 my $sth = $dbh->prepare("select * from masterblocks;");
     43my $sth = $dbh->prepare("select cidr,ctime from masterblocks;");
    4444$sth->execute;
    4545my $i=0;
    4646GETMASTERS: while (my @data = $sth->fetchrow_array()) {
    4747
    48   if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) {
     48# Techically, we only need to exclude 204.138.172.0/24, as we "own" all of the other blocks.
     49  if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0|20[456])/) {
    4950    next GETMASTERS;
    5051  }
    5152  $masterblocks[$i] = new NetAddr::IP $data[0];
     53  my ($ctime,undef) = split /\s/, $data[1];
    5254
    53 print "$masterblocks[$i]\n";
     55print "$masterblocks[$i] $data[1]\n";
    5456
    5557  my $date;
    56   chomp ($date = `/bin/date +"%Y%m%d"`);
     58  chomp ($date = `/bin/date +"%Y-%m-%d"`);
    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 cidr,custid,type,city,description,createstamp,modifystamp ".
     92        "from allocations where ".
     93        "not (cidr <<= '192.168.0.0/16') and ".
     94        "not (cidr <<= '172.16.0.0/12') and ".
     95        "not (cidr <<= '10.0.0.0/8') and ".
     96        "masklen(cidr) <=30");
     97#" and (custid='6750400' or custid like '%-RES' or custid like '%-BUS')");
    9098$sth->execute;
    9199
    92 while (my @data = $sth->fetchrow_array()) {
     100$i=0;
     101while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime) = $sth->fetchrow_array) {
    93102
    94103# We get master block info from @masterblocks.
     
    106115
    107116  # Get the "full" network number
    108   my $net = new NetAddr::IP $data[0];
     117  my $net = new NetAddr::IP $cidr;
    109118
    110119# Assumptions:  All data in ipdb is public
     
    127136my $date;
    128137      chomp ($date = `/bin/date +"%Y%m%d"`);
    129 if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; }
     138if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }
     139#print "$i:\t$net in $master\n";
     140
    130141      print MASTERFILE "---\nID: NETBLK-ISP.$master\n".
    131142        "Auth-Area: $master\n".
     
    133144        "IP-Network: $net\n".
    134145        "IP-Network-Block: ".$net->range."\n".
    135         "Organization: $data[4]\n".
     146        "Organization: $desc\n".
    136147#       "Tech-Contact: $data[9]\n".
    137148        "Tech-Contact: abuse\@example.com\n".
    138149        "Admin-Contact: ISP-ARIN-HANDLE\n".
    139         "Created: $date\n".
    140         "Updated: $date\n".
     150        "Created: $ctime\n".
     151        "Updated: $mtime\n".
    141152        "Updated-By: noc\@example.com\n";
    142153    }
     
    149160  #  print "$data[0]\t| $data[1]\t| $data[2]\t| $data[3]\t| $data[4]\t| ".
    150161  #     "$data[5]\t| $data[6]\t| $data[7]\t| $data[8]\n";
    151 
     162  $i++;
    152163} # while fetchrow_array()
    153164
Note: See TracChangeset for help on using the changeset viewer.