Changeset 449


Ignore:
Timestamp:
01/10/13 17:18:52 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix bug in location export; tinydns uses octet-truncated prefixes,
not CIDR netblocks. If a CIDR is entered, iterate over the /8s,
/16s, /24s, or /32s to create the actual entries.
Also silently bail on IPv6 locations; as of writing tinydns does
not support IPv6 for this capability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r448 r449  
    46244624    foreach my $ipprefix (split /[,\s]+/, $lochash->{$location}{iplist}) {
    46254625      $ipprefix =~ s/\s+//g;
    4626       print $datafile "%$location:$ipprefix\n";
     4626      $ipprefix = new NetAddr::IP $ipprefix;
     4627##fixme:  how to handle IPv6?
     4628next if $ipprefix->{isv6};
     4629      # have to account for /nn CIDR entries.  tinydns only speaks octet-sliced prefix.
     4630      if ($ipprefix->masklen <= 8) {
     4631        foreach ($ipprefix->split(8)) {
     4632          my $tmp = $_->addr;
     4633          $tmp =~ s/\.\d+\.\d+\.\d+$//;
     4634          print $datafile "%$location:$tmp\n";
     4635        }
     4636      } elsif ($ipprefix->masklen <= 16) {
     4637        foreach ($ipprefix->split(16)) {
     4638          my $tmp = $_->addr;
     4639          $tmp =~ s/\.\d+\.\d+$//;
     4640          print $datafile "%$location:$tmp\n";
     4641        }
     4642      } elsif ($ipprefix->masklen <= 24) {
     4643        foreach ($ipprefix->split(24)) {
     4644          my $tmp = $_->addr;
     4645          $tmp =~ s/\.\d+$//;
     4646          print $datafile "%$location:$tmp\n";
     4647        }
     4648      } else {
     4649        foreach ($ipprefix->split(32)) {
     4650          print $datafile "%$location:".$_->addr."\n";
     4651        }
     4652      }
    46274653    }
    46284654    print $datafile "%$location\n" if !$lochash->{$location}{iplist};
Note: See TracChangeset for help on using the changeset viewer.