Changeset 417 for trunk


Ignore:
Timestamp:
06/30/10 17:48:03 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

Rearrangements and tweaks toward releaseability:

  • Add Makefile to install halfway-sanely
  • Add .spec file
  • Shuffle "use IPDB;" and "use MyIPDB;" lines so that we can automagically insert a suitable "use lib..." line during 'make install'
  • Check copyright statements
  • Clear up some defaults, and place a number of "constants" in IPDB/MyIPDB rather than having them hardcoded all over the place (Still need to think of a sane way to do this for ipdb.psql's alloctype preseeding)
  • Tweak $VERSION identifier in IPDB.pm so it can be defined in the Makefile
  • Clean up some dangling bits from repository history conversion, remove unneeded "use ..." statements
  • Tweak rWHOIS export script to use more globals and "constants" from (My)IPDB.pm, and more Perl internals than system()-equivalents. Add a few fixme comments for longer-term flexibility improvements.
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/CustIDCK.pm

    r400 r417  
    3434
    3535  return 1 if $custid =~ /^STAFF$/;
    36   return 1 if $custid =~ /^6750400$/;  # just in case some later change might block this
     36  return 1 if $custid =~ /^5554242$/;  # just in case some later change might block this
    3737  return 1 if $custid =~ /^\d{7}$/;
    3838  return 1 if $custid =~ /^\d{10}$/;
  • trunk/cgi-bin/IPDB.pm

    r416 r417  
    77# Last update by $Author$
    88###
    9 # Copyright (C) 2004-2006 - Kris Deugau
     9# Copyright (C) 2004-2010 - Kris Deugau
    1010
    1111package IPDB;
     
    2020use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
    2121
    22 $VERSION        = 2.6;
     22$VERSION        = 2; ##VERSION##
    2323@ISA            = qw(Exporter);
    2424@EXPORT_OK    = qw(
     
    5353our %IPDBacl;
    5454
    55 our $orgname = 'Example Corp';
     55our $org_name = 'Example Corp';
    5656our $smtphost = 'smtp.example.com';
    5757our $domain = 'example.com';
     58our $defcustid = '5554242';
     59# mostly for rwhois
     60##fixme:  leave these blank by default?
     61our $org_street = '123 4th Street';
     62our $org_city = 'Anytown';
     63our $org_prov_state = 'ON';
     64our $org_pocode = 'H0H 0H0';
     65our $org_country = 'CA';
     66our $org_phone = '000-555-1234';
     67our $org_techhandle = 'ISP-ARIN-HANDLE';
     68
     69our $syslog_facility = 'local2';
    5870
    5971# Let's initialize the globals.
     
    561573    # have to insert all pool IPs into poolips table as "unallocated".
    562574    $sth = $dbh->prepare("insert into poolips (pool,ip,custid,city,type)".
    563         " values ('$pool', ?, '6750400', '$city', '$type')");
     575        " values ('$pool', ?, '$defcustid', '$city', '$type')");
    564576    my @poolip_list = $pool->hostenum;
    565577    if ($class eq 'all') { # (DSL-ish block - *all* IPs available
     
    618630    eval {
    619631      $msg = "Unable to deallocate $disp_alloctypes{$type} $cidr";
    620       $sth = $dbh->prepare("update poolips set custid='6750400',available='y',".
     632      $sth = $dbh->prepare("update poolips set custid='$defcustid',available='y',".
    621633        "city=(select city from allocations where cidr >>= '$cidr'".
    622634        " order by masklen(cidr) desc limit 1),".
     
    716728##TEMP
    717729  # We've already deleted the block, now we have to stuff its IPs into the pool.
    718   my $sth2 = $dbh->prepare("insert into poolips values ('209.91.185.0/24',?,'6750400','Sudbury','di','y','','','')");
     730  my $sth2 = $dbh->prepare("insert into poolips values ('209.91.185.0/24',?,'$defcustid','Sudbury','di','y','','','')");
    719731  $sth2->execute($cidr->addr);
    720732  foreach my $ip ($cidr->hostenum) {
     
    849861        "Subject: {IPDB} $subj\n",
    850862        "X-Mailer: IPDB Notify v".sprintf("%.1d",$IPDB::VERSION)."\n",
    851         "Organization: $orgname\n",
     863        "Organization: $org_name\n",
    852864        "\n$message\n");
    853865  }
  • trunk/cgi-bin/MyIPDB.pm

    r416 r417  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004-2006 - Kris Deugau
     10# Copyright (C) 2004-2010 - Kris Deugau
     11
     12# don't remove!  required for GNU/FHS-ish install from tarball
     13##uselib##
    1114
    1215use IPDB 2.0 qw(:ALL);
     
    2427#$IPDB::smtphost = '127.0.0.1';
    2528#$IPDB::domain = 'bob.com';
     29#$IPDB::defcustid = '5554242';
     30# Globals for db2rwhois.pl
     31#$IPDB::org_street = '123 4th Street';
     32#$IPDB::org_city = 'Anytown';
     33#$IPDB::org_prov_state = 'ON';
     34#$IPDB::org_pocode = 'H0H 0H0';
     35#$IPDB::org_country = 'CA';
     36#$IPDB::org_phone = '000-555-1234';
     37# note: following may also just be a bare email address
     38#$IPDB::org_techhandle = 'ISP-ARIN-HANDLE';
     39
     40# Logging destination.  Defaults to local2.  See your local syslog docs for valid facilities.
     41# Note that the value here should have the LOG_ prefix removed, and convert to lower-case.
     42# local0 through local7 and user make the most sense.
     43#$IPDB::syslog_facility = 'daemon';
    2644
    2745# Keep Perl from complaining.
  • trunk/cgi-bin/access-pwd-update.pl

    r399 r417  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2007,2008 - Kris Deugau
     10# Copyright (C) 2007-2010 - Kris Deugau
    1111
    1212use strict;
    1313use warnings;
    1414use DBI;
    15 use lib '/var/www/ipdb.example.com/ip/cgi-bin/';
     15
     16# don't remove!  required for GNU/FHS-ish install from tarball
     17##uselib##
     18
    1619use MyIPDB;
    1720
  • trunk/cgi-bin/admin.cgi

    r416 r417  
    1010# Last update by $Author$
    1111###
    12 # Copyright (C) 2004-2006 - Kris Deugau
     12# Copyright (C) 2004-2010 - Kris Deugau
    1313
    1414use strict;
     
    1717use DBI;
    1818use CommonWeb qw(:ALL);
    19 use MyIPDB;
    2019use CustIDCK;
    2120#use POSIX qw(ceil);
     
    2322
    2423use Sys::Syslog;
     24
     25# don't remove!  required for GNU/FHS-ish install from tarball
     26##uselib##
     27
     28use MyIPDB;
    2529
    2630openlog "IPDB-admin","pid","local2";
     
    149153      if (!$status) {
    150154        printError("Customer ID not valid.  Make sure the Customer ID ".
    151           "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     155          "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
    152156          "non-customer assignments.");
    153157        return;
  • trunk/cgi-bin/allocate.pl

    r198 r417  
    1010use strict;
    1111use warnings;
    12 #use CGI::Carp qw(fatalsToBrowser);
    13 use Carp;
    1412use DBI;
    1513use CommonWeb qw(:ALL);
    16 use MyIPDB;
    17 use IBLink;
    18 use POSIX qw(ceil);
    1914use NetAddr::IP;
    2015
    2116use Sys::Syslog;
     17
     18# don't remove!  required for GNU/FHS-ish install from tarball
     19##uselib##
     20
     21use MyIPDB;
    2222
    2323openlog "IPDBshell","pid","local2";
  • trunk/cgi-bin/checkcusts.pl

    r400 r417  
    77# Last update by $Author$
    88###
    9 # Copyright (C) 2004-2006 Kris Deugau
     9# Copyright (C) 2004-2010 Kris Deugau
    1010
    1111use DBI;
     
    3333  push @def_custids, $data[0];
    3434}
    35 $sth = $dbh->prepare("select cidr,custid from searchme where not (custid='6750400') ".
     35$sth = $dbh->prepare("select cidr,custid from searchme where not (custid='$IPDB::defcustid') ".
    3636        "and not (custid='STAFF') order by cidr");
    3737#$sth = $dbh->prepare("select cidr,custid from searchme order by cidr");
  • trunk/cgi-bin/combineblocks.pl

    r401 r417  
    1414use DBI;
    1515#use CommonWeb qw(:ALL);
    16 use MyIPDB;
    1716#use POSIX qw(ceil);
    1817use NetAddr::IP;
    1918
    20 #use Sys::Syslog;
     19# don't remove!  required for GNU/FHS-ish install from tarball
     20##uselib##
     21
     22use MyIPDB;
    2123
    2224my $null = new NetAddr::IP "255.255.255.255/32";
  • trunk/cgi-bin/consistency-check.pl

    r402 r417  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004 - Kris Deugau
     10# Copyright (C) 2004-2010 - Kris Deugau
    1111
    1212use DBI;
     13use NetAddr::IP;
     14
     15# don't remove!  required for GNU/FHS-ish install from tarball
     16##uselib##
     17
    1318use MyIPDB;
    14 use NetAddr::IP;
    1519
    1620print "Content-type: text/plain\n\n";
     
    230234print "Checking for customer blocks with 'bad' CustIDs:\n";
    231235# Make sure cn-type ("customer netblock") blocks have "real" CustIDs.
    232 $sth = $dbh->prepare("select cidr,type,custid from allocations where type='cn' and (custid='6750400' or custid='STAFF') order by cidr");
     236$sth = $dbh->prepare("select cidr,type,custid from allocations where type='cn' and (custid='$IPDB::defcustid' or custid='STAFF') order by cidr");
    233237$sth->execute;
    234238while (@data = $sth->fetchrow_array) {
  • trunk/cgi-bin/extras/db2rwhois.pl

    r380 r417  
    1010# Last update by $Author$
    1111###
    12 # Copyright (C) 2004-2007 - Kris Deugau
     12# Copyright (C) 2004-2010 - Kris Deugau
    1313
    1414use strict;
     
    1616use DBI;
    1717use NetAddr::IP;
     18use File::Path 'rmtree';
     19use POSIX qw(strftime);
     20
     21# don't remove!  required for GNU/FHS-ish install from tarball
     22##uselib##
     23
    1824use MyIPDB;
    19 use File::Path 'rmtree';
    20 
    21 $ENV{"PATH"} = "/bin;/usr/bin";
     25
     26#$ENV{"PATH"} = "/bin;/usr/bin";
    2227
    2328my $rwhoisDataPath = "/etc/rwhoisd";
     
    9196  print "$masterblocks[$i] $ctime $mtime\n";
    9297
    93   my $date;
    94   chomp ($date = `/bin/date +"%Y-%m-%d"`);
     98  my $date = strftime("%Y-%m-%d", localtime);
    9599
    96100  my $rwnet = "net-".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen;
     
    111115    mkdir "$netdatadir/data/referral";
    112116
    113     my $serial;
    114     chomp ($serial = `/bin/date '+%Y%m%d'000000000`);
    115 
     117    my $serial = strftime("%Y%m%d%H%M%S000", localtime);
     118
     119##fixme: SOA should be different every time data changes, therefore need to rewrite this ~~ every export :(
    116120    print "  Creating SOA...\n";
    117121    open SOAFILE, ">$netdatadir/soa";
     
    147151
    148152    print "  Copying template files...\n";
     153##fixme: find a way to do this without a shell (or functional equivalent)
    149154    qx { /bin/cp $rwhoisDataPath/skel/attribute_defs/* $netdatadir/attribute_defs/ };
    150155
     156##fixme: not sure if this is even necessary, since it's not referenced anywhere I can recall...
    151157    print "  Creating org data...\n";
    152     open ORGDATAFILE, ">$netdatadir/data/org/friendlyisp.txt";
     158    open ORGDATAFILE, ">$netdatadir/data/org/ourorg.txt";
    153159    print ORGDATAFILE qq(ID: NETBLK-ISP.$masterblocks[$i]
    154160Auth-Area: $masterblocks[$i]
    155 Org-Name: Friendly ISP
    156 Street-Address: 123 4th Street
    157 City: Anytown
    158 State: ON
    159 Postal-Code: H0H 0H0
    160 Country-Code: CA
    161 Phone: 000-555-1234
     161Org-Name: $IPDB::org_name
     162Street-Address: $IPDB::org_street
     163City: $IPDB::org_city
     164State: $IPDB::org_prov_state
     165Postal-Code: $IPDB::org_pocode
     166Country-Code: $IPDB::org_country
     167Phone: $IPDB::org_phone
    162168Created: 20040308
    163169Updated: 20040308
     
    189195        "IP-Network: $masterblocks[$i]\n".
    190196        "IP-Network-Block: ".$masterblocks[$i]->range."\n".
    191         "Org-Name: Friendly ISP\n".
    192         "Street-Address: 123 4th Street\n".
    193         "City: Anytown\n".
    194         "StateProv: Ontario\n".
    195         "Postal-Code: H0H 0H0\n".
    196         "Country-Code: CA\n".
    197         "Tech-Contact: ISP-ARIN-HANDLE\n".
     197        "Org-Name: $IPDB::org_name\n".
     198        "Street-Address: $IPDB::org_street\n".
     199        "City: $IPDB::org_city\n".
     200        "StateProv: $IPDB::org_prov_state\n".
     201        "Postal-Code: $IPDB::org_pocode\n".
     202        "Country-Code: $IPDB::org_country\n".
     203        "Tech-Contact: $IPDB::org_techhandle\n".
    198204        "Created: $ctime\n".
    199205        "Updated: $mtime\n".
     
    226232
    227233# Fill in a generic entry for nameless allocations
    228 if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }
     234if ($desc =~ /^\s*$/) { $desc = $IPDB::org_name; }
    229235
    230236    # Fix up datestamps.  We don't *really* need sub-microsecond resolution on our exports...
     
    257263        "IP-Network: $net\n".
    258264        "IP-Network-Block: ".$net->range."\n".
    259         "Org-Name: Friendly ISP\n".
    260         "Street-Address: 123 4th Street\n".
    261         "City: Anytown\n".
    262         "StateProv: Ontario\n".
    263         "Postal-Code: H0H 0H0\n".
    264         "Country-Code: CA\n".
    265         "Tech-Contact: ISP-ARIN-HANDLE\n".
     265        "Org-Name: $IPDB::org_name\n".
     266        "Street-Address: $IPDB::org_street\n".
     267        "City: $IPDB::org_city\n".
     268        "StateProv: $IPDB::org_prov_state\n".
     269        "Postal-Code: $IPDB::org_pocode\n".
     270        "Country-Code: $IPDB::org_country\n".
     271        "Tech-Contact: $IPDB::org_techhandle\n".
    266272        "Created: $ctime\n".
    267273        "Updated: $mtime\n".
     
    281287        "IP-Network: $net\n".
    282288        "IP-Network-Block: ".$net->range."\n".
    283         "Org-Name: ".($name ? $name : 'Friendly ISP')."\n".
    284         "Street-Address: ".($street ? $street : '123 4th Street')."\n".
    285         "City: ".($city ? $city : 'Anytown')."\n".
    286         "StateProv: ".($prov ? $prov : 'Ontario')."\n".
    287         "Postal-Code: ".($pocode ? $pocode : 'H0H 0H0')."\n".
    288         "Country-Code: ".($country ? $country : 'CA')."\n".
    289         "Tech-Contact: ".($tech ? $tech : 'ISP-ARIN-HANDLE')."\n".
     289        "Org-Name: ".($name ? $name : $IPDB::org_name)."\n".
     290        "Street-Address: ".($street ? $street : $IPDB::org_street)."\n".
     291        "City: ".($city ? $city : $IPDB::org_city)."\n".
     292        "StateProv: ".($prov ? $prov : $IPDB::org_prov_state)."\n".
     293        "Postal-Code: ".($pocode ? $pocode : $IPDB::org_pocode)."\n".
     294        "Country-Code: ".($country ? $country : $IPDB::org_country)."\n".
     295        "Tech-Contact: ".($tech ? $tech : $IPDB::org_techhandle)."\n".
    290296        "Created: $ctime\n".
    291297        "Updated: $mtime\n".
  • trunk/cgi-bin/freespace.pl

    r320 r417  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004-2006 - Kris Deugau
     10# Copyright (C) 2004-2010 - Kris Deugau
    1111
    1212use DBI;
     13use NetAddr::IP;
     14
     15# don't remove!  required for GNU/FHS-ish install from tarball
     16##uselib##
     17
    1318use MyIPDB;
    14 use NetAddr::IP;
    1519
    1620($dbh,$errstr) = connectDB_My;
  • trunk/cgi-bin/ipdb.psql

    r416 r417  
    137137mi      Static IP - Dialup      Static dialup IP        23              ISP
    138138wi      Static IP - Wireless    Static wireless IP      24              ISP
    139 sd      Static Pool - Servers   Server pool     40      6750400 ISP
     139sd      Static Pool - Servers   Server pool     40      5554242 ISP
    140140cd      Static Pool - Cable     Cable pool      41      CBL-BUS ISP-STATIC-CABLE
    141141dp      Static Pool - DSL       DSL pool        42      DSL-BUS ISP-STATIC-DSL
    142142mp      Static Pool - Dialup    Static dialup pool      43      DIAL-BUS        ISP-STATIC-DIAL
    143143wp      Static Pool - Wireless  Static wireless pool    44      WL-BUS  ISP-STATIC-WIFI
    144 en      End-use netblock        End-use netblock        100     6750400 ISP
     144en      End-use netblock        End-use netblock        100     5554242 ISP
    145145me      Dialup netblock Dialup netblock 101     DIAL-RES        ISP-DIAL
    146146de      Dynamic DSL block       Dynamic DSL block       102     DSL-RES ISP-DSL
     
    154154ad      Static Pool - Management        Management pool 196     NOC-VPN ISP
    155155bd      Static pool - Wifi CPE  Wifi CPE pool   197             ISP
    156 in      Internal netblock       Internal netblock       199     6750400 ISP
    157 wc      Reserve for CORE/WAN blocks     CORE/WAN blocks 200     6750400 ISP
    158 pc      Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201     6750400 ISP-STATIC-DSL
    159 ac      Reserve for ATM ATM blocks      202     6750400 ISP
    160 fc      Reserve for fibre       Fibre blocks    203     6750400 ISP
    161 wr      CORE/WAN block  CORE/WAN block  220     6750400 ISP
     156in      Internal netblock       Internal netblock       199     5554242 ISP
     157wc      Reserve for CORE/WAN blocks     CORE/WAN blocks 200     5554242 ISP
     158pc      Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201     5554242 ISP-STATIC-DSL
     159ac      Reserve for ATM ATM blocks      202     5554242 ISP
     160fc      Reserve for fibre       Fibre blocks    203     5554242 ISP
     161wr      CORE/WAN block  CORE/WAN block  220     5554242 ISP
    162162pr      Dynamic-route DSL netblock (cust)       Dynamic-route DSL (cust)        221             ISPCUST
    163163ar      ATM block       ATM block       222             ISP
    164164fr      Fibre   Fibre   223             ISP
    165 rm      Routing Routed netblock 500     6750400 ISP
    166 mm      Master block    Master block    999     6750400 ISP
     165rm      Routing Routed netblock 500     5554242 ISP
     166mm      Master block    Master block    999     5554242 ISP
    167167\.
    168168
  • trunk/cgi-bin/main.cgi

    r416 r417  
    77# Last update by $Author$
    88###
     9# Copyright (C) 2004-2010 - Kris Deugau
    910
    1011use strict;             
     
    1314use DBI;
    1415use CommonWeb qw(:ALL);
    15 use MyIPDB;
    1616use CustIDCK;
    1717use POSIX qw(ceil);
     
    1919
    2020use Sys::Syslog;
     21
     22# don't remove!  required for GNU/FHS-ish install from tarball
     23##uselib##
     24
     25use MyIPDB;
    2126
    2227openlog "IPDB","pid","local2";
     
    956961      if (!$status) {
    957962        printError("Customer ID not valid.  Make sure the Customer ID ".
    958           "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     963          "is correct.<br>\nUse STAFF for staff static IPs, and $defcustid for any other ".
    959964          "non-customer assignments.");
    960965        return;
  • trunk/cgi-bin/newcity.cgi

    r416 r417  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004,2005 - Kris Deugau
     10# Copyright (C) 2004-2010 - Kris Deugau
    1111
    1212use strict;
     
    1515use DBI;
    1616use CommonWeb qw(:ALL);
    17 use MyIPDB;
    1817#use POSIX qw(ceil);
    1918use NetAddr::IP;
    2019
    2120use Sys::Syslog;
     21
     22# don't remove!  required for GNU/FHS-ish install from tarball
     23##uselib##
     24
     25use MyIPDB;
    2226
    2327openlog "IPDB","pid","local2";
  • trunk/cgi-bin/newnode.cgi

    r416 r417  
    1515use DBI;
    1616use CommonWeb qw(:ALL);
    17 use MyIPDB;
    1817#use POSIX qw(ceil);
    1918use NetAddr::IP;
    20 
    2119use Sys::Syslog;
    2220
    23 openlog "IPDB","pid","local2";
     21# don't remove!  required for GNU/FHS-ish install from tarball
     22##uselib##
     23
     24use MyIPDB;
     25
     26openlog "IPDB","pid","$IPDB::syslog_facility";
    2427
    2528# Collect the username from HTTP auth.  If undefined, we're in a test environment.
  • trunk/cgi-bin/search.cgi

    r402 r417  
    99# Last update by $Author$
    1010###
    11 # Copyright 2005,2006 Kris Deugau
     11# Copyright 2005-2010 - Kris Deugau
    1212
    1313use strict;             
     
    1616use DBI;
    1717use CommonWeb qw(:ALL);
    18 use MyIPDB;
    1918use POSIX qw(ceil);
    2019use NetAddr::IP;
    2120
    22 # Don't need a username or syslog here.  syslog left active for debugging.
    23 use Sys::Syslog;
    24 openlog "IPDBsearch","pid","local2";
     21# don't remove!  required for GNU/FHS-ish install from tarball
     22##uselib##
     23
     24use MyIPDB;
    2525
    2626# Why not a global DB handle?  (And a global statement handle, as well...)
Note: See TracChangeset for help on using the changeset viewer.