Changeset 324


Ignore:
Timestamp:
04/06/06 15:47:21 (18 years ago)
Author:
Kris Deugau
Message:

/trunk

Refactor rWHOIS export for easier rWHOIS data access.
Update SQL tabledefs (customers table, alloctypes table) and

predefined alloctypes list with database changes.

Add rWHOIS configuration files and notes

Location:
trunk/cgi-bin
Files:
3 added
2 edited

Legend:

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

    r311 r324  
    2828
    2929my @masterblocks;
     30my %netnameprefix;
    3031
    3132# Fill in data about our master blocks as allocated from ARIN
     
    3334# Note that this ASS-U-MEs that we do not add master IP blocks-
    3435# there should probably be a separate system for doing that.
    35 my $sth = $dbh->prepare("select cidr,ctime from masterblocks;");
     36my $sth = $dbh->prepare("select cidr,ctime,mtime from masterblocks;");
    3637$sth->execute;
    3738my $i=0;
     
    4546  $masterblocks[$i] = new NetAddr::IP $data[0];
    4647  my ($ctime,undef) = split /\s/, $data[1];
    47 
    48 print "$masterblocks[$i] $data[1]\n";
     48  my ($mtime,undef) = split /\s/, $data[2];
     49print "$masterblocks[$i] $ctime $mtime\n";
    4950
    5051  my $date;
     
    6465        "IP-Network: $masterblocks[$i]\n".
    6566        "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".
    7074        "Created: $ctime\n".
    71         "Updated: $date\n".
     75        "Updated: $mtime\n".
    7276        "Updated-By: noc\@example.com\n";
    7377
     
    7680}
    7781
     82# prefetch alloctype data
     83$sth = $dbh->prepare("select type,def_custid,arin_netname from alloctypes where listorder <500");
     84$sth->execute;
     85while (my @data = $sth->fetchrow_array) {
     86  $netnameprefix{$data[0]} = $data[2];
     87}
     88
    7889# Now read out the data in the "main" delegation list, and check it
    7990# with the master blocks.  We need to do this to decide which rWHOIS
     
    8394# No use or point in broadcasting our use of them.
    8495# 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 ".
    8697        "from allocations where ".
    8798        "not (cidr <<= '192.168.0.0/16') and ".
     
    93104$sth->execute;
    94105
     106my $custsth = $dbh->prepare("select name,street,city,province,country,pocode,phone,tech_handle,special from customers where custid=?");
     107
    95108$i=0;
    96 while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime) = $sth->fetchrow_array) {
     109while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime, $swip) = $sth->fetchrow_array) {
    97110
    98111# We get master block info from @masterblocks.
     
    134147      ($mtime) = ($mtime =~ /^(\d+-\d+-\d+)\s+/);
    135148
    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
    150212
    151213
  • trunk/cgi-bin/ipdb.psql

    r321 r324  
    1010        "city" character varying(30),
    1111        "province" character(2),
     12        "country" character(2),
    1213        "pocode" character varying(7),
    1314        "phone" character varying(15),
    14         "abuse" character varying(50),
     15        "tech_handle" character varying(50),
     16        "abuse_handle" character varying(50),
     17        "admin_handle" character varying(50),
    1518        "def_rdns" character varying(40),
    16         "description" text,
     19        "special" text,
    1720        Constraint "customers_pkey" Primary Key ("custid")
    1821);
     
    2326CREATE TABLE "masterblocks" (
    2427        "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
    25         "ctime" timestamp DEFAULT now()
     28        "ctime" timestamp DEFAULT now(),
     29        "mtime" timestamp DEFAULT now()
    2630);
    2731
     
    106110        "dispname" character varying(40) DEFAULT '',
    107111        "listorder" integer DEFAULT 0,
    108         "def_custid" character varying(16) DEFAULT ''
     112        "def_custid" character varying(16) DEFAULT '',
     113        "arin_netname" character varying(20) DEFAILT 'ISP'
    109114);
    110115
     
    113118--
    114119
    115 COPY alloctypes ("type", listname, dispname, listorder, def_custid) FROM stdin;
    116 cn      Customer netblock       Customer netblock       0       
    117 si      Static IP - Server pool Server pool IP  20     
    118 ci      Static IP - Cable       Static cable IP 21     
    119 di      Static IP - DSL Static DSL IP   22     
    120 mi      Static IP - Dialup      Static dialup IP        23     
    121 wi      Static IP - Wireless    Static wireless IP      24     
    122 sd      Static Pool - Servers   Server pool     40      6750400
    123 cd      Static Pool - Cable     Cable pool      41      CBL-BUS
    124 dp      Static Pool - DSL       DSL pool        42      DSL-BUS
    125 mp      Static Pool - Dialup    Static dialup pool      43      DIAL-BUS
    126 wp      Static Pool - Wireless  Static wireless pool    44      WL-BUS
    127 en      End-use netblock        End-use netblock        100     6750400
    128 me      Dialup netblock Dialup netblock 101     DIAL-RES
    129 de      Dynamic DSL block       Dynamic DSL block       102     DSL-RES
    130 ce      Dynamic cable block     Dynamic cable block     103     CBL-RES
    131 we      Dynamic WiFi block      Dynamic WiFi block      104     WL-RES
    132 ve      Dynamic VoIP block      Dynamic VoIP block      105     DYN-VOIP
    133 li      Static IP - LAN/POP     Static LAN/POP IP       190     6750400
    134 ai      Static IP - Managment   Static management IP    192     6750400
    135 ad      Static Pool - Managment Management pool 196     6750400
    136 ld      Static Pool - LAN/POP   LAN pool        195     6750400
    137 wc      Reserve for CORE/WAN blocks     CORE/WAN blocks 200     6750400
    138 pc      Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201     6750400
    139 ac      Reserve for ATM ATM blocks      202     6750400
    140 wr      CORE/WAN block  CORE/WAN block  220     6750400
    141 pr      Dynamic-route DSL netblock      Dynamic-route DSL       221     
    142 ar      ATM block       ATM block       222     
    143 rm      Routing Routed netblock 500     6750400
    144 in      Internal netblock       Internal netblock       990     6750400
    145 mm      Master block    Master block    999     6750400
     120COPY "alloctypes" FROM stdin;
     121cn      Customer netblock       Customer netblock       0               ISPCUST
     122si      Static IP - Server pool Server pool IP  20      6750400 ISP
     123ci      Static IP - Cable       Static cable IP 21              ISP
     124di      Static IP - DSL Static DSL IP   22              ISP
     125mi      Static IP - Dialup      Static dialup IP        23              ISP
     126wi      Static IP - Wireless    Static wireless IP      24              ISP
     127sd      Static Pool - Servers   Server pool     40      6750400 ISP
     128cd      Static Pool - Cable     Cable pool      41      CBL-BUS ISP-STATIC-CABLE
     129dp      Static Pool - DSL       DSL pool        42      DSL-BUS ISP-STATIC-DSL
     130mp      Static Pool - Dialup    Static dialup pool      43      DIAL-BUS        ISP-STATIC-DIAL
     131wp      Static Pool - Wireless  Static wireless pool    44      WL-BUS  ISP-STATIC-WIFI
     132en      End-use netblock        End-use netblock        100     6750400 ISP
     133me      Dialup netblock Dialup netblock 101     DIAL-RES        ISP-DIAL
     134de      Dynamic DSL block       Dynamic DSL block       102     DSL-RES ISP-DSL
     135ce      Dynamic cable block     Dynamic cable block     103     CBL-RES ISP-CABLE
     136we      Dynamic WiFi block      Dynamic WiFi block      104     WL-RES  ISP-WIFI
     137ve      Dynamic VoIP block      Dynamic VoIP block      105     DYN-VOIP        ISP
     138li      Static IP - LAN/POP     Static LAN/POP IP       190     6750400 ISP
     139ld      Static Pool - LAN/POP   LAN pool        191     6750400 ISP
     140wc      Reserve for CORE/WAN blocks     CORE/WAN blocks 200     6750400 ISP
     141pc      Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201     6750400 ISP-STATIC-DSL
     142ac      Reserve for ATM ATM blocks      202     6750400 ISP
     143wr      CORE/WAN block  CORE/WAN block  220     6750400 ISP
     144pr      Dynamic-route DSL netblock      Dynamic-route DSL       221             ISP
     145ar      ATM block       ATM block       222             ISP
     146rm      Routing Routed netblock 500     6750400 ISP
     147in      Internal netblock       Internal netblock       990     6750400 ISP
     148mm      Master block    Master block    999     6750400 ISP
    146149\.
    147150
Note: See TracChangeset for help on using the changeset viewer.