Changeset 445


Ignore:
Timestamp:
07/26/10 17:00:00 (14 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Bring /branches/stable up to date with /trunk. See #13.

Location:
branches/stable
Files:
4 deleted
22 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/stable

    • Property svn:ignore
      •  

        old new  
        11local.css
         2*.tar.gz
    • Property svn:mergeinfo changed
      /trunkmerged: 415-420,​422-443
  • branches/stable/alloctypes.html

    r414 r445  
    1111<table class="regular">
    1212
    13 <tr><td colspan=2 class="heading">Allocation Types:</td><tr>
    14 
    15 <tr class="color1">
    16 <td>Customer netblock (default)</td><td>A direct allocation /30 or larger to a
    17 customer.  Note that this does NOT include RADIUS-routed "netblocks".  Internal systems
    18 should use the "End-use netblock" type.</td>
    19 </tr>
    20 
    21 <tr class="color2">
    22 <td>Static IP - Server pool</td><td>A single IP from a pool designated for
    23 servers</td>
    24 </tr><tr class="color1">
    25 <td>Static IP - Cable</td><td>A single IP address from a designated pool
    26 on the cable network.</td>
    27 </tr><tr class="color2">
    28 <td>Static IP - DSL</td><td>A single IP address from a designated pool
    29 on the DSL network.  Note that these are nominally in Sudbury or North Bay,
    30 even if the customer isn't.</td>
    31 </tr><tr class="color1">
    32 <td>Static IP - Dialup</td><td>A single IP address from a designated pool
    33 on a dialup RAS.</td>
    34 </tr><tr class="color2">
    35 <td>Static IP - Wireless</td><td>A single IP address from a designated pool
    36 on one of our wireless networks.</td>
    37 </tr>
    38 
    39 <tr class="color1">
    40 <td>Static pool - Servers</td><td>A pool of IP addresses available for one-by-one
    41 assignment to servers in a POP.  This will usually only be in Sudbury.</td>
    42 </tr><tr class="color2">
    43 <td>Static pool - Cable</td><td>A pool of IP addresses available for one-by-one assignment
    44 to customers on cable.</td>
    45 </tr><tr class="color1">
    46 <td>Static pool - DSL</td><td>A pool of IP addresses available for one-by-one assignment to
    47 customers on DSL.  Note that individual IPs will be "assigned" to the customer's
    48 city, but the pool they are a part of will normally be "assigned" to Sudbury or
    49 North Bay.</td>
    50 </tr><tr class="color2">
    51 <td>Static pool - Dialup</td><td>A pool of IP addresses available for one-by-one
    52 assignment to dialup customers.</td>
    53 </tr><tr class="color1">
    54 <td>Static pool - Wireless</td><td>A pool of IP addresses available for one-by-one
    55 assignment to customers on one of our wireless networks.</td>
    56 </tr>
    57 
    58 <tr class="color2">
    59 <td>End-use netblock</td><td>A /30 or larger allocation for arbitrary services (LAN
    60 management, servers we want fully subnet-isolated, etc)</td>
    61 
    62 </tr><tr class="color1">
    63 <td>Dialup netblock</td><td>Netblock assigned to one or more RAS units in a POP</td>
    64 </tr><tr class="color2">
    65 <td>Dynamic DSL block</td><td>Netblock for (mostly residential) PPPoE DSL.  Nominally
    66 "assigned" to Sudbury</td>
    67 </tr><tr class="color1">
    68 <td>Dynamic cable block</td><td>Netblock for (mostly residential) DHCP cable.</td>
    69 </tr><tr class="color2">
    70 <td>Dynamic WiFi block</td><td>Netblock for (mostly residential) (mostly) PPPoE wireless.</td>
    71 </tr><tr class="color1">
    72 <td>Dynamic VoIP block</td><td>Netblock for DHCP-assigned VoIP services.</td>
    73 
    74 </tr><tr class="color2">
    75 <td>Static IP - LAN/POP</td><td>A single IP address from a designated pool for our
    76 internal LANs - either at a single POP or for a VPN.</td>
    77 </tr><tr class="color1">
    78 <td>Static pool - LAN/POP</td><td>A pool of IP addresses available for one-by-one
    79 assignment to our internal LAN systems or VPNs.</td>
    80 
    81 </tr><tr class="color2">
    82 <td>Reserve for WAN blocks</td><td>Reserve a chunk of IP space for core routers/etc.</td>
    83 </tr><tr class="color1">
    84 <td>Reserve for dynamic-route DSL netblocks</td><td>Reserve a chunk of IP space for
    85 RADIUS-assigned "netblocks" from a PPPoE pool.  Note that this is similar to the static DSL
    86 pool, but IP space is to be allocated as /30 and larger netblocks, not single static IPs.</td>
    87 </tr><tr class="color2">
    88 <td>Reserve for ATM</td><td>Reserve a chunk of IP space for allocation to customers on ATM</td>
    89 </tr><tr class="color1">
    90 <td>WAN block</td><td>Individual netblock assignment for a core router.  Always taken from a
     13<tr><td colspan=2 class="heading">Preseeded Allocation Types:</td><tr>
     14
     15<tr class="color1">
     16<td>Customer netblock (default)</td>
     17<td>A direct allocation /30 or larger to a customer.  Note that this does NOT
     18include RADIUS-routed "netblocks".  Non-customer systems should use the
     19"End-use netblock" type.</td>
     20</tr>
     21
     22<tr class="color2">
     23<td>Static IP - Server pool</td>
     24<td>A single IP from a pool designated for servers</td>
     25</tr>
     26
     27<tr class="color1">
     28<td>Static IP - Cable</td>
     29<td>A single IP address from a designated pool on the cable network.</td>
     30</tr>
     31
     32<tr class="color2">
     33<td>Static IP - DSL</td>
     34<td>A single IP address from a designated pool on the DSL network.</td>
     35</tr>
     36
     37<tr class="color1">
     38<td>Static IP - Dialup</td>
     39<td>A single IP address from a designated pool on a dialup RAS.</td>
     40</tr>
     41
     42<tr class="color2">
     43<td>Static IP - Wireless</td>
     44<td>A single IP address from a designated pool on a wireless connection.</td>
     45</tr>
     46
     47<tr class="color1">
     48<td>Static pool - Servers</td>
     49<td>A pool of IP addresses available for one-by-one assignment to servers in a
     50POP.</td>
     51</tr>
     52
     53<tr class="color2">
     54<td>Static pool - Cable</td>
     55<td>A pool of IP addresses available for one-by-one assignment to customers on
     56cable.</td>
     57</tr>
     58
     59<tr class="color1">
     60<td>Static pool - DSL</td>
     61<td>A pool of IP addresses available for one-by-one assignment to customers on
     62DSL.  Individual IPs will be "assigned" to the customer's city, but the pool
     63will remain assigned to its nominal origin.</td>
     64</tr>
     65
     66<tr class="color2">
     67<td>Static pool - Dialup</td>
     68<td>A pool of IP addresses available for one-by-one assignment to dialup
     69customers.</td>
     70</tr>
     71
     72<tr class="color1">
     73<td>Static pool - Wireless</td>
     74<td>A pool of IP addresses available for one-by-one assignment to customers on a
     75wireless connection.</td>
     76</tr>
     77
     78<tr class="color2">
     79<td>End-use netblock</td>
     80<td>A /30 or larger allocation for arbitrary services - note this should not
     81be used for customer connections.  Use this if exact tracking of IP
     82usage in the block is not required.</td>
     83</tr>
     84
     85<tr class="color1">
     86<td>Dialup netblock</td>
     87<td>Netblock assigned to one or more RAS units in a POP</td>
     88</tr>
     89
     90<tr class="color2">
     91<td>Dynamic DSL block</td>
     92<td>Netblock for (mostly residential) PPPoE DSL.</td>
     93</tr>
     94
     95<tr class="color1">
     96<td>Dynamic cable block</td>
     97<td>Netblock for (mostly residential) DHCP cable.</td>
     98</tr>
     99
     100<tr class="color2">
     101<td>Dynamic WiFi block</td>
     102<td>Netblock for (mostly residential) (mostly) PPPoE wireless.</td>
     103</tr>
     104
     105<tr class="color1">
     106<td>Dynamic VoIP block</td>
     107<td>Netblock for DHCP-assigned VoIP services.</td>
     108</tr>
     109
     110<tr class="color2">
     111<td>Static IP - LAN/POP</td>
     112<td>A single IP address from a designated pool for internal LANs - either at a
     113single POP or for a VPN.</td>
     114</tr>
     115
     116<tr class="color1">
     117<td>Static IP - Managment</td>
     118<td>A single IP address from a designated pool for managed devices.</td>
     119</tr>
     120
     121<tr class="color2">
     122<td>Static IP - Wifi CPE</td>
     123<td>A single IP address from a designated pool for wireless CPE devices.</td>
     124</tr>
     125
     126<tr class="color1">
     127<td>Static pool - LAN/POP</td>
     128<td>A pool of IP addresses available for one-by-one assignment to internal LAN
     129systems or VPNs.</td>
     130</tr>
     131
     132<tr class="color2">
     133<td>Static Pool - Managment</td>
     134<td>A pool of IP addresses available for assignment to managed devices.</td>
     135</tr>
     136
     137<tr class="color1">
     138<td>Static pool - Wifi CPE</td>
     139<td>A pool of IP addresses available for assignment to wireless CPE devices.</td>
     140</tr>
     141
     142<tr class="color2">
     143<td>Reserve for WAN blocks</td>
     144<td>Reserve a chunk of IP space for core routers/etc.</td>
     145</tr>
     146
     147<tr class="color1">
     148<td>Reserve for dynamic-route DSL netblocks</td>
     149<td>Reserve a chunk of IP space for netblocks configured on the customer end via
     150PPPoE/RADIUS.  Note that this is similar to the static DSL pool, but IP space is
     151to be allocated as /30 and larger netblocks, not single static IPs.</td>
     152</tr>
     153
     154<tr class="color2">
     155<td>Reserve for ATM</td>
     156<td>Reserve a chunk of IP space for allocation to customers on ATM.</td>
     157</tr>
     158
     159<tr class="color1">
     160<td>Reserve for fibre</td>
     161<td>Reserve a chunk of IP space for customers on a fibre connection.</td>
     162</tr>
     163
     164<tr class="color2">
     165<td>WAN block</td>
     166<td>Individual netblock assignment for a core router.  Always taken from a
    91167block which has previously been reserved for such assignments.</td>
    92 </tr><tr class="color2">
    93 <td>Dynamic-route DSL netblock</td><td>Customer assignment for a RADIUS-assigned PPPoE
    94 "netblock".  Always taken from a block which has previously been reserved for such
    95 assignments.</td>
    96 </tr><tr class="color1">
    97 <td>ATM block</td><td>Customer assignment for a customer on ATM.  Always taken from a
     168</tr>
     169
     170<tr class="color1">
     171<td>Dynamic-route DSL netblock</td>
     172<td>Customer assignment for a netblock configured on the customer end via
     173PPPoE/RADIUS.  Always taken from a block which has previously been reserved for
     174such assignments.</td>
     175</tr>
     176
     177<tr class="color2">
     178<td>ATM block</td>
     179<td>Customer assignment for a customer on ATM.  Always taken from a
    98180block which has previously been reserved for such assignments.</td>
    99 
    100 </tr><tr class="color2">
    101 <td>Routing</td><td>Blocks not actually assigned to a service on their own, but which
     181</tr>
     182
     183<tr class="color1">
     184<td>Fibre</td>
     185<td>Customer assignment for a customer on fibre. Always taken from a block
     186which has previously been reserved for such assignments.</td>
     187</tr>
     188
     189<tr class="color2">
     190<td>Routing</td>
     191<td>Blocks not actually assigned to a service on their own, but which
    102192have been routed to individual POPs- typically /24, /23, /22</td>
    103 
    104 </tr><tr class="color1">
    105 <td>Master block</td><td>Our allocations from ARIN</td>
     193</tr>
     194
     195<tr class="color1">
     196<td>Master block</td>
     197<td>Allocations provided by the regional registry (ARIN, RIPE, LACNIC, AfriNIC,
     198or APNIC)</td>
    106199</tr>
    107200
  • branches/stable/cgi-bin/CommonWeb.pm

    r242 r445  
    88
    99package CommonWeb;
    10 
    11 # 08/13/2004 kdeugau@vianet
    12 #       Split DB-related functions into new module;  they're not
    13 #       specific to CGI/web stuff.
    1410
    1511use strict;             
     
    108104}
    109105
    110 sub loginAgain
    111 {
    112         print qq(
    113         <center><p>Your session has expired. Please login again.</p>
    114         <p>
    115         <a href="http://hosttest.vianet.ca"> Click here to login again.</a>
    116         </p>
    117         </center>
    118         );
    119         printFooter();
    120         exit(0);
    121 }
    122 
    123106# needs a reference to the webvar hash.
    124107# takes out backticks and single quotes
  • branches/stable/cgi-bin/CustIDCK.pm

    r318 r445  
    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}$/;
  • branches/stable/cgi-bin/IPDB.pm

    r394 r445  
    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.0;
     22$VERSION        = 2; ##VERSION##
    2323@ISA            = qw(Exporter);
    2424@EXPORT_OK    = qw(
     
    5353our %IPDBacl;
    5454
     55our $org_name = 'Example Corp';
     56our $smtphost = 'smtp.example.com';
     57our $domain = 'example.com';
     58our $defcustid = '5554242';
     59# mostly for rwhois
     60##fixme:  leave these blank by default?
     61our $rwhoisDataPath = '/usr/local/rwhoisd/etc/rwhoisd'; # to match ./configure defaults from rwhoisd-1.5.9.6
     62our $org_street = '123 4th Street';
     63our $org_city = 'Anytown';
     64our $org_prov_state = 'ON';
     65our $org_pocode = 'H0H 0H0';
     66our $org_country = 'CA';
     67our $org_phone = '000-555-1234';
     68our $org_techhandle = 'ISP-ARIN-HANDLE';
     69our $org_email = 'noc@example.com';
     70our $hostmaster = 'dns@example.com';
     71
     72our $syslog_facility = 'local2';
     73
    5574# Let's initialize the globals.
    5675## IPDB::initIPDBGlobals()
     
    113132# Set up for a PostgreSQL db;  could be any transactional DBMS with the
    114133# right changes.
    115 # This definition should be sub connectDB($$$) to be technically correct,
    116 # but this breaks.  GRR.
    117134sub connectDB {
    118   my ($dbname,$user,$pass) = @_;
     135  my $dbname = shift;
     136  my $user = shift;
     137  my $pass = shift;
     138  my $dbhost = shift;
     139
    119140  my $dbh;
    120   my $DSN = "DBI:Pg:host=ipdb-db;dbname=$dbname";
    121 #  my $user = 'ipdb';
    122 #  my $pw   = 'ipdbpwd';
     141  my $DSN = "DBI:Pg:".($dbhost ? "host=$dbhost;" : '')."dbname=$dbname";
    123142
    124143# Note that we want to autocommit by default, and we will turn it off locally as necessary.
     
    557576    # have to insert all pool IPs into poolips table as "unallocated".
    558577    $sth = $dbh->prepare("insert into poolips (pool,ip,custid,city,type)".
    559         " values ('$pool', ?, '6750400', '$city', '$type')");
     578        " values ('$pool', ?, '$defcustid', '$city', '$type')");
    560579    my @poolip_list = $pool->hostenum;
    561580    if ($class eq 'all') { # (DSL-ish block - *all* IPs available
     
    614633    eval {
    615634      $msg = "Unable to deallocate $disp_alloctypes{$type} $cidr";
    616       $sth = $dbh->prepare("update poolips set custid='6750400',available='y',".
     635      $sth = $dbh->prepare("update poolips set custid='$defcustid',available='y',".
    617636        "city=(select city from allocations where cidr >>= '$cidr'".
    618637        " order by masklen(cidr) desc limit 1),".
     
    704723      } # end alloctype general case
    705724
    706 ##TEMP
    707 ## Temporary wrapper to "properly" deallocate sIP PPPoE/DSL "netblocks" in 209.91.185.0/24
    708 ## Note that we should really general-case this.
    709 my $staticpool = new NetAddr::IP "209.91.185.0/24";
    710 ##TEMP
    711 if ($cidr->within($staticpool)) {
    712 ##TEMP
    713   # We've already deleted the block, now we have to stuff its IPs into the pool.
    714   my $sth2 = $dbh->prepare("insert into poolips values ('209.91.185.0/24',?,'6750400','Sudbury','di','y','','','')");
    715   $sth2->execute($cidr->addr);
    716   foreach my $ip ($cidr->hostenum) {
    717     $sth2->execute("$ip");
    718   }
    719   $cidr--;
    720   $sth2->execute($cidr->addr);
    721 
    722 ##TEMP
    723 } else {
    724 ##TEMP
    725 
    726       # Now we look for larger-or-equal-sized free blocks in the same master (routed)
    727       # (super)block. If there aren't any, we can't combine blocks anyway.  If there
    728       # are, we check to see if we can combine blocks.
    729       # Execute the statement prepared in the if-else above.
    730 
    731       $sth->execute;
     725      ## Deallocate legacy blocks stashed in the middle of a static IP pool
     726      ## This may be expandable to an even more general case of contained netblock, or other pool types.
     727
     728      # Find out if the block we're deallocating is within a DSL pool
     729      my $sth2 = $dbh->prepare("SELECT cidr,city,type FROM allocations WHERE type LIKE '_p' AND cidr >>= ?");
     730      $sth2->execute("$cidr");
     731      my ($pool,$poolcity,$pooltype) = $sth2->fetchrow_array;
     732
     733      if ($pool || $sth2->rows) {
     734        # We've already deleted the block, now we have to stuff its IPs into the pool.
     735        $pooltype =~ s/p$/i/;   # change type to static IP
     736        $sth2 = $dbh->prepare("INSERT INTO poolips (pool,ip,city,type,custid) values ".
     737                "('$pool',?,'$poolcity','$pooltype','$defcustid')");
     738##fixme:  need to not insert net, gateway, and bcast on "real netblock" pools (DHCPish)
     739        # don't insert .0
     740        $sth2->execute($cidr->addr) unless $cidr->addr =~ m|\.0$|;
     741        foreach my $ip ($cidr->hostenum) {
     742          $sth2->execute("$ip");
     743        }
     744        $cidr--;
     745        # don't insert .255
     746        $sth2->execute($cidr->addr) unless $cidr->addr =~ m|\.255$|;
     747      } else {  # done returning IPs from a block to a static DSL pool
     748
     749        # Now we look for larger-or-equal-sized free blocks in the same master (routed)
     750        # (super)block. If there aren't any, we can't combine blocks anyway.  If there
     751        # are, we check to see if we can combine blocks.
     752        # Execute the statement prepared in the if-else above.
     753
     754        $sth->execute;
    732755
    733756# NetAddr::IP->compact() attempts to produce the smallest inclusive block
     
    739762#       $cidr=.32/27, $ip1=.96/27, $ip2=.0/27, and $ip3=.64/27.
    740763
    741       my (@together, @combinelist);
    742       my $i=0;
    743       while (my @data = $sth->fetchrow_array) {
    744         my $testIP = new NetAddr::IP $data[0];
    745         @together = $testIP->compact($cidr);
    746         my $num = @together;
    747         if ($num == 1) {
    748           $cidr = $together[0];
    749           $combinelist[$i++] = $testIP;
     764        my (@together, @combinelist);
     765        my $i=0;
     766        while (my @data = $sth->fetchrow_array) {
     767          my $testIP = new NetAddr::IP $data[0];
     768          @together = $testIP->compact($cidr);
     769          my $num = @together;
     770          if ($num == 1) {
     771            $cidr = $together[0];
     772            $combinelist[$i++] = $testIP;
     773          }
    750774        }
    751       }
    752 
    753       # Clear old freeblocks entries - if any.  They should all be within
    754       # the $cidr determined above.
    755       $sth = $dbh->prepare("delete from freeblocks where cidr <<='$cidr'");
    756       $sth->execute;
    757 
    758       # insert "new" freeblocks entry
    759       if ($type eq 'rm') {
    760         $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)".
     775
     776        # Clear old freeblocks entries - if any.  They should all be within
     777        # the $cidr determined above.
     778        $sth = $dbh->prepare("delete from freeblocks where cidr <<='$cidr'");
     779        $sth->execute;
     780
     781        # insert "new" freeblocks entry
     782        if ($type eq 'rm') {
     783          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)".
    761784                " values ('$cidr',".$cidr->masklen.",'<NULL>')");
    762       } else {
    763         # Magic hackery to insert "correct" data for deallocation of
    764         # non-contained blocks allocated from within a container.
    765         $type = 'pr' if $con_type && $con_type eq 'pc';
    766 
    767         $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
     785        } else {
     786          # Magic hackery to insert "correct" data for deallocation of
     787          # non-contained blocks allocated from within a container.
     788          $type = 'pr' if $con_type && $con_type eq 'pc';
     789
     790          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
    768791                " values ('$cidr',".$cidr->masklen.
    769792                ",(select city from routed where cidr >>= '$cidr'),'".
    770793                (($type =~ /^(.)r$/) ? "$1" : 'y')."')");
    771       }
    772       $sth->execute;
    773 
    774 ##TEMP
    775 }
    776 ##TEMP
     794        }
     795        $sth->execute;
     796
     797      } # done returning IPs to the appropriate place
    777798
    778799      # If we got here, we've succeeded.  Whew!
     
    780801    }; # end eval
    781802    if ($@) {
     803      $msg = $@;
    782804      eval { $dbh->rollback; };
    783805      return ('FAIL', $msg);
     
    806828## IPDB::mailNotify()
    807829# Sends notification mail to recipients regarding an IPDB operation
    808 sub mailNotify ($$$) {
    809   my ($recip,$subj,$message) = @_;
    810   my $mailer = Net::SMTP->new("smtp.example.com", Hello => "ipdb.example.com");
    811 
    812   $mailer->mail('ipdb@example.com');
    813   $mailer->to($recip);
    814   $mailer->data("From: \"IP Database\" <ipdb\@example.com>\n",
     830sub mailNotify {
     831  my $dbh = shift;
     832  my ($action,$subj,$message) = @_;
     833
     834##fixme: need to redesign the breakdown/processing for $action for proper handling of all cases
     835
     836# split action into parts for fiddlement.  nb: there are almost certainly better ways to do this.
     837  my @actionbits = split //, $action;
     838
     839  # want to notify anyone who has specifically requested notify on *this* type ($action as passed),
     840  # on "all static IP types" or "all pool types" (and other last-char-in-type groupings), on eg "all DSL types",
     841  # and "all events with this action"
     842  my @actionsets = ($action);
     843##fixme: ick, eww.  really gotta find a better way to handle this...
     844  push @actionsets, ($actionbits[0].'.'.$actionbits[2],
     845        $actionbits[0].$actionbits[1].'.', $actionbits[0].'a') if $action =~ /^.{3}$/;
     846
     847  my $mailer = Net::SMTP->new($smtphost, Hello => "ipdb.$domain");
     848
     849  # get recip list from db
     850  my $sth = $dbh->prepare("SELECT reciplist FROM notify WHERE action=?");
     851
     852  my %reciplist;
     853  foreach (@actionsets) {
     854    $sth->execute($_);
     855##fixme - need to handle db errors
     856    my ($recipsub) = $sth->fetchrow_array;
     857    next if !$recipsub;
     858    foreach (split(/,/, $recipsub)) {
     859      $reciplist{$_}++;
     860    }
     861  }
     862
     863  return if !%reciplist;
     864
     865  foreach my $recip (keys %reciplist) {
     866    $mailer->mail("ipdb\@$domain");
     867    $mailer->to($recip);
     868    $mailer->data("From: \"$org_name IP Database\" <ipdb\@$domain>\n",
    815869        "To: $recip\n",
    816870        "Date: ".strftime("%a, %d %b %Y %H:%M:%S %z",localtime)."\n",
    817871        "Subject: {IPDB} $subj\n",
    818872        "X-Mailer: IPDB Notify v".sprintf("%.1d",$IPDB::VERSION)."\n",
    819         "Organization: Example Corp\n",
     873        "Organization: $org_name\n",
    820874        "\n$message\n");
     875  }
    821876  $mailer->quit;
    822877}
  • branches/stable/cgi-bin/MyIPDB.pm

    r319 r445  
    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);
     16
     17
     18# DSN, user, and password for database.  These **MUST** be set.
     19my $dbname = 'ipdb';
     20my $dbuser = 'ipdb';
     21my $dbpass = 'ipdbpwd';
     22# DB host is optional.
     23my $dbhost = 'ipdb-db';
     24
     25# Set some globals declared in IPDB.pm.  Most of these only affect mailNotify().
     26# Note that while you *can* leave these at defaults, it's probably a Really Bad Idea.
     27#$IPDB::org_name = "Bob's Big Bonaza";
     28#$IPDB::smtphost = '127.0.0.1';
     29#$IPDB::domain = 'bob.com';
     30#$IPDB::defcustid = '5554242';
     31# Globals for db2rwhois.pl
     32#$IPDB::rwhoisDataPath = '/usr/local/rwhoisd/etc/rwhoisd';
     33#$IPDB::org_street = '123 4th Street';
     34#$IPDB::org_city = 'Anytown';
     35#$IPDB::org_prov_state = 'ON';
     36#$IPDB::org_pocode = 'H0H 0H0';
     37#$IPDB::org_country = 'CA';
     38#$IPDB::org_phone = '000-555-1234';
     39# note: following may also just be a bare email address
     40#$IPDB::org_techhandle = 'ISP-ARIN-HANDLE';
     41#$IPDB::org_email = 'noc@example.com';
     42#$IPDB::hostmaster = 'dns@example.com';
     43
     44# Logging destination.  Defaults to local2.  See your local syslog docs for valid facilities.
     45# Note that the value here should have the LOG_ prefix removed, and convert to lower-case.
     46# local0 through local7 and user make the most sense.
     47#$IPDB::syslog_facility = 'daemon';
     48
    1349
    1450## connectDB_My()
     
    1652# Takes no arguments, returns whatever IPDB::connectDB returns.
    1753sub connectDB_My {
    18   return connectDB("ipdb", "ipdb", "ipdbpwd");
     54  return connectDB($dbname, $dbuser, $dbpass, $dbhost);
    1955} # end connectDB_My()
    2056
  • branches/stable/cgi-bin/access-pwd-update.pl

    r386 r445  
    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
  • branches/stable/cgi-bin/admin.cgi

    r414 r445  
    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);
     
    2423use Sys::Syslog;
    2524
    26 openlog "IPDB-admin","pid","local2";
     25# don't remove!  required for GNU/FHS-ish install from tarball
     26##uselib##
     27
     28use MyIPDB;
     29
     30openlog "IPDB-admin","pid","$IPDB::syslog_facility";
    2731
    2832# Collect the username from HTTP auth.  If undefined, we're in a test environment.
     
    5357        qq(\t<link rel="stylesheet" type="text/css" href="/ip/local.css">\n).
    5458        "</head>\n<body>\n".
    55         qq(Access to this tool is restricted.  Contact <a href="mailto:kdeugau\@vianet.ca">Kris</a> \n).
     59        qq(Access to this tool is restricted.  Contact the <a href="mailto:ipdbadmin\@example.com">IPDB administrator</a> \n).
    5660        "for more information.\n</body>\n</html>\n";
    5761  exit;
     
    8993  print qq(WARNING:  There are FAR fewer controls on what you can do here.  Use the
    9094main interface if at all possible.
    91 <hr>
    92 <a href="admin.cgi?action=newalloc">Add allocation</a>
    9395<hr>
    9496<form action="admin.cgi" method="POST">
     
    107109Bump "last updated" timestamp on this master: <select name=whichmaster>$masterlist</select>
    108110<input type=submit value="Update timestamp"> (Sets timestamp to "now")</form>
    109 <a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a>
     111<a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a> - data used for
     112blocks with the SWIP box checkmarked.  Links to edit/add data are on this page.
    110113
    111114<hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates
     115
    112116<hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users;  change
    113 internal access controls - note that this does NOT include IP-based limits)
     117internal access controls - note that this does NOT include IP-based limits)<br>
     118<a href="admin.cgi?action=emailnotice">Manage email notice options</a> (pick which events
     119and allocation types cause notifications;  configure recipient lists for notices)
     120
    114121<hr>Consistency check tools<br>
    115122<a href="consistency-check.pl">General</a>:  Check general netblock consistency.<br>
    116123<a href="freespace.pl">Free space</a>:  List total and aggregate free space.  Does not
    117124include private networks (192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8)
    118 <hr>(r)WHOIS<br>
    119 <a href="list-cust.php">List customer data for WHOIS</a> - data used for blocks with the SWIP box checkmarked.
    120 Links to edit/add data are on this page.
    121125);
    122126} else {
     
    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;
     
    250254        syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
    251255                "'$webvar{alloctype}'";
    252         # Notify tech@example.com
    253         mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation",
     256        mailNotify($ip_dbh, "a$webvar{alloctype}",
    254257          "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer".
    255258          " $webvar{custid}\n".
     
    306309<form action=admin.cgi method=POST>
    307310<table border=1><tr>
    308 <input type=hidden name=action value=newcust>
     311<input type=hidden name=action value=edcust>
     312<input type=hidden name=newcust value=1>
    309313<td>CustID:</td><td><input name=custid></td>
    310 <td>Name:</td><td><input name=name></td></tr>
    311 <tr><td>Street:</td><td><input name=street></td></tr>
    312 <!-- <td>Street2:</td><td><input name=street2></td> -->
    313 <tr><td>City:</td><td><input name=city></td>
    314 <td>Province: (2-letter code)</td><td><input name=province value=ON length=2 size=2></td></tr>
    315 <tr><td>Country: (2-letter code)</td><td><input name=country value=CA length=2 size=2></td>
    316 <td>Postal/ZIP Code:</td><td><input name=pocode></td></tr>
    317 <tr><td>Phone:</td><td><input name=phone></td>
    318 <!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
    319 <td>Description:</td><td><input name=description></td> -->
    320 <td>ARIN Handles:</td><td>
    321  Tech: <input name=tech_handle value="VH25-ORG-ARIN"><br>
    322  Abuse: <input name=abuse_handle><br>
    323  Admin: <input name=admin_handle><br>
    324 Note:  Only tech is required at the moment.
    325 </td></tr>
    326 <tr><td colspan=4 align=center><input type=submit value="Add"></td></tr>
     314<td align=center><input type=submit value="Go to edit page for this custid"></td></tr>
    327315</form></table>
    328316);
     
    336324  }
    337325  print "</table>\n";
    338 } elsif ($webvar{action} eq 'newcust') {
    339   if ($webvar{custid} eq '') {
    340     print 'No CustID entered.  PTHBT!  (Hit "Back" and fix the problem.)';
    341   } else {
    342     $sth = $ip_dbh->prepare("insert into customers ".
    343         "(custid, name, street, city, province, country, pocode, ".
    344         "phone, tech_handle, abuse_handle, admin_handle) values ".
    345         "('$webvar{custid}', '$webvar{name}', '$webvar{street}', ".
    346         "'$webvar{city}', '$webvar{province}', '$webvar{country}', ".
    347         "'$webvar{pocode}', '$webvar{phone}', '$webvar{techhandle}', ".
    348         "'$webvar{abusehandle}', '$webvar{adminhandle}')");
    349     $sth->execute;
    350     if ($sth->err) {
    351       print "INSERT failed:  ".$sth->errstr."\n";
    352     } else {
    353       print "Success!  Added customer contact data:\n".
    354         qq(<table border=1><tr>
    355 <td>CustID:</td>$webvar{custid}</td><td>Name:</td>$webvar{name}</td></tr>
    356 <tr><td>Street:</td><td>$webvar{street}</td></tr>
    357 <tr><td>City:</td><td>$webvar{city}</td><td>Province:</td><td>$webvar{province}</td></tr>
    358 <tr><td>Country:</td><td>$webvar{country}</td>
    359 <td>Postal/ZIP Code:</td><td>$webvar{pocode}</td></tr>
    360 <tr><td>Phone:</td><td>$webvar{phone}</td>
    361 <!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
    362 <tr><td>Description:</td><td><input name=description></td> -->
    363 <td>ARIN Handles:</td><td>
    364  Tech: $webvar{tech_handle}<br>
    365  Abuse: $webvar{abuse_handle}<br>
    366  Admin: $webvar{admin_handle}<br>
    367 </td></tr></table>
    368 );
    369     } # $sth err check
    370   } # bad custid
    371326} elsif ($webvar{action} eq 'edcust') {
     327  if ($webvar{newcust}) {
     328    print "got here?\n";
     329    $sth = $ip_dbh->prepare("INSERT INTO customers (custid) VALUES (?)");
     330    $sth->execute($webvar{custid});
     331  }
    372332  $sth = $ip_dbh->prepare("select custid,name,street,city,province,".
    373         "country,pocode,phone,tech_handle,abuse_handle,admin_handle ".
     333        "country,pocode,phone,tech_handle,abuse_handle,admin_handle,special ".
    374334        "from customers where custid='$webvar{custid}'");
    375335  $sth->execute;
    376   my ($custid, $name, $street, $city, $prov, $country, $pocode, $phone, $tech, $abuse, $admin) =
     336  my ($custid, $name, $street, $city, $prov, $country, $pocode, $phone, $tech, $abuse, $admin, $special) =
    377337        $sth->fetchrow_array;
    378338  print qq(<form action=admin.cgi method=POST>
     
    381341<td>CustID:</td><td>$custid<input type=hidden name=custid value=$custid></td>
    382342<td>Name:</td><td><input name=name value="$name"></td></tr>
    383 <tr><td>Street:</td><td><input name=street value="$street"></td></tr>
     343<tr><td>Street:</td><td><input name=street value="$street"></td>
    384344<!-- <td>Street2:</td><td><input name=street2></td> -->
    385 <tr><td>City:</td><td><input name=city value="$city"></td>
    386 <td>Province: (2-letter code)</td><td><input name=province value="$prov" length=2 size=2></td></tr>
    387 <tr><td>Country: (2-letter code)</td><td><input name=country value="$country" length=2 size=2></td>
    388 <td>Postal/ZIP Code:</td><td><input name=pocode value="$pocode"></td></tr>
    389 <tr><td>Phone:</td><td><input name=phone value="$pocode"></td>
     345<td>City:</td><td><input name=city value="$city"></td></tr>
     346<tr><td>Province/State: (2-letter code)</td><td><input name=province value="$prov" length=2 size=2></td>
     347<td>Country: (2-letter code)</td><td><input name=country value="$country" length=2 size=2></td></tr>
     348<tr><td>Postal/ZIP Code:</td><td><input name=pocode value="$pocode"></td>
     349<td>Phone:</td><td><input name=phone value="$pocode"></td></tr>
    390350<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
    391351<td>Description:</td><td><input name=description></td> -->
    392 <td>ARIN Handles:</td><td>
     352<tr><td>Contacts/ARIN Handles:</td><td>
    393353 Tech: <input name=tech_handle value="$tech"><br>
    394354 Abuse: <input name=abuse_handle value="$abuse"><br>
    395355 Admin: <input name=admin_handle value="$admin"><br>
    396356Note:  Only tech is required at the moment.
    397 </td></tr>
     357</td>
     358<td>"Special":</td><td><textarea name=special rows=4 cols=50>$special</textarea></td>
     359</tr>
    398360<tr><td colspan=4 align=center><input type=submit value="Update"></td></tr>
    399361</form></table>
     362<div style="margin-left:5px">
     363<h3>Explanation for "Special" field:</h3>
     364This is a temporary place to define the WHOIS "net name" for a block.
     365It may be removed later, more likely migrated elsewhere.
     366<p>It's formatted like this, one line for each custom net name:
     367<pre>NetName[CIDR block]: NET-NAME</pre>
     368Example:
     369<pre>NetName192.168.236.0/24: MEGAWIDGET-1</pre>
     370Note:
     371<ul style="margin-top: 0px;">
     372<li>Spacing is important - there should only be ONE space, in between the colon and the net name.
     373<li>The CIDR block name nust include all four octets - no short forms are accepted.
     374<li>Net names must be all uppercase, and consist only of A-Z, 0-9, and - (same as for SWIPed net names).
     375</ul>
     376</div>
    400377);
    401378
    402379} elsif ($webvar{action} eq 'updcust') {
    403   print "Updated $webvar{custid}\n";
     380  $sth = $ip_dbh->prepare("UPDATE customers SET".
     381        " name=?, street=?, city=?, province=?, country=?, pocode=?,".
     382        " phone=?, tech_handle=?, abuse_handle=?, admin_handle=?, special=?".
     383        " WHERE custid=?");
     384  $sth->execute($webvar{name}, $webvar{street}, $webvar{city}, $webvar{province},
     385        $webvar{country}, $webvar{pocode}, $webvar{phone}, $webvar{tech_handle},
     386        $webvar{abuse_handle}, $webvar{admin_handle}, $webvar{special}, $webvar{custid});
     387  print "Updated $webvar{custid}<br>\n".
     388        qq(<table border=1>
     389<tr><td>CustID:</td><td>$webvar{custid}</td></tr>
     390<tr><td>Name:</td><td>$webvar{name}</td></tr>
     391<tr><td>Street:</td><td>$webvar{street}</td></tr>
     392<tr><td>City:</td><td>$webvar{city}</td></tr>
     393<tr><td>Province/State:</td><td>$webvar{province}</td></tr>
     394<tr><td>Country:</td><td>$webvar{country}</td></tr>
     395<tr><td>Postal/ZIP Code:</td><td>$webvar{pocode}</td></tr>
     396<tr><td>Phone:</td><td>$webvar{phone}</td></tr>
     397<!-- <td>Default rDNS:</td><td>$webvar{def_rdns}</td></tr> -->
     398<tr><td>Contacts/ARIN Handles:</td><td>
     399 Tech: $webvar{tech_handle}<br>
     400 Abuse: $webvar{abuse_handle}<br>
     401 Admin: $webvar{admin_handle}<br>
     402</td></tr>
     403<tr><td>"Special":</td><td><pre>$webvar{special}</pre></td></tr>
     404</table>
     405<a href="admin.cgi?action=listcust">Back</a> to rWHOIS customer list<br>\n);
     406
    404407} elsif ($webvar{action} eq 'showpools') {
    405408  print "IP Pools currently allocated:\n".
     
    516519  print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n);
    517520
     521} elsif ($webvar{action} eq 'emailnotice') {
     522  print "<h4>Email notice management:</h4>\nClick the email addresses to edit that list.";
     523  $sth = $ip_dbh->prepare("SELECT action,reciplist FROM notify");
     524  $sth->execute;
     525
     526  print "<table border=1>\n";
     527  while (my ($notice_code,$reciplist) = $sth->fetchrow_array() ) {
     528##fixme: hairy mess, only a few things call mailNotify() anyway, so many possible notices won't work.
     529    my $action_out = dispNoticeCode($notice_code);
     530    print "<tr><td>$action_out</td>".
     531        qq(<td><a href="admin.cgi?action=ednotice&code=$notice_code">$reciplist</a></td>).
     532        qq(<td><a href="admin.cgi?action=delnotice&code=$notice_code">Delete</a></tr>\n);
     533  }
     534  print qq(<tr><td colspan=2>Known "special" codes:<br>
     535<ul style="margin-top: 0px; margin-bottom: 0px;">
     536        <li>swi: Notify if block being updated has SWIP flag set</li>
     537</ul></td></tr>
     538</table>
     539);
     540
     541# add new entries from this tangle:
     542  print "<h4>Add new notification:</h4>\n".
     543        "Note:  Failure notices on most conditions are not yet supported.\n";
     544
     545  print qq(<table border=1><form action=admin.cgi method="POST">
     546<input type=hidden name=action value=addnotice>
     547<tr>
     548<td>Recipients</td><td colspan=3><textarea name=reciplist cols=50 rows=5></textarea></td></tr>
     549<tr><td>Action</td><td>
     550        <table><tr>
     551                <td><input type=radio name=msgaction value=a>Add &nbsp;
     552                <input type=radio name=msgaction value=u>Update &nbsp;
     553                <input type=radio name=msgaction value=d>Delete &nbsp;
     554                <input type=radio name=msgaction value=n>New listitem</td>
     555        </tr><tr>
     556                <td>
     557                <input type=radio name=msgaction value=s:>Special: <input name=special>(requires code changes)
     558        </td></tr></table>
     559</td>
     560<td>Failure?</td><td><input type=checkbox name=onfail></td></tr>
     561<tr><td>Event/Allocation type:</td><td colspan=3>
     562        <table>
     563        <tr>
     564                <td><input type=radio name=alloctype value=a>All allocations</td>
     565                <td><input type=radio name=alloctype value=.i>All static IPs</td>
     566                <td><input type=radio name=alloctype value=ci>New city</td>
     567                <td><input type=radio name=alloctype value=no>New node</td>
     568        </tr>
     569        <tr>
     570);
     571
     572  $sth = $ip_dbh->prepare("SELECT type,dispname FROM alloctypes WHERE listorder < 500 ".
     573        "ORDER BY listorder");
     574  $sth->execute;
     575  my $i=0;
     576  while (my ($type,$disp) = $sth->fetchrow_array) {
     577    print "             <td><input type=radio name=alloctype value=$type>$disp</td>";
     578    $i++;
     579    print "     </tr>\n\t<tr>"
     580        if ($i % 4 == 0);
     581  }
     582
     583  print qq(     </tr>
     584        </table>
     585</tr>
     586<tr><td colspan=4 align=center><input type=submit value="Add notice"></td></tr>
     587</table>
     588</form>
     589);
     590  ## done spitting out add-new-spam-me-now table
     591
     592} elsif ($webvar{action} eq 'addnotice') {
     593  $webvar{alloctype} = $webvar{special} if $webvar{msgaction} eq 's:';
     594  if ($webvar{msgaction} && $webvar{alloctype} && $webvar{reciplist}) {
     595    $webvar{reciplist} =~ s/[\r\n]+/,/g;
     596    $webvar{msgaction} = "f:$webvar{msgaction}" if $webvar{onfail};
     597    print "Adding notice to $webvar{reciplist} for ".dispNoticeCode($webvar{msgaction}.$webvar{alloctype}).":\n";
     598    $sth = $ip_dbh->prepare("INSERT INTO notify (action, reciplist) VALUES (?,?)");
     599##fixme:  automagically merge reciplists iff action already exists
     600    $sth->execute($webvar{msgaction}.$webvar{alloctype}, $webvar{reciplist});
     601    if ($sth->err) {
     602      print "Failed:  DB error: ".$sth->errstr."\n";
     603    } else {
     604      print "OK!<br>\n"
     605    }
     606  } else {
     607    print "Need to specify at least one recipient, an action, and an allocation type. ".
     608        qq{("Special" content is considered an allocation type).  Hit the Back button and try again.<br>\n};
     609  }
     610  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
     611
     612} elsif ($webvar{action} eq 'delnotice') {
     613  print "Deleting notices on ".dispNoticeCode($webvar{code}.$webvar{alloctype}).":\n";
     614  $sth = $ip_dbh->prepare("DELETE FROM notify WHERE action=?");
     615  $sth->execute($webvar{code});
     616  if ($sth->err) {
     617    print "Failed:  DB error: ".$sth->errstr."\n";
     618  } else {
     619    print "OK!<br>\n"
     620  }
     621  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
     622
     623} elsif ($webvar{action} eq 'ednotice') {
     624  print "<h4>Editing recipient list for '".dispNoticeCode($webvar{code})."':</h4>\n";
     625  $sth = $ip_dbh->prepare("SELECT reciplist FROM notify WHERE action=?");
     626  $sth->execute($webvar{code});
     627  my ($reciplist) = $sth->fetchrow_array;
     628  $reciplist =~ s/,/\n/g;
     629  print qq(<form action=admin.cgi method=POST><input type=hidden name=code value="$webvar{code}">\n).
     630        qq(<input type=hidden name=action value="updnotice"><table border=1><tr><td>).
     631        qq(<textarea cols="40" rows="5" name=reciplist>$reciplist</textarea></td><td><input type=submit value="Update">\n).
     632        "</td></tr></table></form>\n";
     633} elsif ($webvar{action} eq 'updnotice') {
     634  print "<h4>Updating recipient list for '".dispNoticeCode($webvar{code})."':</h4>\n";
     635  $sth = $ip_dbh->prepare("UPDATE notify SET reciplist=? WHERE action=?");
     636  $webvar{reciplist} =~ s/[\r\n]+/,/g;
     637  $sth->execute($webvar{reciplist}, $webvar{code});
     638  if ($sth->err) {
     639    print "Failed:  DB error: ".$sth->errstr."\n";
     640  } else {
     641    print "OK!<br>\n"
     642  }
     643  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
    518644} elsif ($webvar{action} ne '<NULL>') {
    519645  print "webvar{action} check failed: Don't know how to $webvar{action}";
     
    668794  print "</form></table>\n";
    669795}
     796
     797
     798# interpret the notify codes
     799sub dispNoticeCode {
     800  my $code = shift;
     801  my $action_out = '';
     802
     803  if ($code =~ /^s:/) {
     804    $code =~ s/^s:/Special: /;
     805    return $code;
     806  }
     807  if ($code =~ /^f:(.+)$/) {
     808    $code =~ s/^f://;
     809    $action_out = "Failure on ";
     810  }
     811  if (my $target = $code =~ /^n(.+)/) {
     812    $action_out .= "New ";
     813    if ($1 eq 'ci') { $action_out .= "city"; }
     814    elsif ($1 eq 'no') { $action_out .= "node"; }
     815    else { $action_out .= '&lt;unknown&gt;'; }
     816  } else {
     817    my ($action,$target) = ($code =~ /^(.)(.+)$/);
     818    if ($action eq 'a')      { $action_out .= 'Add '; }
     819    elsif ($action eq 'u')   { $action_out .= 'Update '; }
     820    elsif ($action eq 'd')   { $action_out .= 'Delete '; }
     821##fixme:  what if we get something funky?
     822# What about the eleventy-billion odd combinations possible?
     823# this should give an idea of the structure tho
     824    if ($target eq 'a') { $action_out .= "all"; }
     825    elsif ($target eq '.i') {
     826      $action_out .= "all static IPs";
     827    }
     828    else { $action_out .= $disp_alloctypes{$target}; }
     829  }
     830  return $action_out;
     831}
  • branches/stable/cgi-bin/allocate.pl

    r291 r445  
    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;
    2217
    23 openlog "IPDBshell","pid","local2";
     18# don't remove!  required for GNU/FHS-ish install from tarball
     19##uselib##
     20
     21use MyIPDB;
     22
     23openlog "IPDBshell","pid","$IPDB::syslog_facility";
    2424
    2525# Collect the username from the environment.  If undefined, something
  • branches/stable/cgi-bin/checkcusts.pl

    r319 r445  
    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");
  • branches/stable/cgi-bin/combineblocks.pl

    r306 r445  
    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";
  • branches/stable/cgi-bin/consistency-check.pl

    r444 r445  
    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) {
  • branches/stable/cgi-bin/extras/db2rwhois.pl

    r375 r445  
    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";
    22 
    23 my $rwhoisDataPath = "/etc/rwhoisd";
     25
     26#$ENV{"PATH"} = "/bin;/usr/bin";
    2427
    2528my @autharea;
    2629my $authrw;
    2730# Use the template file to allow us to keep persistent nodes aside from netblock data
    28 open AUTHTEMPLATE, "<$rwhoisDataPath/rwhoisd.auth_template";
     31open AUTHTEMPLATE, "<$IPDB::rwhoisDataPath/rwhoisd.auth_template";
    2932my $template_persist;
    3033while (<AUTHTEMPLATE>) {
     
    4346
    4447# Get the list of live directories for potential deletion
    45 opendir RWHOISROOT, $rwhoisDataPath;
     48opendir RWHOISROOT, $IPDB::rwhoisDataPath;
    4649my %rwhoisdirs;
    4750foreach (readdir RWHOISROOT) {
     
    9194  print "$masterblocks[$i] $ctime $mtime\n";
    9295
    93   my $date;
    94   chomp ($date = `/bin/date +"%Y-%m-%d"`);
     96  my $date = strftime("%Y-%m-%d", localtime);
    9597
    9698  my $rwnet = "net-".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen;
     
    100102
    101103# Hokay.  Gonna do checks *here* to see if we need to create new master trees
    102   my $netdatadir = "$rwhoisDataPath/$rwnet";
     104  my $netdatadir = "$IPDB::rwhoisDataPath/$rwnet";
    103105  if (! -e $netdatadir) {
    104106    print " New master $masterblocks[$i]!\n";
     
    111113    mkdir "$netdatadir/data/referral";
    112114
    113     my $serial;
    114     chomp ($serial = `/bin/date '+%Y%m%d'000000000`);
    115 
     115    my $serial = strftime("%Y%m%d%H%M%S000", localtime);
     116
     117##fixme: SOA should be different every time data changes, therefore need to rewrite this ~~ every export :(
    116118    print "  Creating SOA...\n";
    117119    open SOAFILE, ">$netdatadir/soa";
     
    121123Retry-Interval: 1800
    122124Time-To-Live: 86400
    123 Primary-Server: rwhois.example.com:4321
    124 Hostmaster: dns\@example.com
     125Primary-Server: rwhois.$IPDB::domain:4321
     126Hostmaster: $IPDB::hostmaster
    125127);
    126128    close SOAFILE;
     
    147149
    148150    print "  Copying template files...\n";
    149     qx { /bin/cp $rwhoisDataPath/skel/attribute_defs/* $netdatadir/attribute_defs/ };
    150 
     151##fixme: find a way to do this without a shell (or functional equivalent)
     152    qx { /bin/cp $IPDB::rwhoisDataPath/skel/attribute_defs/* $netdatadir/attribute_defs/ };
     153
     154##fixme: not sure if this is even necessary, since it's not referenced anywhere I can recall...
    151155    print "  Creating org data...\n";
    152     open ORGDATAFILE, ">$netdatadir/data/org/friendlyisp.txt";
     156    open ORGDATAFILE, ">$netdatadir/data/org/ourorg.txt";
    153157    print ORGDATAFILE qq(ID: NETBLK-ISP.$masterblocks[$i]
    154158Auth-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
     159Org-Name: $IPDB::org_name
     160Street-Address: $IPDB::org_street
     161City: $IPDB::org_city
     162State: $IPDB::org_prov_state
     163Postal-Code: $IPDB::org_pocode
     164Country-Code: $IPDB::org_country
     165Phone: $IPDB::org_phone
    162166Created: 20040308
    163167Updated: 20040308
     
    182186  my $masterfilename = "$rwnet/data/network/".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen.".txt";
    183187
    184   open MASTERFILE,">$rwhoisDataPath/$masterfilename";
     188  open MASTERFILE,">$IPDB::rwhoisDataPath/$masterfilename";
    185189
    186190  print MASTERFILE "ID: NETBLK-ISP.$masterblocks[$i]\n".
     
    189193        "IP-Network: $masterblocks[$i]\n".
    190194        "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".
     195        "Org-Name: $IPDB::org_name\n".
     196        "Street-Address: $IPDB::org_street\n".
     197        "City: $IPDB::org_city\n".
     198        "StateProv: $IPDB::org_prov_state\n".
     199        "Postal-Code: $IPDB::org_pocode\n".
     200        "Country-Code: $IPDB::org_country\n".
     201        "Tech-Contact: $IPDB::org_techhandle\n".
    198202        "Created: $ctime\n".
    199203        "Updated: $mtime\n".
    200         "Updated-By: noc\@example.com\n";
     204        "Updated-By: $IPDB::org_email\n";
    201205
    202206  # And now the subblocks
     
    226230
    227231# Fill in a generic entry for nameless allocations
    228 if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }
     232if ($desc =~ /^\s*$/) { $desc = $IPDB::org_name; }
    229233
    230234    # Fix up datestamps.  We don't *really* need sub-microsecond resolution on our exports...
     
    257261        "IP-Network: $net\n".
    258262        "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".
     263        "Org-Name: $IPDB::org_name\n".
     264        "Street-Address: $IPDB::org_street\n".
     265        "City: $IPDB::org_city\n".
     266        "StateProv: $IPDB::org_prov_state\n".
     267        "Postal-Code: $IPDB::org_pocode\n".
     268        "Country-Code: $IPDB::org_country\n".
     269        "Tech-Contact: $IPDB::org_techhandle\n".
    266270        "Created: $ctime\n".
    267271        "Updated: $mtime\n".
    268         "Updated-By: noc\@example.com\n";
     272        "Updated-By: $IPDB::org_email\n";
    269273    } else {
    270274      $custsth->execute($custid);
     
    281285        "IP-Network: $net\n".
    282286        "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".
     287        "Org-Name: ".($name ? $name : $IPDB::org_name)."\n".
     288        "Street-Address: ".($street ? $street : $IPDB::org_street)."\n".
     289        "City: ".($city ? $city : $IPDB::org_city)."\n".
     290        "StateProv: ".($prov ? $prov : $IPDB::org_prov_state)."\n".
     291        "Postal-Code: ".($pocode ? $pocode : $IPDB::org_pocode)."\n".
     292        "Country-Code: ".($country ? $country : $IPDB::org_country)."\n".
     293        "Tech-Contact: ".($tech ? $tech : $IPDB::org_techhandle)."\n".
    290294        "Created: $ctime\n".
    291295        "Updated: $mtime\n".
    292         "Updated-By: noc\@example.com\n";
     296        "Updated-By: $IPDB::org_email\n";
    293297    } # swip
    294298
     
    304308foreach my $netdir (keys %rwhoisdirs) {
    305309  print "deleting obsolete directory $netdir...\n";
    306   rmtree ( "$rwhoisDataPath/$netdir", { verbose => 1, error => \my $errlist } );
     310  rmtree ( "$IPDB::rwhoisDataPath/$netdir", { verbose => 1, error => \my $errlist } );
    307311  for my $diag (@$errlist) {
    308312    my ($file, $message) = each %$diag;
     
    317321if ($authrw) {
    318322  print "Regenerating auth_area\n";
    319   open RWHOISDAUTH, ">$rwhoisDataPath/rwhoisd.auth_area";
     323  open RWHOISDAUTH, ">$IPDB::rwhoisDataPath/rwhoisd.auth_area";
    320324  print RWHOISDAUTH "# WARNING: This file is autogenerated!  Any static nodes should\n".
    321325                "# be entered in /etc/rwhoisd/rwhoisd.auth_template\n";
     
    333337
    334338  # restart/reload rwhoisd
    335   if (-e "$rwhoisDataPath/rwhoisd.pid") {       # no pidfile, no restart.
     339  if (-e "$IPDB::rwhoisDataPath/rwhoisd.pid") { # no pidfile, no restart.
    336340    print "Restarting rwhoisd\n";
    337     open PIDFILE, "<$rwhoisDataPath/rwhoisd.pid";
     341    open PIDFILE, "<$IPDB::rwhoisDataPath/rwhoisd.pid";
    338342    my ($rwpid) = (<PIDFILE> =~ /^(\d+)/);
    339343    close PIDFILE;
  • branches/stable/cgi-bin/freespace.pl

    r319 r445  
    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;
  • branches/stable/cgi-bin/ipdb.psql

    r410 r445  
    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
     
    226226    node_ip inet
    227227);
     228
     229-- Email notifications on <action>
     230CREATE TABLE notify (
     231    action varchar(5) NOT NULL PRIMARY KEY,
     232    reciplist varchar(500)
     233);
  • branches/stable/cgi-bin/main.cgi

    r408 r445  
    11#!/usr/bin/perl
    22# ipdb/cgi-bin/main.cgi
    3 # Started munging from noc.vianet's old IPDB 04/22/2004
    43###
    54# SVN revision info
     
    87# Last update by $Author$
    98###
     9# Copyright (C) 2004-2010 - Kris Deugau
    1010
    1111use strict;             
     
    1414use DBI;
    1515use CommonWeb qw(:ALL);
    16 use MyIPDB;
    1716use CustIDCK;
    1817use POSIX qw(ceil);
     
    2120use Sys::Syslog;
    2221
    23 openlog "IPDB","pid","local2";
     22# don't remove!  required for GNU/FHS-ish install from tarball
     23##uselib##
     24
     25use MyIPDB;
     26
     27openlog "IPDB","pid","$IPDB::syslog_facility";
    2428
    2529# Collect the username from HTTP auth.  If undefined, we're in
     
    681685  if ($webvar{alloctype} =~ /^.i$/) {
    682686    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    683     my ($sql,$city);
    684     # Check for pools in Subury, North Bay, or Toronto if DSL or server pool.
    685     # Anywhere else is invalid and shouldn't be in the db in the first place.
    686     # ... aside from #^%#$%#@#^%^^!!!! legacy data.  GRRR.
    687     # Note that we want to retain the requested city to relate to customer info.
    688     if ($base =~ /^[ds]$/) {
    689       $city = "(allocations.city='Sudbury' or allocations.city='North Bay' or ".
    690         "allocations.city='Toronto')";
    691     } else {
    692       $city = "allocations.city='$webvar{pop}'";
    693     }
    694687
    695688# Ewww.  But it works.
    696689    $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ".
    697690        "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ".
    698         "poolips.pool=allocations.cidr AND $city AND poolips.type LIKE '".$base."_' ".
     691        "poolips.pool=allocations.cidr AND allocations.city='$webvar{pop}' AND poolips.type LIKE '".$base."_' ".
    699692        "GROUP BY pool");
    700693    $sth->execute;
     
    750743        # This does NOT include cable pools.
    751744        if ($webvar{alloctype} =~ /^.[pc]$/) {
    752           if (($webvar{city} !~ /^(Sudbury|North Bay|Toronto)$/) && ($webvar{alloctype} eq 'dp')) {
    753             printError("You must chose Sudbury, North Bay, or Toronto for DSL pools.");
    754             return;
    755           }
    756745          $city = $webvar{city};
    757746          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    758             " superblock from one of the<br>\nmaster blocks in Sudbury or chose a smaller".
     747            " superblock from one of the<br>\nmaster blocks or chose a smaller".
    759748            " block size for the pool.";
    760749        } else {
    761750          $city = $webvar{pop};
    762751          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    763             " superblock to $webvar{pop}<br>\nfrom one of the master blocks in Sudbury or".
     752            " superblock to $webvar{pop}<br>\nfrom one of the master blocks or".
    764753            " chose a smaller blocksize.";
    765754        }
     
    891880                qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>)
    892881        : "</div>");
    893       # Notify tech@example.com
    894 #      mailNotify('tech@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    895 #       "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
    896 #       "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     882      mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
     883        "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
     884        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
    897885    } else {
    898886      my $netblock = new NetAddr::IP $webvar{fullcidr};
     
    906894                qq(">Add this netblock to RADIUS user table</a></div>)
    907895        : "</div>");
    908 #      mailNotify('nocmgr@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    909 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
    910 #       "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     896      mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
     897        "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
     898        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
    911899    }
    912900    syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ".
     
    958946      if (!$status) {
    959947        printError("Customer ID not valid.  Make sure the Customer ID ".
    960           "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     948          "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
    961949          "non-customer assignments.");
    962950        return;
    963951      }
    964 #"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for
    965 #static IPs for staff.");
    966952    }
    967953#    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
     
    985971  } else {
    986972    $flag = 'n';
    987     if ($webvar{alloctype} =~ /[wp][cr]|[ds][pi]/) {
    988       # Set this forcibly rather than messing around elsewhere.  Yes, this *is* a hack.  PTHBTT!!
    989       $webvar{pop} = 'Sudbury';
    990     }
     973##fixme:  hook to force-set POP or city on certain alloctypes
     974# if ($webvar{alloctype =~ /foo,bar,bz/ { $webvar{pop} = 'blah'; }
    991975    if ($webvar{pop} =~ /^-$/) {
    992976      $flag = 'to route the block from/through';
     
    12251209  # If we get here, the operation succeeded.
    12261210  syslog "notice", "$authuser updated $webvar{block}";
    1227 #mailNotify('nocmgr@example.com',"SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1228 #       "$webvar{block} had SWIP status changed to \"Yes\" by $authuser");
     1211##fixme:  need to wedge something in to allow "update:field" notifications
     1212## hmm.  how to tell what changed?  O_o
     1213mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1214        "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
    12291215  open (HTML, "../updated.html")
    12301216        or croak "Could not open updated.html :$!";
     
    14021388    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}".
    14031389        " $custid, $city, desc='$description'";
    1404     # Notify tech@ when a block/IP is deallocated
    1405 #    mailNotify('tech@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1406 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
    1407 #       "CustID: $custid\nCity: $city\nDescription: $description\n");
    1408 #    mailNotify('nocmgr@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1409 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
    1410 #       "CustID: $custid\nCity: $city\nDescription: $description\n");
     1390    mailNotify($ip_dbh, 'da', "REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1391        "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
     1392        "CustID: $custid\nCity: $city\nDescription: $description\n");
    14111393  } else {
    14121394    if ($webvar{alloctype} =~ /^.i$/) {
  • branches/stable/cgi-bin/newcity.cgi

    r355 r445  
    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;
     
    2120use Sys::Syslog;
    2221
    23 openlog "IPDB","pid","local2";
     22# don't remove!  required for GNU/FHS-ish install from tarball
     23##uselib##
     24
     25use MyIPDB;
     26
     27openlog "IPDB","pid","$IPDB::syslog_facility";
    2428
    2529# Collect the username from HTTP auth.  If undefined, we're in a test environment.
     
    4852if ($sth->err) {
    4953  print "Error adding city to database: ".$sth->errstr;
    50   mailNotify('kdeugau@vianet.ca',"IPDB city add failure",
     54  mailNotify($dbh, 'f:nci', "IPDB city add failure",
    5155        "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr);
    5256  syslog "err", "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr;
  • branches/stable/cgi-bin/newnode.cgi

    r394 r445  
    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.
     
    4548if ($sth->err) {
    4649  print "Error adding node to database: ".$sth->errstr;
    47   mailNotify('noc@example.com',"IPDB node add failure",
     50  mailNotify($dbh, 'f:nno', "IPDB node add failure",
    4851        "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr);
    4952  syslog "err", "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr;
  • branches/stable/cgi-bin/search.cgi

    r395 r445  
    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.
     21# don't remove!  required for GNU/FHS-ish install from tarball
     22##uselib##
     23
     24use MyIPDB;
     25
     26# Don't formally need a username or syslog here.  syslog left active for debugging.
    2327use Sys::Syslog;
    24 openlog "IPDBsearch","pid","local2";
     28openlog "IPDBsearch","pid","$IPDB::syslog_facility";
     29
     30# ... but we do *use* the username on ACLs now.
     31# Collect the username from HTTP auth.  If undefined, we're in
     32# a test environment, or called without a username.
     33my $authuser;
     34if (!defined($ENV{'REMOTE_USER'})) {
     35  $authuser = '__temptest';
     36} else {
     37  $authuser = $ENV{'REMOTE_USER'};
     38}
    2539
    2640# Why not a global DB handle?  (And a global statement handle, as well...)
     
    4963}
    5064
    51 printHeader('Searching...');
     65# Headerize!  Make sure we replace the $$EXTRA0$$ bit as needed.
     66printHeader('', ($IPDBacl{$authuser} =~ /a/ ?
     67        '<td align=right><a href="/ip/cgi-bin/main.cgi?action=assign">Add new assignment</a></td>' : ''
     68        ));
    5269
    5370if ($webvar{stype} eq 'q') {
     
    148165  if ($webvar{cidr} eq '') { # We has a blank CIDR.  Ignore it.
    149166  } elsif ($webvar{cidr} =~ /\//) {
    150     # 209.91.179/26 should show all /26 subnets in 209.91.179
     167    # 192.168.179/26 should show all /26 subnets in 192.168.179
    151168    my ($net,$maskbits) = split /\//, $webvar{cidr};
    152169    if ($webvar{cidr} =~ /^(\d{1,3}\.){3}\d{1,3}\/\d{2}$/) {
     
    340357    $query =~ s/\s+//g;
    341358    if ($query =~ /\//) {
    342       # 209.91.179/26 should show all /26 subnets in 209.91.179
     359      # 192.168.179/26 should show all /26 subnets in 192.168.179
    343360      my ($net,$maskbits) = split /\//, $query;
    344361      if ($query =~ /^(\d{1,3}\.){3}\d{1,3}\/\d{2}$/) {
  • branches/stable/footer.inc

    r230 r445  
    99  <tr>
    1010    <td nowrap="" width="0" height="0" valign="top">
    11       <div align="right"><font face="Arial, Helvetica, sans-serif" size="1">contact:
    12         <a href="mailto:kdeugau@deepnet.cx">kdeugau@deepnet.cx</a> - (c) 2004 <a href="http://www.deepnet.cx/" target="_blank">deepnet</a><br>
    13 Written for standards-based browsers (eg <a href="http://www.netscape.com">Netscape</a>/<a href="http://www.mozilla.org">Mozilla</a>)</font></div>
     11      <div align="right"><font face="Arial, Helvetica, sans-serif" size="1"> DeepNet
     12 <a href="http://projects.deepnet.cx/trac/ipdb" target="_blank">IP Database</a> |
     13 Copyright 2004-2010 <a href="mailto:kdeugau@deepnet.cx">Kris Deugau</a><br>
     14Written for standards-based browsers (eg <a href="http://www.mozilla.org">Mozilla</a>)</font></div>
    1415    </td>
    1516  </tr>
  • branches/stable/header.inc

    r414 r445  
    4949<input type="button" value=" Help? " onclick="openHelp()" class="regular">
    5050</td><td width=10></td><td><a href="/ip/cgi-bin/search.cgi">Complex Search</a></td>
     51$$EXTRA0$$
    5152<td width=60></td>
    52 $$EXTRA0$$
    5353</form>
    5454</tr>
     
    6262</tbody></table>
    6363<table width="98%" border=0><tr><td align=right>
    64 <a href="/ip/cgi-bin/main.cgi?action=nodesearch">Find by connection point</a>&nbsp; &nbsp;
    65 <a href="javascript:popNotes('/ip/changes.html')">Recent Changes</a>
     64<a href="/ip/cgi-bin/main.cgi?action=nodesearch">Find by connection point</a>
    6665</td></tr></table>
    6766<br>
  • branches/stable/help.html

    r414 r445  
    1414
    1515<tr class="color1">
    16 <td>IP blocks</td><td>209.91.128 or 209.</td>
     16<td>IP blocks</td><td>192.168.28 or 192.</td>
    1717<td>Lists all alloctions starting with that set of octets.  Note that matches on the
    1818first octet MUST include the period to be considered an IP search.</td>
    1919</tr>
    2020<tr class="color2">
    21 <td>CIDR blocks</td><td>209.92.128/30</br>or
    22 209.92.128.0/30</td><td>Lists all /30's beginning with 209.91.128 or checks for an
    23 exact match for 209.92.128.0/30 respectively</td>
     21<td>CIDR blocks</td><td>192.168.28/30</br>or
     22192.168.28.0/30</td><td>Lists all /30's beginning with 192.168.28 or checks for an
     23exact match for 192.168.28.0/30 respectively</td>
    2424</tr>
    2525<tr class="color1">
    26 <td>IP address</td><td>209.92.128.30</td><td>Finds the alloction that IP is a
     26<td>IP address</td><td>192.168.28.30</td><td>Finds the alloction that IP is a
    2727part of (if any)</td>
    2828</tr>
    2929<tr class="color2">
    30 <td>Customer ID:</td><td>705 or 6137328844 or 503101</td><td>Find all alloctions to that
    31 customer. Matches on prefix (area code, area code + exchange, etc).  Searches old as well as
    32 new CustIDs.
     30<td>Customer ID:</td><td>123456</td><td>Find all alloctions to that
     31customer.  Customer IDs are assumed to be numeric for this search.
    3332</td>
    3433</tr>
    3534<tr class="color1">
    36 <td>Description:</td><td>cable or efni</td><td>Find all allocations with the search term in
     35<td>Description:</td><td>cable or BigCustomer</td><td>Find all allocations with the search term in
    3736the description.  Note that searches for CustIDs with letters will fall under this category
    38 until CustIDs are all-numeric.</td>
     37unless CustIDs are all-numeric.</td>
    3938</tr>
    4039
Note: See TracChangeset for help on using the changeset viewer.