- Timestamp:
- 04/06/05 17:06:28 (20 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/extras/db2rwhois.pl
r146 r218 17 17 use NetAddr::IP; 18 18 use MyIPDB; 19 use Digest::MD5 qw(md5_hex); 19 20 20 21 $ENV{"PATH"} = "/bin;/usr/bin"; … … 41 42 # Note that this ASS-U-MEs that we do not add master IP blocks- 42 43 # there should probably be a separate system for doing that. 43 my $sth = $dbh->prepare("select *from masterblocks;");44 my $sth = $dbh->prepare("select cidr,ctime from masterblocks;"); 44 45 $sth->execute; 45 46 my $i=0; 46 47 GETMASTERS: while (my @data = $sth->fetchrow_array()) { 47 48 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 # } 51 52 $masterblocks[$i] = new NetAddr::IP $data[0]; 52 53 … … 55 56 my $date; 56 57 chomp ($date = `/bin/date +"%Y%m%d"`); 58 my ($ctime,undef) = split /\s+/, $data[1]; 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 * 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"); 90 95 $sth->execute; 91 96 92 while (my @data= $sth->fetchrow_array()) {97 while (my ($cidr,$custid,$type,$city,$description,$ctime,$mtime) = $sth->fetchrow_array()) { 93 98 94 99 # We get master block info from @masterblocks. … … 105 110 # Updated-By: noc@example.com 106 111 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; 109 114 110 115 # Assumptions: All data in ipdb is public … … 121 126 or print "File open error: '$!' on '$rwhoisDataPath/$masterfilename'\n"; 122 127 123 # cidr custid type city description notes maskbits124 125 # Creation date in record to eventually be "correct"; near-term will126 # be master's creation date; immediate is today's date.127 my $date;128 chomp ($date = `/bin/date +"%Y%m%d"`);129 128 if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; } 129 print "$type-type $net for $custid, created $ctime, modified $mtime\n"; 130 130 print MASTERFILE "---\nID: NETBLK-ISP.$master\n". 131 131 "Auth-Area: $master\n". … … 133 133 "IP-Network: $net\n". 134 134 "IP-Network-Block: ".$net->range."\n". 135 "Organization: $d ata[4]\n".135 "Organization: $description\n". 136 136 # "Tech-Contact: $data[9]\n". 137 137 "Tech-Contact: abuse\@example.com\n". 138 138 "Admin-Contact: ISP-ARIN-HANDLE\n". 139 "Created: $ date\n".140 "Updated: $ date\n".139 "Created: $ctime\n". 140 "Updated: $mtime\n". 141 141 "Updated-By: noc\@example.com\n"; 142 142 } … … 154 154 155 155 $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 }; -
trunk/cgi-bin/ipdb.psql
r189 r218 70 70 "circuitid" character varying(128) DEFAULT '' NOT NULL, 71 71 "newcustid" integer, 72 "createstamp" timestamp DEFAULT now(), 73 "modifystamp" timestamp DEFAULT now(), 72 74 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar))) 73 75 ); … … 86 88 "maskbits" integer DEFAULT 128, 87 89 "circuitid" character varying(128) DEFAULT '', 90 "createstamp" timestamp DEFAULT now(), 91 "modifystamp" timestamp DEFAULT now(), 88 92 "newcustid" integer 89 93 ); … … 182 186 pr Dynamic-route DSL netblock Dynamic-route DSL 203 183 187 \. 188 189 -- 190 -- Trigger and matching function to update modifystamp on allocations, poolips 191 -- 192 CREATE FUNCTION up_modtime () RETURNS OPAQUE AS ' 193 BEGIN 194 NEW.modifystamp := ''now''; 195 RETURN NEW; 196 END; 197 ' LANGUAGE 'plpgsql'; 198 199 CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations 200 FOR EACH ROW EXECUTE PROCEDURE up_modtime(); 201 202 CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips 203 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
Note:
See TracChangeset
for help on using the changeset viewer.