- Timestamp:
- 08/09/05 17:15:26 (19 years ago)
- Location:
- branches/dns/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dns/cgi-bin/IPDB.pm
r262 r273 184 184 # Does all of the magic of actually allocating a netblock 185 185 # Requires database handle, block to allocate, custid, type, city, 186 # description, notes, circuit ID, block to allocate from, 186 # description, notes, circuit ID, block to allocate from, 187 # rDNS for the block/IP 187 188 # Returns a success code and optional error message. 188 189 sub allocateBlock { 189 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid ) = @_;190 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$rdns) = @_; 190 191 191 192 my $cidr = new NetAddr::IP $_[1]; … … 223 224 " where ip='$cidr'"); 224 225 $sth->execute; 226 227 # rDNS change is an update as the pool should have set "unassigned..." 228 # rDNS on all IPs already. 229 $msg = "Unable to update rDNS assigning $cidr to $custid"; 230 $sth = $dbh->prepare("update dns set hostname='$rdns',auto='n' where ip='$cidr'"); 231 $sth->execute; 232 225 233 $dbh->commit; 226 234 }; … … 405 413 # Note that this is NOT done in a transaction, that's why it's a private 406 414 # function and should ONLY EVER get called from allocateBlock() 415 # We also do the rDNS for the pool here to save some sanity. 407 416 sub initPool { 408 my ($dbh,undef,$type,$city,$class ) = @_;417 my ($dbh,undef,$type,$city,$class,$rdns,$domain) = @_; 409 418 my $pool = new NetAddr::IP $_[1]; 410 419 … … 424 433 $sth = $dbh->prepare("insert into poolips (pool,ip,custid,city,type)". 425 434 " values ('$pool', ?, '6750400', '$city', '$type')"); 435 my $sth2 = $dbh->prepare("insert into dns (ip,hostname) values (?, ?)"); 426 436 my @poolip_list = $pool->hostenum; 427 437 if ($class eq 'all') { # (DSL-ish block - *all* IPs available 428 438 if ($pool->addr !~ /\.0$/) { # .0 causes weirdness. 429 439 $sth->execute($pool->addr); 440 # Insert rDNS entry 441 $sth2->execute($pool->addr,subst_rDNS($rdns,$pool->addr).".".$domain); 430 442 } 431 443 for (my $i=0; $i<=$#poolip_list; $i++) { 432 444 $sth->execute($poolip_list[$i]->addr); 445 # Insert rDNS entry 446 $sth2->execute($poolip_list[$i]->addr, 447 subst_rDNS($rdns,$poolip_list[$i]->addr).".".$domain); 433 448 } 434 449 $pool--; 435 450 if ($pool->addr !~ /\.255$/) { # .255 can cause weirdness. 436 451 $sth->execute($pool->addr); 452 # Insert rDNS entry 453 $sth2->execute($pool->addr,subst_rDNS($rdns,$pool->addr).".".$domain); 437 454 } 438 455 } else { # (real netblock) 439 456 for (my $i=1; $i<=$#poolip_list; $i++) { 440 457 $sth->execute($poolip_list[$i]->addr); 458 # Insert rDNS entry 459 $sth2->execute($poolip_list[$i]->addr, 460 subst_rDNS($rdns,$poolip_list[$i]->addr).".".$domain); 441 461 } 442 462 } … … 628 648 } 629 649 650 651 ## IPDB::subst_rDNS() 652 # Substitute tokens in a template string for rDNS entries 653 sub subst_rDNS { 654 my ($template,$ip) = $@; 655 656 my ($o1,$o2,$o3,$o4) = ($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)/); 657 $rdns =~ s/\%o1\%/$o1/; 658 $rdns =~ s/\%o2\%/$o2/; 659 $rdns =~ s/\%o3\%/$o3/; 660 $rdns =~ s/\%o4\%/$o4/; 661 $rdns =~ s/\%d\%/$o1$-o2-$o3-$o4/; 662 663 return $rdns; 664 } # end subst_rDNS() 665 630 666 # Indicates module loaded OK. Required by Perl. 631 667 1; -
branches/dns/cgi-bin/main.cgi
r262 r273 641 641 my $cidr; 642 642 my $alloc_from; 643 my $rdns; 643 644 644 645 # Going to manually validate some items. … … 781 782 $html =~ s|\$\$CITY\$\$|$webvar{city}|g; 782 783 $html =~ s|\$\$CUSTID\$\$|$webvar{custid}|g; 784 $html =~ s|\$\$RDNS\$\$|$rdns|g; 783 785 $webvar{circid} = desanitize($webvar{circid}); 784 786 $html =~ s|\$\$CIRCID\$\$|$webvar{circid}|g;
Note:
See TracChangeset
for help on using the changeset viewer.