Changeset 748


Ignore:
Timestamp:
06/17/15 16:59:08 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Fill in next major subbranch of mergeBlocks() rDNS calls;
clearpeer/clearall.
See #8.

File:
1 edited

Legend:

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

    r747 r748  
    25182518
    25192519    } # scope eq 'keepall' || 'mergepeer'
     2520    else {
     2521
     2522      # Assemble a list of blocks to convert from template to individual records...
     2523      my @convlist;
     2524      my @dellist;
     2525      my @fulldellist;
     2526# There may be an impossible edge case that can be optimized away in here...
     2527      foreach my $mblock (@retlist) {
     2528        my $checkcidr = new NetAddr::IP $mblock->{block};
     2529        next if $mblock->{block} =~ $newblock;
     2530        if (!$block->contains($checkcidr)) {
     2531          # Blocks not within the original get deleted
     2532          push @fulldellist, $mblock->{block};
     2533        }
     2534        elsif ($mblock->{mtype} =~ /.[cmdp]/) {
     2535          # Containers and pools get deleted
     2536          push @dellist, $mblock->{block};
     2537        } else {
     2538          # Whatever's left over gets converted
     2539          push @convlist, $mblock->{block};
     2540        }
     2541      } # foreach @retlist
     2542      # And do the calls.
     2543      if ($args{scope} eq 'clearpeer') {
     2544        # Not happy doing this many, but there isn't really a better way.
     2545        # We delete ALL EVARYTHING in peer blocks...
     2546        _rpc('delRevSet', cidrlist => join(',', @fulldellist), rpcuser => $args{user}, delforward => 'y',
     2547            delsubs => 'y', parpatt => $pinfo->{rdns}) if @fulldellist;
     2548        # ... and just the template for container or pool templates in $prime...
     2549        _rpc('delRevSet', cidrlist => join(',', @dellist), rpcuser => $args{user}, delforward => 'y',
     2550            delsubs => 'n', parpatt => $pinfo->{rdns}) if @dellist;
     2551        # ... and convert a few to record groups
     2552        _rpc('templatesToRecords', templates => \@convlist, rpcuser => $args{user}) if @convlist;
     2553      }
     2554      if ($args{scope} eq 'clearall') {
     2555# consider just doing join(',',$newblock->split($newblock->masklen+1))?
     2556        _rpc('delRevSet', cidrlist => join(',', @fulldellist, @dellist, @convlist, $binfo->{block}),
     2557            rpcuser => $args{user}, delforward => 'y', delsubs => 'y', parpatt => $pinfo->{rdns});
     2558      }
     2559
     2560    } # scope eq 'clearpeer' || 'clearall'
    25202561
    25212562  } # type grouping for rDNS calls
Note: See TracChangeset for help on using the changeset viewer.