Changeset 325 for branches/stable/cgi-bin/extras
- Timestamp:
- 04/06/06 15:53:25 (19 years ago)
- Location:
- branches/stable/cgi-bin/extras
- Files:
-
- 1 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/extras/db2rwhois.pl
r308 r325 28 28 29 29 my @masterblocks; 30 my %netnameprefix; 30 31 31 32 # Fill in data about our master blocks as allocated from ARIN … … 33 34 # Note that this ASS-U-MEs that we do not add master IP blocks- 34 35 # there should probably be a separate system for doing that. 35 my $sth = $dbh->prepare("select cidr,ctime from masterblocks;");36 my $sth = $dbh->prepare("select cidr,ctime,mtime from masterblocks;"); 36 37 $sth->execute; 37 38 my $i=0; … … 45 46 $masterblocks[$i] = new NetAddr::IP $data[0]; 46 47 my ($ctime,undef) = split /\s/, $data[1]; 47 48 print "$masterblocks[$i] $ data[1]\n";48 my ($mtime,undef) = split /\s/, $data[2]; 49 print "$masterblocks[$i] $ctime $mtime\n"; 49 50 50 51 my $date; … … 64 65 "IP-Network: $masterblocks[$i]\n". 65 66 "IP-Network-Block: ".$masterblocks[$i]->range."\n". 66 "Organization: Friendly ISP\n". 67 "Tech-Contact: noc\@example.com\n". 68 "Admin-Contact: ISP-ARIN-HANDLE\n". 69 "Abuse-Contact: abuse\@example.com\n". 67 "Org-Name: Friendly ISP\n". 68 "Street-Address: 123 4th Street\n". 69 "City: Anytown\n". 70 "StateProv: Ontario\n". 71 "Postal-Code: H0H 0H0\n". 72 "Country-Code: CA\n". 73 "Tech-Contact: ISP-ARIN-HANDLE\n". 70 74 "Created: $ctime\n". 71 "Updated: $ date\n".75 "Updated: $mtime\n". 72 76 "Updated-By: noc\@example.com\n"; 73 77 … … 76 80 } 77 81 82 # prefetch alloctype data 83 $sth = $dbh->prepare("select type,def_custid,arin_netname from alloctypes where listorder <500"); 84 $sth->execute; 85 while (my @data = $sth->fetchrow_array) { 86 $netnameprefix{$data[0]} = $data[2]; 87 } 88 78 89 # Now read out the data in the "main" delegation list, and check it 79 90 # with the master blocks. We need to do this to decide which rWHOIS … … 83 94 # No use or point in broadcasting our use of them. 84 95 # Also remove the details of our "reserved CORE/WAN" blocks; they're not critical. 85 $sth = $dbh->prepare("select cidr,custid,type,city,description,createstamp,modifystamp ".96 $sth = $dbh->prepare("select cidr,custid,type,city,description,createstamp,modifystamp,swip ". 86 97 "from allocations where ". 87 98 "not (cidr <<= '192.168.0.0/16') and ". … … 93 104 $sth->execute; 94 105 106 my $custsth = $dbh->prepare("select name,street,city,province,country,pocode,phone,tech_handle,special from customers where custid=?"); 107 95 108 $i=0; 96 while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime ) = $sth->fetchrow_array) {109 while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime, $swip) = $sth->fetchrow_array) { 97 110 98 111 # We get master block info from @masterblocks. … … 134 147 ($mtime) = ($mtime =~ /^(\d+-\d+-\d+)\s+/); 135 148 136 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 137 "Auth-Area: $master\n". 138 "Network-Name: ISP-".$net->network."\n". 139 "IP-Network: $net\n". 140 "IP-Network-Block: ".$net->range."\n". 141 "Organization: $desc\n". 142 # "Tech-Contact: $data[9]\n". 143 "Tech-Contact: abuse\@example.com\n". 144 "Admin-Contact: ISP-ARIN-HANDLE\n". 145 "Created: $ctime\n". 146 "Updated: $mtime\n". 147 "Updated-By: noc\@example.com\n"; 148 } 149 } 149 # Notes: 150 # Network-name should contain some component of "description" 151 # Cust address/contact data should be included; NB, no phone for ARIN! 152 # network:ID: NET-WIDGET 153 # network:Network-Name: WIDGET [IPDB description, sort of] 154 # network:IP-Network: 10.1.1.0/24 155 # network:Org-Name: Widget Corp [Cust name; from billing?] 156 # network:Street-Address: 211 Oak Drive [May need more than one line, OR...] 157 # network:City: Pineville [...this line...] 158 # network:StateProv: WI [...and this line...] 159 # network:Postal-Code: 48888 [...and this line] 160 # network:Country-Code: US 161 # network:Tech-Contact: BZ142-MYRWHOIS [ARIN handle?] 162 # network:Updated: 19991221 [timestamp from db] 163 # network:Updated-By: jo@myrwhois.net [noc@example, since that's our POC for IP netspace issues] 164 # network:Class-Name:network [Provided by rWHOIS protocol] 165 166 my $netname = $netnameprefix{$type}; 167 168 if ($swip eq 'n') { 169 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 170 "Auth-Area: $master\n". 171 "Network-Name: $netname-".$net->network."\n". 172 "IP-Network: $net\n". 173 "IP-Network-Block: ".$net->range."\n". 174 "Org-Name: Friendly ISP\n". 175 "Street-Address: 123 4th Street\n". 176 "City: Anytown\n". 177 "StateProv: Ontario\n". 178 "Postal-Code: H0H 0H0\n". 179 "Country-Code: CA\n". 180 "Tech-Contact: ISP-ARIN-HANDLE\n". 181 "Created: $ctime\n". 182 "Updated: $mtime\n". 183 "Updated-By: noc\@example.com\n"; 184 } else { 185 $custsth->execute($custid); 186 my ($name, $street, $city, $prov, $country, $pocode, $phone, $tech, $special) = $custsth->fetchrow_array; 187 $custsth->finish; 188 if ($special && $special =~ /NetName/ && $special =~ /$cidr/) { 189 ($netname) = ($special =~ /NetName$cidr: ([A-Z0-9_-]+)/); 190 } else { 191 $netname .= "-".$net->network; 192 } 193 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 194 "Auth-Area: $master\n". 195 "Network-Name: $netname\n". 196 "IP-Network: $net\n". 197 "IP-Network-Block: ".$net->range."\n". 198 "Org-Name: $name\n". 199 "Street-Address: $street\n". 200 "City: $city\n". 201 "StateProv: $prov\n". 202 "Postal-Code: $pocode\n". 203 "Country-Code: $country\n". 204 "Tech-Contact: $tech\n". 205 "Created: $ctime\n". 206 "Updated: $mtime\n". 207 "Updated-By: noc\@example.com\n"; 208 } # swip 209 210 } # net in master 211 } # foreach master 150 212 151 213
Note:
See TracChangeset
for help on using the changeset viewer.