Only in freeipdb-0_1_2: CHANGES.TXT diff -c freeipdb-0_1_1/Data_Types.txt freeipdb-0_1_2/Data_Types.txt *** freeipdb-0_1_1/Data_Types.txt Tue Nov 13 21:17:55 2001 --- freeipdb-0_1_2/Data_Types.txt Mon Nov 19 13:57:51 2001 *************** *** 4,17 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ! ###################################################################### CREATE TABLE REGIONTABLE ( ID SERIAL, NAME VARCHAR(20) UNIQUE NOT NULL, ! DESCR VARCHAR(30) NOT NULL, RA INT NOT NULL, V6 BOOL, COUNTRY VARCHAR(6) --- 4,17 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ! ######################################################################; CREATE TABLE REGIONTABLE ( ID SERIAL, NAME VARCHAR(20) UNIQUE NOT NULL, ! DESCR VARCHAR(30), RA INT NOT NULL, V6 BOOL, COUNTRY VARCHAR(6) diff -c freeipdb-0_1_1/INSTALL.TXT freeipdb-0_1_2/INSTALL.TXT *** freeipdb-0_1_1/INSTALL.TXT Tue Nov 13 21:15:54 2001 --- freeipdb-0_1_2/INSTALL.TXT Mon Nov 19 13:57:58 2001 *************** *** 1 **** ! Nothing here yet. (Wanna contribute?) --- 1,55 ---- ! # _____ ___ ____ _ _ ! # | ___| __ ___ ___|_ _| _ \ __| | |__ ! # | |_ | '__/ _ \/ _ \| || |_) / _` | '_ \ ! # | _|| | | __/ __/| || __/ (_| | |_) | ! # |_| |_| \___|\___|___|_| \__,_|_.__/ ! # ! # FreeIPdb-0.1.2 11-19-2001 ! ###################################################################### ! ! FreeIPdb Install ! ! -Unpack the tarball: ! It's best to do this in cgi-bin area you want the ! cgi portion to run from (e.g. /usr/local/httpd/cgi-bin/) ! ! tar -zxvf freeipdb-0_1_2.tar.gz ! cd freeipdb-0_1_2 ! ! or ! ! gzip -d freeipdb-0_1_2.tar.gz ! tar -xvf freeipdb-0_1_2.tar ! cd freeipdb-0_1_2 ! ! You may want to consider at this point a sym-link from freeipdb-0_1_2 to freeipdb ! so in the future you can just re-point the sym-link once testing on the new version ! is finished. ! ! -Create the database tables: ! ! There are a few ways to go about doing this. ! (here is one of them) ! ! /usr/local/pgsql/bin/createdb freeipdb ! cat Data_Types.txt | /usr/local/pgsql/bin/psql freeipdb ! ! -Set-up the config file. ! ! cp config.pm.sample config.pm ! -edit the file and set: ! the name of the database (freeipdb used in examples) ! the database host (if it's on the same system it's 127.0.0.1) ! the username ! the password ! ! ! -Try it! ! point a browser @ http:////freeipdb_0_1_2/admin.cgi ! ! ! ###################################################################### ! ! 1 What is FreeIPdb? ! 2 Features. ! 3 How does FreeIPdb Work? ! 4 What are the requirements to run FreeIPdb? ! 5 How do I get Help with FreeIPdb? ! 6 How do I drive FreeIPdb? ! ! 1 What is FreeIPdb. ! ! 2 Features ! ! Regions: A Region is used to divide or combine portions of ! IP space into a independent sections. This gives the ! operator the ability to either keep IP space separate ! (i.e. RIPE,APNIC,ARIN), Allocate a subnet to a project ! or customer that would then be allowed to assign subnets ! from that subnet in any manner they choose. (i.e. operator ! allocates a /24 to the new "shiny-widget" project. The ! manager of the "shiny-widget" project chooses to assign ! a /25 to the "widgets" and a /26 to the "shiny things" in ! L.A. and a /27 to the "shiny things" in New York. The ! manager can see that he has a /27 left and the operator ! knows exactly how the project manager used the IP space that ! he was assigned.) Two different regions are allowed to contain ! IP space from the same block (i.e. more than one region of ! RFC-1918 space). ! Reclaim: When a block (or a parent of it) is in reclaim mode ! that block will NOT be re-allocated or assigned from the ! database in the event that it is reclaimed. This feature ! is useful if the operator has a need to return a block of ! IP space to a RIR or any situation where it is not desirable ! for a block to be allocated or assigned. ! Priorities: As supernets are added to the database for the ! first time the operator may assign a priority. A priority ! is a value that can be used by the database to assign/allocate ! space from one supernet before another. ! IPv6: FreeIPdb works seamlessly with IPv6. The only restriction ! is that IPv6 space be added in a region that contains no IPv4 ! Space. Other than that all features work the same way. ! Hold Time: The operator may set a global hold time (this will ! soon be per region). Every time a block is reclaimed a ! datestamp is set in the block (current time + holdime) when ! that datestamp is less then the current time the database ! will once again allow that block to be allocated/assigned or ! rolled up into it's parent. ! Set a specific block: In the event the operator needs to ! allocate/assign an exact block (i.e. not whatever the database ! returns) they can use the "Set a specific block" feature. The ! database will automaticly create all the parents and children ! needed to locate this block in the database. ! ! 3 How does FreeIPdb work? ! ! FreeIPdb is based on a binary tree database. Every block can ! be the parent of 2 children (A /24 is the parent of 2 /25's). ! FreeIPdb is written in Perl to be universally portable. ! All IP addresses (v4 and v6) are stored in the database as integers ! The allocation and reclaim routines are fully recursive. ! If both children of a parent are not in use both children ! will be pruned from the tree and the parent ! etc... ! The database uses an algorithm of best fit. If you do nothing ! but assignment/allocation(s) you will never have more than ! one unused block of each size in that given region at any time. ! ! ! ! 4 What are the requirements to run FreeIPdb? ! A Perl interpreter. (tested on 5.005_03 built for i386-freebsd). ! PostgreSQL 7.0 with Perl interface installed. (also tested on 7.1.2). ! Math::BigInt-1.42 We're dealing with some mind-boggling-ly big numbers. ! Net::IP-1.0 ! A Webserver capable of running Perl cgi (If you want the web front-end.) ! ! ! ! 5 How do I get Help with FreeIPdb ! ! Send an e-mail to the addresses below with 'subscribe' in the subject ! (you should know how to do this by now;-) ! Announce - announce-request@FreeIPdb.org - ! New releases and important updates. ! Users - users-request@FreeIPdb.org - ! User questions and support. ! Hackers - hackers-request@FreeIPdb.org - ! Development and customization. ! ! 6 How do I drive FreeIPdb? ! ! I'm glad you asked that! Lets start with the admin.cgi page. ! It should be something like cgi-bin/freeipdb-?_?_?/admin.cgi. ! This is where you will add new Registrars, Regions, and Allocations. ! The first thing we need is a Registrar(RA). We'll use ARIN for our ! example. You could use RIPE,APNIC,My_RAR,RFC1918 whatever you want. ! A RA is used to keep track of which space comes from which Authority. ! This way when it comes time to go get more we can do some easy reports ! and poof you're done. So find the section titled "Add a RA", fill in ! the field and click the [Add RA] Button. Provided you are all set ! up correctly you should see the same page with "RA Added" at ! the top. The "RA:" Pull-down in the "Add A Region" section should ! now list your RA. ! ! Our next step to getting FreeIPdb to do something useful will be to ! add a region. ! ! ! What the heck is a region? ! ! A region is a "Pool" of IP space within an RA that may be either ! IPv4 or IPv6(not both). All IP space requests to FreeIPdb require ! a region and will return space from that region. You will likely ! want to think a little about how you want to define your regions. ! Some sample region schemes: ! ! US/MEXICO/CANADA ! North Am./South Am./Asia/Europe/Aust. ! MA/NH/ME/VT/CT/RI ! East/Central/West ! Servers/Desktops/WAN/SAN ! ! I'll let you go on from there. One way to think of a region is like ! a disk partition. You give 30GB to var and it's used for one type of ! operation another 20GB to /usr and that's for different operations. ! /usr can fill up and not have any adverse effect on /var. ! ! ! So now find the "Add a Region" section of the admin page. Choose an ! RA from the pull-down. Give your region a name. If you will be putting ! IPv6 IP space in this region check the box. and hit [Add Region]. ! You should come back to the same page only the region you just added ! will be in the "Region:" pull-downs. ! ! Now for the last step before we can get some gratification :-) ! Add an Allocation. Find the "Add Allocation" section. Enter the ! name of the block so 10.10.10.0 not 10.10.10.0/24. Now the netmask ! so 24 for a class C. Choose a region to add this block to. ! ! ! What the heck is a priority? ! ! I use priorities to keep my older allocation at as close to 100% ! use as I can. The lower the number the more likely the block ! is to be used. If the database can find a larger block with a ! lower priority than a block of the correct size it will split the ! block with the better priority. The tool will do anything possible ! to use a block with a lower priority. ! ! If priority is left null the block will be the last block to be used ! provided there are block with real priority values in that region. ! More than one block with no priority will get used in a quasi-random ! fashion. ! ! ! Enter a priority. Click [Add]. It should be in there. Now we can ! have some real fun. ! ! Lets move to the index.cgi. This page is where the day to day ! user functions will take place. I want to see that the Allocation ! we just added made it to the database. Choose "List free blocks" ! from the action pull-down and click [Submit Request]. ! You should see a list of all the free blocks in your database. ! (If you are following along there should be one entry.) ! ! Lets get a block. Go back to the index.cgi page. Set Action to ! "Request Assignment". Choose the size of the block you want say a ! /28 or 16 IP addresses. Select a region. You can use the next two ! fields for some customer or internal tracking information. now click ! [Submit Request]. You should get something like this: ! ! Your New BlockID is : 327 ! 10.0.23.208/28 from NorthAmerica Swipped=No To: 12333 IPv4 ! ! [Confirm Allocation] [Cancel Allocation] ! ! If you click the Confirm button the block will be saved as in-use ! if you clock cancel it will be reclaimed and become available again. ! (Note: the browser back button will leave this block in an in-use state) ! ! Lets do one more thing before we go. Reclaim a block. To do this we ! need to find the block. we know the the block is a /28 and the region ! is so fill them in. Choose "Search for block in ! database" in the action field and click [Submit Request]. You should ! see your block and maybe others in the list. Here you can either edit ! or reclaim the block. ! ! ! A word about reclaims: ! ! Reclaiming can be fun. It can also cause lots of trouble. Customer ! who think they are done with a block can and do turn-around 10 days ! later and say the need it back. This does not make the Database guy's ! job any easier. We have included the "10 day holding period". When a ! block is reclaimed it becomes ready to use that instant however there ! is a flag set on that entry so that it will not be reused until the ! 10-days have elapsed. (You can use the admin.cgi page to manually ! assign that block if the customer wants it back.) ! ! ! Thats is for now. ! ! More to come. (wanna contribute? ;-) diff -c freeipdb-0_1_1/TODO.TXT freeipdb-0_1_2/TODO.TXT *** freeipdb-0_1_1/TODO.TXT Tue Nov 13 15:39:49 2001 --- freeipdb-0_1_2/TODO.TXT Mon Nov 19 13:58:33 2001 *************** *** 4,46 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1 11-13-2001 ###################################################################### ! 1.0-5- Write an API to get blocks for scripts. (serial IP's) ! 1.0-6- Reporting. ! 1.0-7- Be sure we can have 2 regions with the same block. (e.g. 10.) ! 1.0-8- Say something when a block is added to a region ! prefreably go back to the Page. ! 1.0-11- Rwhoisd... ! 1.0-14- Add Forward DNS Functionality. ! 1.0-15- Add Sorts to the The Search Function ! 1.0-16- Add Toggle to the Search Function ! 1.0.23- DBI interface. ! 1.0.27- Reverse DNS ought to work with regions. ! 1.0.29- Make GetBlockIdNM V6 compliant. ! 1.0.31- [10-30-01] ! 1.0-21- Add a function to allow createion of a reverse DNS zone. ! 1.0.26- some interface to add reverse DNS for any IP. ! 1.0.30- Fix Search by Region. [10-24-01] ! 1.0.28- Can't have dupe reverse entries (can have dupe forwards. [10-23-01] ! 1.0.22- Objectify. [Scrapped for now.] ! 1.0.25- Option to "create reverse zone" when allocationg a block. [Not Needed] ! 1.0-1- Be sure holdtime is cleared anytime a block is allocated. [9-28-01] ! 1.0-20- Move the admin functions to a new page. [9-25-01] ! 1.0-12- Add Reverse DNS Functionality. ! 1.0-13- Serial IP Functionality. [9-24-01] ! 1.0-3- Give users a way to set reclaims. ! 1.0-2- Give users a way to define proirity ! 1.0-4- Give users a way to move an existing blocks into a new region. [9-14-01] ! 1.0-9- lookup.pl now works in reverse. Feed it int and get IP.(v4) ! 1.0-14- Create a config file. check in config.sample --- 4,47 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### ! 0.1-5- Write an API to get blocks for scripts. (serial IP's) ! 0.1-6- Reporting. ! 0.1-7- Be sure we can have 2 regions with the same block. (e.g. 10.) ! 0.1-8- Say something when a block is added to a region ! prefreably go back to the admin Page. ! 0.1-11- Rwhoisd... ! 0.1-14- Add Forward DNS Functionality. ! 0.1-15- Add Sorts to the The Search Function ! 0.1-16- Add Toggle to the Search Function ! 0.1-23- DBI interface. ! 0.1-29- Make GetBlockIdNM V6 compliant. ! 0.1.2-31- rev_gen_tool.pl needs to create something more than a list of zones in the config.file file. + [11-19-01 + 0.1-27- Reverse DNS ought to work with regions. [10-30-01] ! 0.1-21- Add a function to allow createion of a reverse DNS zone. ! 0.1.26- some interface to add reverse DNS for any IP. ! 0.1.30- Fix Search by Region. [10-24-01] ! 0.1.28- Can't have dupe reverse entries (can have dupe forwards. [10-23-01] ! 0.1.22- Objectify. [Scrapped for now.] ! 0.1.25- Option to "create reverse zone" when allocationg a block. [Not Needed] ! 0.1-1- Be sure holdtime is cleared anytime a block is allocated. [9-28-01] ! 0.1-20- Move the admin functions to a new page. [9-25-01] ! 0.1-12- Add Reverse DNS Functionality. ! 0.1-13- Serial IP Functionality. [9-24-01] ! 0.1-3- Give users a way to set reclaims. ! 0.1-2- Give users a way to define proirity ! 0.1-4- Give users a way to move an existing blocks into a new region. [9-14-01] ! 0.1-9- lookup.pl now works in reverse. Feed it int and get IP.(v4) ! 0.1-14- Create a config file. check in config.sample diff -c freeipdb-0_1_1/admin.cgi freeipdb-0_1_2/admin.cgi *** freeipdb-0_1_1/admin.cgi Tue Nov 13 21:37:17 2001 --- freeipdb-0_1_2/admin.cgi Mon Nov 19 13:58:41 2001 *************** *** 5,18 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("FreeIPdb 0.1.1"); print < --- 5,18 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("$config{ver}"); print <
*************** *** 21,37 ****

! FreeIPdb v0.1.1

EOF use Pg; - my $dbhost = "127.0.0.1"; - #my $dbhost = "64.210.27.11"; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname}"); my $buffer; my @pairs; my $pair; --- 21,35 ----

! $config{ver}

EOF use Pg; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname} password=$config{dbpass}"); my $buffer; my @pairs; my $pair; diff -c freeipdb-0_1_1/auto.cgi freeipdb-0_1_2/auto.cgi *** freeipdb-0_1_1/auto.cgi Tue Nov 13 21:21:16 2001 --- freeipdb-0_1_2/auto.cgi Mon Nov 19 13:58:50 2001 *************** *** 5,11 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### require 'ipdb_httpcgi.pl'; --- 5,11 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### require 'ipdb_httpcgi.pl'; *************** *** 14,23 **** print "Content-type: text/html\n\n"; use Pg; - my $dbhost = "127.0.0.1"; - #my $dbhost = "64.210.27.11"; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname}"); my $buffer; my @pairs; my $pair; --- 14,21 ---- print "Content-type: text/html\n\n"; use Pg; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname} password=$config{dbpass}"); my $buffer; my @pairs; my $pair; diff -c freeipdb-0_1_1/config.pm.sample freeipdb-0_1_2/config.pm.sample *** freeipdb-0_1_1/config.pm.sample Tue Nov 13 21:31:17 2001 --- freeipdb-0_1_2/config.pm.sample Sun Nov 18 23:06:24 2001 *************** *** 4,10 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### --- 4,10 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-18-2001 ###################################################################### *************** *** 13,21 **** #Name of the freeipdb table $config{dbname} = "freeipdb"; #IP of the database server. ! $config{dbhost} = "10.20.0.1"; #Username $config{dbuser} = "freeipdb"; return(%config); } 1; --- 13,31 ---- #Name of the freeipdb table $config{dbname} = "freeipdb"; #IP of the database server. ! $config{dbhost} = "127.0.0.1"; #Username $config{dbuser} = "freeipdb"; + #Password + $config{dbpass} = "freeipdb"; + #DNS directory (Where does the rev_gen_tool.pl create the DNS reverse files?) + # should be /etc/namedb/ or something like that. + $config{dnsdir} = "./dns/"; + # The name of the bind8 config file where the rev_gen_tool.pl will add the files + # it created (should not be the main namedb.conf as this file will be overwritten + # everytime (Under $config{dnsdir}) + $config{dnsinclude} = "config.file"; + $config{ver} = "FreeIPdb 0.1.2"; return(%config); } 1; diff -c freeipdb-0_1_1/index.cgi freeipdb-0_1_2/index.cgi *** freeipdb-0_1_1/index.cgi Tue Nov 13 21:34:06 2001 --- freeipdb-0_1_2/index.cgi Mon Nov 19 18:46:02 2001 *************** *** 5,23 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("FreeIPdb 0.1.1"); use Pg; - my $dbhost = "127.0.0.1"; - #my $dbhost = "64.210.27.11"; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname}"); my $buffer; my @pairs; my $pair; --- 5,21 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("$config{ver}"); use Pg; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname} password=$config{dbpass}"); my $buffer; my @pairs; my $pair; *************** *** 41,46 **** --- 39,45 ---- if($FORM{'FORM'} =~ /RECLAIM/){ #procede to reclaim + &ClearRevDNS($conn,$FORM{'RECLAIM'}); &ReclaimBlock($conn,$FORM{'RECLAIM'}); print "Reclaim Block $FORM{'RECLAIM'}\n
"; } *************** *** 151,159 **** @blk = &GetBlockIdNM($conn,$BLK,$FORM{'REGION'}); $block = $blk[0]; $index = $blk[1]; #Set the reverse enrty. ! if($REV){ ! &SetSerialIP($conn,$block,$ForZone,$index,$hostname); } #Get/Create the Forward Block ID #Set the forward entry. --- 150,163 ---- @blk = &GetBlockIdNM($conn,$BLK,$FORM{'REGION'}); $block = $blk[0]; $index = $blk[1]; + unless($block){ + print "Block not allocated.(Can't assign DNS)"; + } #Set the reverse enrty. ! if($FORM{DNSTYPE} eq "REV" || $FORM{DNSTYPE} eq "BOTH"){ ! print "Set Reverse DNS for $FORM{'BLOCK'} to $hostname.$fqdn\n"; ! &SetRevDNS($conn,$block,$ForZone,$index,$hostname); ! &SetRevZone($conn,$FORM{'BLOCK'},$FORM{'REGION'}); } #Get/Create the Forward Block ID #Set the forward entry. *************** *** 174,180 ****

! FreeIPdb v0.1.1

--- 178,184 ----

! $config{ver}

*************** *** 258,264 ****
! --- 262,269 ---- ! diff -c freeipdb-0_1_1/ipdb_ck.pl freeipdb-0_1_2/ipdb_ck.pl *** freeipdb-0_1_1/ipdb_ck.pl Tue Nov 13 21:19:17 2001 --- freeipdb-0_1_2/ipdb_ck.pl Mon Nov 19 13:59:13 2001 *************** *** 1,20 **** # _____ ___ ____ _ _ # | ___| __ ___ ___|_ _| _ \ __| | |__ # | |_ | '__/ _ \/ _ \| || |_) / _` | '_ \ # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### - #!/usr/bin/perl use Pg; use config; %config = config::config(); require 'ipdb_lib.pl'; ! $conn = Pg::connectdb("dbname=$config{dbname} host=$config{dbhost} user=$config{dbuser}"); print " /*--------------------- IP Database Consistency Check ---------------------*/\n\n"; --- 1,20 ---- + #!/usr/bin/perl # _____ ___ ____ _ _ # | ___| __ ___ ___|_ _| _ \ __| | |__ # | |_ | '__/ _ \/ _ \| || |_) / _` | '_ \ # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### use Pg; use config; %config = config::config(); require 'ipdb_lib.pl'; ! $conn = Pg::connectdb("dbname=$config{dbname} host=$config{dbhost} user=$config{dbuser} password=$config{dbpass}"); print " /*--------------------- IP Database Consistency Check ---------------------*/\n\n"; diff -c freeipdb-0_1_1/ipdb_httpcgi.pl freeipdb-0_1_2/ipdb_httpcgi.pl *** freeipdb-0_1_1/ipdb_httpcgi.pl Tue Nov 13 21:21:42 2001 --- freeipdb-0_1_2/ipdb_httpcgi.pl Mon Nov 19 18:43:35 2001 *************** *** 4,10 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### --- 4,10 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### *************** *** 324,342 **** $conn->exec("DELETE FROM reverse_serial_table WHERE BLOCK = $block"); } ! sub GetBlockId(){ ! my $conn = shift; ! my $block = shift; ! my $bits = shift; ! my $region = shift; ! my $query = "SELECT ID FROM IPDB WHERE BLOCK = ".$block."::NUMERIC(40,0) AND BITS = $bits AND REGION = $region"; ! my $result = $conn->exec($query); ! if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockId $EM"); } ! if($result->ntuples){ ! my $id = $result->getvalue(0,0); ! return($id); ! } ! } #Get block ID no mask needed (returns the ID of the block of the smallest size matching the criteria. --- 324,342 ---- $conn->exec("DELETE FROM reverse_serial_table WHERE BLOCK = $block"); } ! #sub GetBlockId(){ ! # my $conn = shift; ! # my $block = shift; ! # my $bits = shift; ! # my $region = shift; ! # my $query = "SELECT ID FROM IPDB WHERE BLOCK = ".$block."::NUMERIC(40,0) AND BITS = $bits AND REGION = $region"; ! # my $result = $conn->exec($query); ! # if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockId $EM"); } ! # if($result->ntuples){ ! # my $id = $result->getvalue(0,0); ! # return($id); ! # } ! #} #Get block ID no mask needed (returns the ID of the block of the smallest size matching the criteria. *************** *** 383,393 **** $string1 = $port; $string2 = $cust.".".$port; &IncSerial($conn,$zoneid); ! &SetSerialIP($conn,$id,$zoneid,1,$string1); ! &SetSerialIP($conn,$id,$zoneid,2,$string2); } ! sub SetSerialIP(){ my $conn = shift; my $block = shift; my $zone = shift; # This is the forward zone. --- 383,393 ---- $string1 = $port; $string2 = $cust.".".$port; &IncSerial($conn,$zoneid); ! &SetRevDNS($conn,$id,$zoneid,1,$string1); ! &SetRevDNS($conn,$id,$zoneid,2,$string2); } ! sub SetRevDNS(){ my $conn = shift; my $block = shift; my $zone = shift; # This is the forward zone. *************** *** 397,408 **** --- 397,454 ---- $result = $conn->exec("SELECT TEXT FROM reverse_serial_table WHERE BLOCK = $block AND ZONE = $zone AND INDEX = $index"); if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockIdNM $EM"); } if($result->ntuples){ + print "
Updating existing entry"; $conn->exec("UPDATE reverse_serial_table SET TEXT = '$string' WHERE BLOCK = $block AND ZONE = $zone AND INDEX = $index"); if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockIdNM $EM"); } } else { + print "
Adding new entry"; $conn->exec("INSERT INTO reverse_serial_table (BLOCK,ZONE,INDEX,TEXT) VALUES ($block,$zone,$index,'$string')"); if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockIdNM $EM"); } } + } + + sub ClearRevDNS(){ + my $conn = shift; + my $block = shift; + my $result = $conn->exec("SELECT ID FROM ZONE_TABLE WHERE REVERSE_BLOCK = $block"); + if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not get used zone list. $EM"); } + my $i = 0; + my $num = $result->ntuples; + while($num != $i){ + $zone = $result->getvalue(0,$i); + IncSerial($conn,$zone); + $i++; + } + $conn->exec("UPDATE ZONE_TABLE SET own = 'f' WHERE REVERSE_BLOCK = $block"); + $conn->exec("UPDATE ZONE_TABLE SET REVERSE_BLOCK = NULL WHERE REVERSE_BLOCK = $block"); + $conn->exec("DELETE FROM reverse_serial_table WHERE BLOCK = $block"); + if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockIdNM $EM"); } + } + + sub SetRevZone(){ + my $conn = shift; + my $block = shift; + my $region = shift; + @ip = split(/\./,$block); + my $RevZoneName = "$ip[2].$ip[1].$ip[0].in-addr.arpa"; + my $RevZone = &GetZone($conn,$RevZoneName); + my $blockname = "$ip[0].$ip[1].$ip[2].0"; + $block = &ip2deci($blockname); + my $query = "SELECT ID FROM IPDB WHERE BLOCK <= ".$block."::NUMERIC(40,0) AND REGION = $region AND BITS = 24 ORDER BY BLOCK DESC"; + if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not query Block from database. $EM"); } + my $result = $conn->exec($query); + if($result->ntuples){ + $id = $result->getvalue(0,0); + my $result = $conn->exec("SELECT REVERSE_BLOCK FROM ZONE_TABLE WHERE ID = $RevZone"); + if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not pull from zone database. $EM"); } + unless($result->getvalue(0,0)){ + $conn->exec("UPDATE ZONE_TABLE SET REVERSE_BLOCK = $id WHERE ID = $RevZone"); + if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not update zone database. $EM"); } + } + } else { + &IPDBError(-1,"Can't find matching block"); + } + &IncSerial($conn,$RevZone); } sub GetZone(){ diff -c freeipdb-0_1_1/ipdb_lib.pl freeipdb-0_1_2/ipdb_lib.pl *** freeipdb-0_1_1/ipdb_lib.pl Tue Nov 13 21:50:37 2001 --- freeipdb-0_1_2/ipdb_lib.pl Mon Nov 19 19:08:24 2001 *************** *** 4,10 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### --- 4,10 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### *************** *** 624,637 **** } else { $conn->exec("BEGIN"); $conn->exec("INSERT INTO IPDB (BLOCK,BITS,REGION,PARENT,PRIORITY) VALUES ($binblock,$bits,$region,0,$priority)"); ! my $result = $conn->exec("SELECT ID FROM IPDB WHERE BLOCK = $binblock AND BITS = $bits AND REGION = $region"); $conn->exec("commit"); if($result->ntuples){ $blockID = $result->getvalue(0,0); return($blockID); } else { ! print "Error could not create new block\n"; ! return(-1); } } } --- 624,644 ---- } else { $conn->exec("BEGIN"); $conn->exec("INSERT INTO IPDB (BLOCK,BITS,REGION,PARENT,PRIORITY) VALUES ($binblock,$bits,$region,0,$priority)"); ! if($errorMessage = $conn->errorMessage){ ! IPDBError(-1,"Could not insert block into database| $errorMessage"); ! } ! my $query = "SELECT ID FROM IPDB WHERE BLOCK = ".$binblock."::NUMERIC(40,0) AND BITS = $bits AND REGION = $region"; ! my $result = $conn->exec($query); ! if($errorMessage = $conn->errorMessage){ ! IPDBError(-1,"Could not query block from database| $errorMessage"); ! } $conn->exec("commit"); if($result->ntuples){ $blockID = $result->getvalue(0,0); + print "
Block added to database."; return($blockID); } else { ! IPDBError(-1,"Could not confirm block in database."); } } } *************** *** 1363,1375 **** my $conn = shift; my $block = shift; my $bits = shift; ! my $query = "SELECT ID FROM IPDB WHERE BLOCK = ".$block."::NUMERIC(40,0) AND BITS = $bits"; my $result = $conn->exec($query); ! if($EM = $conn->errorMessage()){print "Error GetBlockId: $EM\n";} if($result->ntuples){ my $id = $result->getvalue(0,0); return($id); ! } } --- 1370,1383 ---- my $conn = shift; my $block = shift; my $bits = shift; ! my $region = shift; ! my $query = "SELECT ID FROM IPDB WHERE BLOCK = ".$block."::NUMERIC(40,0) AND BITS = $bits AND REGION = $region"; my $result = $conn->exec($query); ! if($EM = $conn->errorMessage()){ &IPDBError(-1,"Could not GetBlockId $EM"); } if($result->ntuples){ my $id = $result->getvalue(0,0); return($id); ! } } diff -c freeipdb-0_1_1/rev_gen_tool.pl freeipdb-0_1_2/rev_gen_tool.pl *** freeipdb-0_1_1/rev_gen_tool.pl Tue Nov 13 21:22:01 2001 --- freeipdb-0_1_2/rev_gen_tool.pl Mon Nov 19 13:59:37 2001 *************** *** 5,11 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### --- 5,11 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### *************** *** 14,23 **** use config; %config = config::config(); use Pg; ! my $dbhost = "127.0.0.1"; ! #my $dbhost = "64.210.27.11"; ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname}"); #Walk DB for Reverse Files. --- 14,24 ---- use config; %config = config::config(); + #Check for DNS dir + open(CONFIG,">$config{dnsdir}/$config{dnsinclude}")|| die "Can't open $config{dnsdir}/$config{dnsinclude} for writing $!"; + use Pg; ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname} password=$config{dbpass}"); #Walk DB for Reverse Files. *************** *** 29,38 **** my $rev_zone = $result->getvalue($i,1); my $zonename = &GetZoneString($conn,$id); print "ZONE $zonename\n"; &ReverseHead($conn,$rev_zone); # Walk blocks under zone. ! WalkReverseBlocks($conn,$rev_zone); $i++; } --- 30,46 ---- my $rev_zone = $result->getvalue($i,1); my $zonename = &GetZoneString($conn,$id); print "ZONE $zonename\n"; + open(FILE,">$config{dnsdir}/$zonename")|| die "Can't open $config{dnsdir}/$zonename for writing $!"; + select(FILE); &ReverseHead($conn,$rev_zone); # Walk blocks under zone. ! &WalkReverseBlocks($conn,$rev_zone); ! select(STDOUT); ! close(FILE); ! print CONFIG "$zonename\n"; ! $i++; } + close(CONFIG); diff -c freeipdb-0_1_1/search.cgi freeipdb-0_1_2/search.cgi *** freeipdb-0_1_1/search.cgi Tue Nov 13 21:22:08 2001 --- freeipdb-0_1_2/search.cgi Mon Nov 19 13:59:45 2001 *************** *** 5,22 **** # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.1 11-13-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("FreeIPdb 0.1.1"); use Pg; - #my $dbhost = "127.0.0.1"; - my $dbhost = "64.210.27.11"; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname}"); my $buffer; my @pairs; my $pair; --- 5,20 ---- # | _|| | | __/ __/| || __/ (_| | |_) | # |_| |_| \___|\___|___|_| \__,_|_.__/ # ! # FreeIPdb-0.1.2 11-19-2001 ###################################################################### require 'ipdb_httpcgi.pl'; use config; %config = config::config(); ! printHead("$condif{ver}"); use Pg; my $script = get_cgi($0); ! my $conn = Pg::connectdb("host=$config{dbhost} user=$config{dbuser} dbname=$config{dbname} password=$config{dbpass}"); my $buffer; my @pairs; my $pair; *************** *** 44,50 ****

! FreeIPdb v0.1.1

--- 42,48 ----

! $config{ver}

Hostname: (Do reverse too: )
Hostname: Set :