Changeset 445
- Timestamp:
- 07/26/10 17:00:00 (14 years ago)
- Location:
- branches/stable
- Files:
-
- 4 deleted
- 22 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:ignore
-
old new 1 1 local.css 2 *.tar.gz
-
- Property svn:mergeinfo changed
/trunk merged: 415-420,422-443
- Property svn:ignore
-
branches/stable/alloctypes.html
r414 r445 11 11 <table class="regular"> 12 12 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 18 include 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 50 POP.</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 56 cable.</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 62 DSL. Individual IPs will be "assigned" to the customer's city, but the pool 63 will 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 69 customers.</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 75 wireless 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 81 be used for customer connections. Use this if exact tracking of IP 82 usage 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 113 single 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 129 systems 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 150 PPPoE/RADIUS. Note that this is similar to the static DSL pool, but IP space is 151 to 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 91 167 block 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 173 PPPoE/RADIUS. Always taken from a block which has previously been reserved for 174 such 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 98 180 block 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 186 which 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 102 192 have 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, 198 or APNIC)</td> 106 199 </tr> 107 200 -
branches/stable/cgi-bin/CommonWeb.pm
r242 r445 8 8 9 9 package CommonWeb; 10 11 # 08/13/2004 kdeugau@vianet12 # Split DB-related functions into new module; they're not13 # specific to CGI/web stuff.14 10 15 11 use strict; … … 108 104 } 109 105 110 sub loginAgain111 {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 123 106 # needs a reference to the webvar hash. 124 107 # takes out backticks and single quotes -
branches/stable/cgi-bin/CustIDCK.pm
r318 r445 34 34 35 35 return 1 if $custid =~ /^STAFF$/; 36 return 1 if $custid =~ /^ 6750400$/; # just in case some later change might block this36 return 1 if $custid =~ /^5554242$/; # just in case some later change might block this 37 37 return 1 if $custid =~ /^\d{7}$/; 38 38 return 1 if $custid =~ /^\d{10}$/; -
branches/stable/cgi-bin/IPDB.pm
r394 r445 7 7 # Last update by $Author$ 8 8 ### 9 # Copyright (C) 2004-20 06- Kris Deugau9 # Copyright (C) 2004-2010 - Kris Deugau 10 10 11 11 package IPDB; … … 20 20 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); 21 21 22 $VERSION = 2 .0;22 $VERSION = 2; ##VERSION## 23 23 @ISA = qw(Exporter); 24 24 @EXPORT_OK = qw( … … 53 53 our %IPDBacl; 54 54 55 our $org_name = 'Example Corp'; 56 our $smtphost = 'smtp.example.com'; 57 our $domain = 'example.com'; 58 our $defcustid = '5554242'; 59 # mostly for rwhois 60 ##fixme: leave these blank by default? 61 our $rwhoisDataPath = '/usr/local/rwhoisd/etc/rwhoisd'; # to match ./configure defaults from rwhoisd-1.5.9.6 62 our $org_street = '123 4th Street'; 63 our $org_city = 'Anytown'; 64 our $org_prov_state = 'ON'; 65 our $org_pocode = 'H0H 0H0'; 66 our $org_country = 'CA'; 67 our $org_phone = '000-555-1234'; 68 our $org_techhandle = 'ISP-ARIN-HANDLE'; 69 our $org_email = 'noc@example.com'; 70 our $hostmaster = 'dns@example.com'; 71 72 our $syslog_facility = 'local2'; 73 55 74 # Let's initialize the globals. 56 75 ## IPDB::initIPDBGlobals() … … 113 132 # Set up for a PostgreSQL db; could be any transactional DBMS with the 114 133 # right changes. 115 # This definition should be sub connectDB($$$) to be technically correct,116 # but this breaks. GRR.117 134 sub connectDB { 118 my ($dbname,$user,$pass) = @_; 135 my $dbname = shift; 136 my $user = shift; 137 my $pass = shift; 138 my $dbhost = shift; 139 119 140 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"; 123 142 124 143 # Note that we want to autocommit by default, and we will turn it off locally as necessary. … … 557 576 # have to insert all pool IPs into poolips table as "unallocated". 558 577 $sth = $dbh->prepare("insert into poolips (pool,ip,custid,city,type)". 559 " values ('$pool', ?, ' 6750400', '$city', '$type')");578 " values ('$pool', ?, '$defcustid', '$city', '$type')"); 560 579 my @poolip_list = $pool->hostenum; 561 580 if ($class eq 'all') { # (DSL-ish block - *all* IPs available … … 614 633 eval { 615 634 $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',". 617 636 "city=(select city from allocations where cidr >>= '$cidr'". 618 637 " order by masklen(cidr) desc limit 1),". … … 704 723 } # end alloctype general case 705 724 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; 732 755 733 756 # NetAddr::IP->compact() attempts to produce the smallest inclusive block … … 739 762 # $cidr=.32/27, $ip1=.96/27, $ip2=.0/27, and $ip3=.64/27. 740 763 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 } 750 774 } 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)". 761 784 " values ('$cidr',".$cidr->masklen.",'<NULL>')"); 762 763 # Magic hackery to insert "correct" data for deallocation of764 # 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)". 768 791 " values ('$cidr',".$cidr->masklen. 769 792 ",(select city from routed where cidr >>= '$cidr'),'". 770 793 (($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 777 798 778 799 # If we got here, we've succeeded. Whew! … … 780 801 }; # end eval 781 802 if ($@) { 803 $msg = $@; 782 804 eval { $dbh->rollback; }; 783 805 return ('FAIL', $msg); … … 806 828 ## IPDB::mailNotify() 807 829 # 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", 830 sub 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", 815 869 "To: $recip\n", 816 870 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %z",localtime)."\n", 817 871 "Subject: {IPDB} $subj\n", 818 872 "X-Mailer: IPDB Notify v".sprintf("%.1d",$IPDB::VERSION)."\n", 819 "Organization: Example Corp\n",873 "Organization: $org_name\n", 820 874 "\n$message\n"); 875 } 821 876 $mailer->quit; 822 877 } -
branches/stable/cgi-bin/MyIPDB.pm
r319 r445 8 8 # Last update by $Author$ 9 9 ### 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## 11 14 12 15 use IPDB 2.0 qw(:ALL); 16 17 18 # DSN, user, and password for database. These **MUST** be set. 19 my $dbname = 'ipdb'; 20 my $dbuser = 'ipdb'; 21 my $dbpass = 'ipdbpwd'; 22 # DB host is optional. 23 my $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 13 49 14 50 ## connectDB_My() … … 16 52 # Takes no arguments, returns whatever IPDB::connectDB returns. 17 53 sub connectDB_My { 18 return connectDB( "ipdb", "ipdb", "ipdbpwd");54 return connectDB($dbname, $dbuser, $dbpass, $dbhost); 19 55 } # end connectDB_My() 20 56 -
branches/stable/cgi-bin/access-pwd-update.pl
r386 r445 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2007 ,2008- Kris Deugau10 # Copyright (C) 2007-2010 - Kris Deugau 11 11 12 12 use strict; 13 13 use warnings; 14 14 use 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 16 19 use MyIPDB; 17 20 -
branches/stable/cgi-bin/admin.cgi
r414 r445 10 10 # Last update by $Author$ 11 11 ### 12 # Copyright (C) 2004-20 06- Kris Deugau12 # Copyright (C) 2004-2010 - Kris Deugau 13 13 14 14 use strict; … … 17 17 use DBI; 18 18 use CommonWeb qw(:ALL); 19 use MyIPDB;20 19 use CustIDCK; 21 20 #use POSIX qw(ceil); … … 24 23 use Sys::Syslog; 25 24 26 openlog "IPDB-admin","pid","local2"; 25 # don't remove! required for GNU/FHS-ish install from tarball 26 ##uselib## 27 28 use MyIPDB; 29 30 openlog "IPDB-admin","pid","$IPDB::syslog_facility"; 27 31 28 32 # Collect the username from HTTP auth. If undefined, we're in a test environment. … … 53 57 qq(\t<link rel="stylesheet" type="text/css" href="/ip/local.css">\n). 54 58 "</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). 56 60 "for more information.\n</body>\n</html>\n"; 57 61 exit; … … 89 93 print qq(WARNING: There are FAR fewer controls on what you can do here. Use the 90 94 main interface if at all possible. 91 <hr>92 <a href="admin.cgi?action=newalloc">Add allocation</a>93 95 <hr> 94 96 <form action="admin.cgi" method="POST"> … … 107 109 Bump "last updated" timestamp on this master: <select name=whichmaster>$masterlist</select> 108 110 <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 112 blocks with the SWIP box checkmarked. Links to edit/add data are on this page. 110 113 111 114 <hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates 115 112 116 <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) 117 internal 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 119 and allocation types cause notifications; configure recipient lists for notices) 120 114 121 <hr>Consistency check tools<br> 115 122 <a href="consistency-check.pl">General</a>: Check general netblock consistency.<br> 116 123 <a href="freespace.pl">Free space</a>: List total and aggregate free space. Does not 117 124 include 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.121 125 ); 122 126 } else { … … 149 153 if (!$status) { 150 154 printError("Customer ID not valid. Make sure the Customer ID ". 151 "is correct.<br>\nUse STAFF for staff static IPs, and 6750400for any other ".155 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ". 152 156 "non-customer assignments."); 153 157 return; … … 250 254 syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ". 251 255 "'$webvar{alloctype}'"; 252 # Notify tech@example.com 253 mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation", 256 mailNotify($ip_dbh, "a$webvar{alloctype}", 254 257 "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer". 255 258 " $webvar{custid}\n". … … 306 309 <form action=admin.cgi method=POST> 307 310 <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> 309 313 <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> 327 315 </form></table> 328 316 ); … … 336 324 } 337 325 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 check370 } # bad custid371 326 } 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 } 372 332 $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 ". 374 334 "from customers where custid='$webvar{custid}'"); 375 335 $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) = 377 337 $sth->fetchrow_array; 378 338 print qq(<form action=admin.cgi method=POST> … … 381 341 <td>CustID:</td><td>$custid<input type=hidden name=custid value=$custid></td> 382 342 <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> 384 344 <!-- <td>Street2:</td><td><input name=street2></td> --> 385 <t r><td>City:</td><td><input name=city value="$city"></td>386 <t d>Province: (2-letter code)</td><td><input name=province value="$prov" length=2 size=2></td></tr>387 <t r><td>Country: (2-letter code)</td><td><input name=country value="$country" length=2 size=2></td>388 <t d>Postal/ZIP Code:</td><td><input name=pocode value="$pocode"></td></tr>389 <t r><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> 390 350 <!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr> 391 351 <td>Description:</td><td><input name=description></td> --> 392 <t d>ARIN Handles:</td><td>352 <tr><td>Contacts/ARIN Handles:</td><td> 393 353 Tech: <input name=tech_handle value="$tech"><br> 394 354 Abuse: <input name=abuse_handle value="$abuse"><br> 395 355 Admin: <input name=admin_handle value="$admin"><br> 396 356 Note: 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> 398 360 <tr><td colspan=4 align=center><input type=submit value="Update"></td></tr> 399 361 </form></table> 362 <div style="margin-left:5px"> 363 <h3>Explanation for "Special" field:</h3> 364 This is a temporary place to define the WHOIS "net name" for a block. 365 It 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> 368 Example: 369 <pre>NetName192.168.236.0/24: MEGAWIDGET-1</pre> 370 Note: 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> 400 377 ); 401 378 402 379 } 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 404 407 } elsif ($webvar{action} eq 'showpools') { 405 408 print "IP Pools currently allocated:\n". … … 516 519 print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n); 517 520 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 552 <input type=radio name=msgaction value=u>Update 553 <input type=radio name=msgaction value=d>Delete 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); 518 644 } elsif ($webvar{action} ne '<NULL>') { 519 645 print "webvar{action} check failed: Don't know how to $webvar{action}"; … … 668 794 print "</form></table>\n"; 669 795 } 796 797 798 # interpret the notify codes 799 sub 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 .= '<unknown>'; } 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 10 10 use strict; 11 11 use warnings; 12 #use CGI::Carp qw(fatalsToBrowser);13 use Carp;14 12 use DBI; 15 13 use CommonWeb qw(:ALL); 16 use MyIPDB;17 use IBLink;18 use POSIX qw(ceil);19 14 use NetAddr::IP; 20 15 21 16 use Sys::Syslog; 22 17 23 openlog "IPDBshell","pid","local2"; 18 # don't remove! required for GNU/FHS-ish install from tarball 19 ##uselib## 20 21 use MyIPDB; 22 23 openlog "IPDBshell","pid","$IPDB::syslog_facility"; 24 24 25 25 # Collect the username from the environment. If undefined, something -
branches/stable/cgi-bin/checkcusts.pl
r319 r445 7 7 # Last update by $Author$ 8 8 ### 9 # Copyright (C) 2004-20 06Kris Deugau9 # Copyright (C) 2004-2010 Kris Deugau 10 10 11 11 use DBI; … … 33 33 push @def_custids, $data[0]; 34 34 } 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') ". 36 36 "and not (custid='STAFF') order by cidr"); 37 37 #$sth = $dbh->prepare("select cidr,custid from searchme order by cidr"); -
branches/stable/cgi-bin/combineblocks.pl
r306 r445 14 14 use DBI; 15 15 #use CommonWeb qw(:ALL); 16 use MyIPDB;17 16 #use POSIX qw(ceil); 18 17 use NetAddr::IP; 19 18 20 #use Sys::Syslog; 19 # don't remove! required for GNU/FHS-ish install from tarball 20 ##uselib## 21 22 use MyIPDB; 21 23 22 24 my $null = new NetAddr::IP "255.255.255.255/32"; -
branches/stable/cgi-bin/consistency-check.pl
r444 r445 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004 - Kris Deugau10 # Copyright (C) 2004-2010 - Kris Deugau 11 11 12 12 use DBI; 13 use NetAddr::IP; 14 15 # don't remove! required for GNU/FHS-ish install from tarball 16 ##uselib## 17 13 18 use MyIPDB; 14 use NetAddr::IP;15 19 16 20 print "Content-type: text/plain\n\n"; … … 230 234 print "Checking for customer blocks with 'bad' CustIDs:\n"; 231 235 # 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"); 233 237 $sth->execute; 234 238 while (@data = $sth->fetchrow_array) { -
branches/stable/cgi-bin/extras/db2rwhois.pl
r375 r445 10 10 # Last update by $Author$ 11 11 ### 12 # Copyright (C) 2004-20 07- Kris Deugau12 # Copyright (C) 2004-2010 - Kris Deugau 13 13 14 14 use strict; … … 16 16 use DBI; 17 17 use NetAddr::IP; 18 use File::Path 'rmtree'; 19 use POSIX qw(strftime); 20 21 # don't remove! required for GNU/FHS-ish install from tarball 22 ##uselib## 23 18 24 use 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"; 24 27 25 28 my @autharea; 26 29 my $authrw; 27 30 # Use the template file to allow us to keep persistent nodes aside from netblock data 28 open AUTHTEMPLATE, "<$ rwhoisDataPath/rwhoisd.auth_template";31 open AUTHTEMPLATE, "<$IPDB::rwhoisDataPath/rwhoisd.auth_template"; 29 32 my $template_persist; 30 33 while (<AUTHTEMPLATE>) { … … 43 46 44 47 # Get the list of live directories for potential deletion 45 opendir RWHOISROOT, $ rwhoisDataPath;48 opendir RWHOISROOT, $IPDB::rwhoisDataPath; 46 49 my %rwhoisdirs; 47 50 foreach (readdir RWHOISROOT) { … … 91 94 print "$masterblocks[$i] $ctime $mtime\n"; 92 95 93 my $date; 94 chomp ($date = `/bin/date +"%Y-%m-%d"`); 96 my $date = strftime("%Y-%m-%d", localtime); 95 97 96 98 my $rwnet = "net-".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen; … … 100 102 101 103 # 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"; 103 105 if (! -e $netdatadir) { 104 106 print " New master $masterblocks[$i]!\n"; … … 111 113 mkdir "$netdatadir/data/referral"; 112 114 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 :( 116 118 print " Creating SOA...\n"; 117 119 open SOAFILE, ">$netdatadir/soa"; … … 121 123 Retry-Interval: 1800 122 124 Time-To-Live: 86400 123 Primary-Server: rwhois. example.com:4321124 Hostmaster: dns\@example.com125 Primary-Server: rwhois.$IPDB::domain:4321 126 Hostmaster: $IPDB::hostmaster 125 127 ); 126 128 close SOAFILE; … … 147 149 148 150 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... 151 155 print " Creating org data...\n"; 152 open ORGDATAFILE, ">$netdatadir/data/org/ friendlyisp.txt";156 open ORGDATAFILE, ">$netdatadir/data/org/ourorg.txt"; 153 157 print ORGDATAFILE qq(ID: NETBLK-ISP.$masterblocks[$i] 154 158 Auth-Area: $masterblocks[$i] 155 Org-Name: Friendly ISP156 Street-Address: 123 4th Street157 City: Anytown158 State: ON159 Postal-Code: H0H 0H0160 Country-Code: CA161 Phone: 000-555-1234159 Org-Name: $IPDB::org_name 160 Street-Address: $IPDB::org_street 161 City: $IPDB::org_city 162 State: $IPDB::org_prov_state 163 Postal-Code: $IPDB::org_pocode 164 Country-Code: $IPDB::org_country 165 Phone: $IPDB::org_phone 162 166 Created: 20040308 163 167 Updated: 20040308 … … 182 186 my $masterfilename = "$rwnet/data/network/".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen.".txt"; 183 187 184 open MASTERFILE,">$ rwhoisDataPath/$masterfilename";188 open MASTERFILE,">$IPDB::rwhoisDataPath/$masterfilename"; 185 189 186 190 print MASTERFILE "ID: NETBLK-ISP.$masterblocks[$i]\n". … … 189 193 "IP-Network: $masterblocks[$i]\n". 190 194 "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". 198 202 "Created: $ctime\n". 199 203 "Updated: $mtime\n". 200 "Updated-By: noc\@example.com\n";204 "Updated-By: $IPDB::org_email\n"; 201 205 202 206 # And now the subblocks … … 226 230 227 231 # Fill in a generic entry for nameless allocations 228 if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }232 if ($desc =~ /^\s*$/) { $desc = $IPDB::org_name; } 229 233 230 234 # Fix up datestamps. We don't *really* need sub-microsecond resolution on our exports... … … 257 261 "IP-Network: $net\n". 258 262 "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". 266 270 "Created: $ctime\n". 267 271 "Updated: $mtime\n". 268 "Updated-By: noc\@example.com\n";272 "Updated-By: $IPDB::org_email\n"; 269 273 } else { 270 274 $custsth->execute($custid); … … 281 285 "IP-Network: $net\n". 282 286 "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". 290 294 "Created: $ctime\n". 291 295 "Updated: $mtime\n". 292 "Updated-By: noc\@example.com\n";296 "Updated-By: $IPDB::org_email\n"; 293 297 } # swip 294 298 … … 304 308 foreach my $netdir (keys %rwhoisdirs) { 305 309 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 } ); 307 311 for my $diag (@$errlist) { 308 312 my ($file, $message) = each %$diag; … … 317 321 if ($authrw) { 318 322 print "Regenerating auth_area\n"; 319 open RWHOISDAUTH, ">$ rwhoisDataPath/rwhoisd.auth_area";323 open RWHOISDAUTH, ">$IPDB::rwhoisDataPath/rwhoisd.auth_area"; 320 324 print RWHOISDAUTH "# WARNING: This file is autogenerated! Any static nodes should\n". 321 325 "# be entered in /etc/rwhoisd/rwhoisd.auth_template\n"; … … 333 337 334 338 # restart/reload rwhoisd 335 if (-e "$ rwhoisDataPath/rwhoisd.pid") { # no pidfile, no restart.339 if (-e "$IPDB::rwhoisDataPath/rwhoisd.pid") { # no pidfile, no restart. 336 340 print "Restarting rwhoisd\n"; 337 open PIDFILE, "<$ rwhoisDataPath/rwhoisd.pid";341 open PIDFILE, "<$IPDB::rwhoisDataPath/rwhoisd.pid"; 338 342 my ($rwpid) = (<PIDFILE> =~ /^(\d+)/); 339 343 close PIDFILE; -
branches/stable/cgi-bin/freespace.pl
r319 r445 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004-20 06- Kris Deugau10 # Copyright (C) 2004-2010 - Kris Deugau 11 11 12 12 use DBI; 13 use NetAddr::IP; 14 15 # don't remove! required for GNU/FHS-ish install from tarball 16 ##uselib## 17 13 18 use MyIPDB; 14 use NetAddr::IP;15 19 16 20 ($dbh,$errstr) = connectDB_My; -
branches/stable/cgi-bin/ipdb.psql
r410 r445 137 137 mi Static IP - Dialup Static dialup IP 23 ISP 138 138 wi Static IP - Wireless Static wireless IP 24 ISP 139 sd Static Pool - Servers Server pool 40 6750400ISP139 sd Static Pool - Servers Server pool 40 5554242 ISP 140 140 cd Static Pool - Cable Cable pool 41 CBL-BUS ISP-STATIC-CABLE 141 141 dp Static Pool - DSL DSL pool 42 DSL-BUS ISP-STATIC-DSL 142 142 mp Static Pool - Dialup Static dialup pool 43 DIAL-BUS ISP-STATIC-DIAL 143 143 wp Static Pool - Wireless Static wireless pool 44 WL-BUS ISP-STATIC-WIFI 144 en End-use netblock End-use netblock 100 6750400ISP144 en End-use netblock End-use netblock 100 5554242 ISP 145 145 me Dialup netblock Dialup netblock 101 DIAL-RES ISP-DIAL 146 146 de Dynamic DSL block Dynamic DSL block 102 DSL-RES ISP-DSL … … 154 154 ad Static Pool - Management Management pool 196 NOC-VPN ISP 155 155 bd Static pool - Wifi CPE Wifi CPE pool 197 ISP 156 in Internal netblock Internal netblock 199 6750400ISP157 wc Reserve for CORE/WAN blocks CORE/WAN blocks 200 6750400ISP158 pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 6750400ISP-STATIC-DSL159 ac Reserve for ATM ATM blocks 202 6750400ISP160 fc Reserve for fibre Fibre blocks 203 6750400ISP161 wr CORE/WAN block CORE/WAN block 220 6750400ISP156 in Internal netblock Internal netblock 199 5554242 ISP 157 wc Reserve for CORE/WAN blocks CORE/WAN blocks 200 5554242 ISP 158 pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 5554242 ISP-STATIC-DSL 159 ac Reserve for ATM ATM blocks 202 5554242 ISP 160 fc Reserve for fibre Fibre blocks 203 5554242 ISP 161 wr CORE/WAN block CORE/WAN block 220 5554242 ISP 162 162 pr Dynamic-route DSL netblock (cust) Dynamic-route DSL (cust) 221 ISPCUST 163 163 ar ATM block ATM block 222 ISP 164 164 fr Fibre Fibre 223 ISP 165 rm Routing Routed netblock 500 6750400ISP166 mm Master block Master block 999 6750400ISP165 rm Routing Routed netblock 500 5554242 ISP 166 mm Master block Master block 999 5554242 ISP 167 167 \. 168 168 … … 226 226 node_ip inet 227 227 ); 228 229 -- Email notifications on <action> 230 CREATE TABLE notify ( 231 action varchar(5) NOT NULL PRIMARY KEY, 232 reciplist varchar(500) 233 ); -
branches/stable/cgi-bin/main.cgi
r408 r445 1 1 #!/usr/bin/perl 2 2 # ipdb/cgi-bin/main.cgi 3 # Started munging from noc.vianet's old IPDB 04/22/20044 3 ### 5 4 # SVN revision info … … 8 7 # Last update by $Author$ 9 8 ### 9 # Copyright (C) 2004-2010 - Kris Deugau 10 10 11 11 use strict; … … 14 14 use DBI; 15 15 use CommonWeb qw(:ALL); 16 use MyIPDB;17 16 use CustIDCK; 18 17 use POSIX qw(ceil); … … 21 20 use Sys::Syslog; 22 21 23 openlog "IPDB","pid","local2"; 22 # don't remove! required for GNU/FHS-ish install from tarball 23 ##uselib## 24 25 use MyIPDB; 26 27 openlog "IPDB","pid","$IPDB::syslog_facility"; 24 28 25 29 # Collect the username from HTTP auth. If undefined, we're in … … 681 685 if ($webvar{alloctype} =~ /^.i$/) { 682 686 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 }694 687 695 688 # Ewww. But it works. 696 689 $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ". 697 690 "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ". 698 "poolips.pool=allocations.cidr AND $cityAND poolips.type LIKE '".$base."_' ".691 "poolips.pool=allocations.cidr AND allocations.city='$webvar{pop}' AND poolips.type LIKE '".$base."_' ". 699 692 "GROUP BY pool"); 700 693 $sth->execute; … … 750 743 # This does NOT include cable pools. 751 744 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 }756 745 $city = $webvar{city}; 757 746 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 758 " superblock from one of the<br>\nmaster blocks in Sudburyor chose a smaller".747 " superblock from one of the<br>\nmaster blocks or chose a smaller". 759 748 " block size for the pool."; 760 749 } else { 761 750 $city = $webvar{pop}; 762 751 $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 Sudburyor".752 " superblock to $webvar{pop}<br>\nfrom one of the master blocks or". 764 753 " chose a smaller blocksize."; 765 754 } … … 891 880 qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>) 892 881 : "</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"); 897 885 } else { 898 886 my $netblock = new NetAddr::IP $webvar{fullcidr}; … … 906 894 qq(">Add this netblock to RADIUS user table</a></div>) 907 895 : "</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"); 911 899 } 912 900 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ". … … 958 946 if (!$status) { 959 947 printError("Customer ID not valid. Make sure the Customer ID ". 960 "is correct.<br>\nUse STAFF for staff static IPs, and 6750400for any other ".948 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ". 961 949 "non-customer assignments."); 962 950 return; 963 951 } 964 #"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for965 #static IPs for staff.");966 952 } 967 953 # print "<!-- [ In validateInput(). Insert customer ID cross-check here. ] -->\n"; … … 985 971 } else { 986 972 $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'; } 991 975 if ($webvar{pop} =~ /^-$/) { 992 976 $flag = 'to route the block from/through'; … … 1225 1209 # If we get here, the operation succeeded. 1226 1210 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 1213 mailNotify($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'; 1229 1215 open (HTML, "../updated.html") 1230 1216 or croak "Could not open updated.html :$!"; … … 1402 1388 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}". 1403 1389 " $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"); 1411 1393 } else { 1412 1394 if ($webvar{alloctype} =~ /^.i$/) { -
branches/stable/cgi-bin/newcity.cgi
r355 r445 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004 ,2005- Kris Deugau10 # Copyright (C) 2004-2010 - Kris Deugau 11 11 12 12 use strict; … … 15 15 use DBI; 16 16 use CommonWeb qw(:ALL); 17 use MyIPDB;18 17 #use POSIX qw(ceil); 19 18 use NetAddr::IP; … … 21 20 use Sys::Syslog; 22 21 23 openlog "IPDB","pid","local2"; 22 # don't remove! required for GNU/FHS-ish install from tarball 23 ##uselib## 24 25 use MyIPDB; 26 27 openlog "IPDB","pid","$IPDB::syslog_facility"; 24 28 25 29 # Collect the username from HTTP auth. If undefined, we're in a test environment. … … 48 52 if ($sth->err) { 49 53 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", 51 55 "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr); 52 56 syslog "err", "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr; -
branches/stable/cgi-bin/newnode.cgi
r394 r445 15 15 use DBI; 16 16 use CommonWeb qw(:ALL); 17 use MyIPDB;18 17 #use POSIX qw(ceil); 19 18 use NetAddr::IP; 20 21 19 use Sys::Syslog; 22 20 23 openlog "IPDB","pid","local2"; 21 # don't remove! required for GNU/FHS-ish install from tarball 22 ##uselib## 23 24 use MyIPDB; 25 26 openlog "IPDB","pid","$IPDB::syslog_facility"; 24 27 25 28 # Collect the username from HTTP auth. If undefined, we're in a test environment. … … 45 48 if ($sth->err) { 46 49 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", 48 51 "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr); 49 52 syslog "err", "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr; -
branches/stable/cgi-bin/search.cgi
r395 r445 9 9 # Last update by $Author$ 10 10 ### 11 # Copyright 2005 ,2006Kris Deugau11 # Copyright 2005-2010 - Kris Deugau 12 12 13 13 use strict; … … 16 16 use DBI; 17 17 use CommonWeb qw(:ALL); 18 use MyIPDB;19 18 use POSIX qw(ceil); 20 19 use NetAddr::IP; 21 20 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 24 use MyIPDB; 25 26 # Don't formally need a username or syslog here. syslog left active for debugging. 23 27 use Sys::Syslog; 24 openlog "IPDBsearch","pid","local2"; 28 openlog "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. 33 my $authuser; 34 if (!defined($ENV{'REMOTE_USER'})) { 35 $authuser = '__temptest'; 36 } else { 37 $authuser = $ENV{'REMOTE_USER'}; 38 } 25 39 26 40 # Why not a global DB handle? (And a global statement handle, as well...) … … 49 63 } 50 64 51 printHeader('Searching...'); 65 # Headerize! Make sure we replace the $$EXTRA0$$ bit as needed. 66 printHeader('', ($IPDBacl{$authuser} =~ /a/ ? 67 '<td align=right><a href="/ip/cgi-bin/main.cgi?action=assign">Add new assignment</a></td>' : '' 68 )); 52 69 53 70 if ($webvar{stype} eq 'q') { … … 148 165 if ($webvar{cidr} eq '') { # We has a blank CIDR. Ignore it. 149 166 } elsif ($webvar{cidr} =~ /\//) { 150 # 209.91.179/26 should show all /26 subnets in 209.91.179167 # 192.168.179/26 should show all /26 subnets in 192.168.179 151 168 my ($net,$maskbits) = split /\//, $webvar{cidr}; 152 169 if ($webvar{cidr} =~ /^(\d{1,3}\.){3}\d{1,3}\/\d{2}$/) { … … 340 357 $query =~ s/\s+//g; 341 358 if ($query =~ /\//) { 342 # 209.91.179/26 should show all /26 subnets in 209.91.179359 # 192.168.179/26 should show all /26 subnets in 192.168.179 343 360 my ($net,$maskbits) = split /\//, $query; 344 361 if ($query =~ /^(\d{1,3}\.){3}\d{1,3}\/\d{2}$/) { -
branches/stable/footer.inc
r230 r445 9 9 <tr> 10 10 <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> 14 Written for standards-based browsers (eg <a href="http://www.mozilla.org">Mozilla</a>)</font></div> 14 15 </td> 15 16 </tr> -
branches/stable/header.inc
r414 r445 49 49 <input type="button" value=" Help? " onclick="openHelp()" class="regular"> 50 50 </td><td width=10></td><td><a href="/ip/cgi-bin/search.cgi">Complex Search</a></td> 51 $$EXTRA0$$ 51 52 <td width=60></td> 52 $$EXTRA0$$53 53 </form> 54 54 </tr> … … 62 62 </tbody></table> 63 63 <table width="98%" border=0><tr><td align=right> 64 <a href="/ip/cgi-bin/main.cgi?action=nodesearch">Find by connection point</a> 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> 66 65 </td></tr></table> 67 66 <br> -
branches/stable/help.html
r414 r445 14 14 15 15 <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> 17 17 <td>Lists all alloctions starting with that set of octets. Note that matches on the 18 18 first octet MUST include the period to be considered an IP search.</td> 19 19 </tr> 20 20 <tr class="color2"> 21 <td>CIDR blocks</td><td> 209.92.128/30</br>or22 209.92.128.0/30</td><td>Lists all /30's beginning with 209.91.128 or checks for an23 exact match for 209.92.128.0/30 respectively</td>21 <td>CIDR blocks</td><td>192.168.28/30</br>or 22 192.168.28.0/30</td><td>Lists all /30's beginning with 192.168.28 or checks for an 23 exact match for 192.168.28.0/30 respectively</td> 24 24 </tr> 25 25 <tr class="color1"> 26 <td>IP address</td><td> 209.92.128.30</td><td>Finds the alloction that IP is a26 <td>IP address</td><td>192.168.28.30</td><td>Finds the alloction that IP is a 27 27 part of (if any)</td> 28 28 </tr> 29 29 <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 31 customer. Customer IDs are assumed to be numeric for this search. 33 32 </td> 34 33 </tr> 35 34 <tr class="color1"> 36 <td>Description:</td><td>cable or efni</td><td>Find all allocations with the search term in35 <td>Description:</td><td>cable or BigCustomer</td><td>Find all allocations with the search term in 37 36 the description. Note that searches for CustIDs with letters will fall under this category 38 un tilCustIDs are all-numeric.</td>37 unless CustIDs are all-numeric.</td> 39 38 </tr> 40 39
Note:
See TracChangeset
for help on using the changeset viewer.