Changeset 253 for branches/stable
- Timestamp:
- 05/30/05 16:09:05 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/extras/db2rwhois.pl
r158 r253 41 41 # Note that this ASS-U-MEs that we do not add master IP blocks- 42 42 # there should probably be a separate system for doing that. 43 my $sth = $dbh->prepare("select *from masterblocks;");43 my $sth = $dbh->prepare("select cidr,ctime from masterblocks;"); 44 44 $sth->execute; 45 45 my $i=0; 46 46 GETMASTERS: while (my @data = $sth->fetchrow_array()) { 47 47 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])/) { 49 50 next GETMASTERS; 50 51 } 51 52 $masterblocks[$i] = new NetAddr::IP $data[0]; 53 my ($ctime,undef) = split /\s/, $data[1]; 52 54 53 print "$masterblocks[$i] \n";55 print "$masterblocks[$i] $data[1]\n"; 54 56 55 57 my $date; 56 chomp ($date = `/bin/date +"%Y %m%d"`);58 chomp ($date = `/bin/date +"%Y-%m-%d"`); 57 59 58 60 # Whew! Ugly little varmint. … … 73 75 "Admin-Contact: ISP-ARIN-HANDLE\n". 74 76 "Abuse-Contact: abuse\@example.com\n". 75 "Created: 20040308\n".77 "Created: $ctime\n". 76 78 "Updated: $date\n". 77 79 "Updated-By: noc\@example.com\n"; … … 87 89 # Make sure to remove the private netblocks from this. 88 90 # 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')"); 90 98 $sth->execute; 91 99 92 while (my @data = $sth->fetchrow_array()) { 100 $i=0; 101 while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime) = $sth->fetchrow_array) { 93 102 94 103 # We get master block info from @masterblocks. … … 106 115 107 116 # Get the "full" network number 108 my $net = new NetAddr::IP $ data[0];117 my $net = new NetAddr::IP $cidr; 109 118 110 119 # Assumptions: All data in ipdb is public … … 127 136 my $date; 128 137 chomp ($date = `/bin/date +"%Y%m%d"`); 129 if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; } 138 if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; } 139 #print "$i:\t$net in $master\n"; 140 130 141 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 131 142 "Auth-Area: $master\n". … … 133 144 "IP-Network: $net\n". 134 145 "IP-Network-Block: ".$net->range."\n". 135 "Organization: $d ata[4]\n".146 "Organization: $desc\n". 136 147 # "Tech-Contact: $data[9]\n". 137 148 "Tech-Contact: abuse\@example.com\n". 138 149 "Admin-Contact: ISP-ARIN-HANDLE\n". 139 "Created: $ date\n".140 "Updated: $ date\n".150 "Created: $ctime\n". 151 "Updated: $mtime\n". 141 152 "Updated-By: noc\@example.com\n"; 142 153 } … … 149 160 # print "$data[0]\t| $data[1]\t| $data[2]\t| $data[3]\t| $data[4]\t| ". 150 161 # "$data[5]\t| $data[6]\t| $data[7]\t| $data[8]\n"; 151 162 $i++; 152 163 } # while fetchrow_array() 153 164
Note:
See TracChangeset
for help on using the changeset viewer.