Changeset 602
- Timestamp:
- 03/28/14 15:22:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r601 r602 4802 4802 my $logfrag = ''; 4803 4803 4804 # Collect some record parts 4804 4805 my $type = $rr->type; 4805 4806 my $host = $rr->name; 4806 4807 my $ttl = ($args{newttl} ? $args{newttl} : $rr->ttl); # allow force-override TTLs 4807 4808 4809 # Info flags for SOA and NS records 4808 4810 $soaflag = 1 if $type eq 'SOA'; 4809 4811 $nsflag = 1 if $type eq 'NS'; … … 4828 4830 # processing depending on the record. le sigh. 4829 4831 4832 # do the initial processing as if the record was in a forward zone. If we're 4833 # doing a revzone, we can flip $host and $val as needed, once, after this 4834 # monster if-elsif-...-elsif-else. This actually simplifies things a lot. 4835 4830 4836 ##fixme: what record types other than TXT can/will have >255-byte payloads? 4831 4837 … … 4834 4840 } elsif ($type eq 'NS') { 4835 4841 # hmm. should we warn here if subdomain NS'es are left alone? 4836 if ($rev eq 'y') { 4837 # revzones have records more or less reversed from forward zones. 4838 my ($tmpcode,$tmpmsg) = _zone2cidr($host); 4839 die "Error converting NS record: $tmpmsg\n" if $tmpcode eq 'FAIL'; # hmm. may not make sense... 4840 next if ($args{rwns} && ($tmpmsg eq "$cidr")); 4841 $val = "$tmpmsg"; 4842 $host = $rr->nsdname; 4843 $logfrag = "Added record '$val $type $host', TTL $ttl"; 4844 # Tag and preserve. For now this is commented for a no-op, but we have Ideas for 4845 # another custom storage type ("DELEGATE") that will use these subzone-delegation records 4846 #if ($val ne "$cidr") { 4847 # push @{$suboct{$val}{ns}}, $host; 4848 #} 4849 } else { 4850 next if ($args{rwns} && ($rr->name eq $zone)); 4851 $val = $rr->nsdname; 4852 } 4842 next if ($args{rwns} && ($host eq $zone)); 4843 $val = $rr->nsdname; 4853 4844 $nsflag = 1; 4854 4845 } elsif ($type eq 'CNAME') { 4855 if ($rev eq 'y') { 4856 # hmm. do we even want to bother with storing these at this level? Sub-octet delegation 4857 # by CNAME is essentially a record-publication hack, and we want to just represent the 4858 # "true" logical intentions as far down the stack as we can from the UI. 4859 ($host,$val) = _revswap($host,$rr->cname); 4860 $logfrag = "Added record '$val $type $host', TTL $ttl"; 4861 # Tag and preserve in case we want to commit them as-is later, but mostly we don't care. 4862 # Commented pending actually doing something with possibly new type DELEGATE 4863 #my $tmprev = $host; 4864 #$tmprev =~ s/^\d+\.//; 4865 #($code,$tmprev) = _zone2cidr($tmprev); 4866 #push @{$suboct{"$tmprev"}{cname}}, $val; 4867 # Silently skip CNAMEs in revzones. 4868 next; 4869 } else { 4870 $val = $rr->cname; 4871 } 4846 $val = $rr->cname; 4872 4847 } elsif ($type eq 'SOA') { 4873 4848 next if $args{rwsoa}; … … 4876 4851 $soaflag = 1; 4877 4852 } elsif ($type eq 'PTR') { 4878 ($host,$val) = _revswap($host,$rr->ptrdname); 4879 $logfrag = "Added record '$val $type $host', TTL $ttl"; 4880 # hmm. PTR records should not be in forward zones. 4853 $val = $rr->ptrdname; 4881 4854 } elsif ($type eq 'MX') { 4882 4855 $val = $rr->exchange; … … 4891 4864 # details as far down the stack as we can) 4892 4865 # NB: this may turn out to be more troublesome if we ever have need of >512-byte TXT records. 4893 if ($rev eq 'y') { 4894 ($host,$val) = _revswap($host,$rr->txtdata); 4895 $logfrag = "Added record '$val $type $host', TTL $ttl"; 4896 } else { 4897 $val = $rr->txtdata; 4898 } 4866 $val = $rr->txtdata; 4899 4867 } elsif ($type eq 'SPF') { 4900 4868 ##fixme: and the same caveat here, since it is apparently a clone of ::TXT … … 4916 4884 $warnmsg .= "Unusual record ".$rr->name." ($type) found\n"; 4917 4885 } 4886 4887 if ($rev eq 'y' && $type ne 'SOA') { 4888 # up to this point we haven't meddled with the record's hostname part or rdata part. 4889 # for reverse records, (except SOA) we must swap the two. 4890 $host = $val; 4891 $val = $rr->name; 4892 my ($tmpcode,$tmpmsg) = _zone2cidr($val); 4893 if ($tmpcode eq 'FAIL') { 4894 # $val did not have a valid IP value. It's syntactically valid but WTF? 4895 $warnmsg .= "Suspect record '".$rr->string."' may not be imported correctly: $tmpmsg\n"; 4896 } else { 4897 # $val has a valid IP value. See if we can store it as that IP value. 4898 # Note we're enumerating do-nothing cases for clarity. 4899 ##enhance: this is where we will implement the more subtle variations on #53 4900 if ($type ne 'PTR' && $type ne 'NS' && $type ne 'CNAME' && $type ne 'TXT') { 4901 # case: the record is "weird" - ie, not a PTR, NS, CNAME, or TXT 4902 # $warnmsg .= "Discarding suspect record '".$rr->string."'\n" if $self->{strict} eq 'full'; 4903 } elsif ($type eq 'PTR' && $tmpmsg->masklen != 32 && $tmpmsg->masklen != 128) { 4904 # case: PTR with netblock value, not IP value 4905 # eg, "@ PTR foo" in zone f.e.e.b.d.a.e.d.ip6.arpa should not be 4906 # stored/displayed as dead:beef::/32 PTR foo 4907 4908 ## hrm. WTF is this case for, anyway? Needs testing to check the logic. 4909 # } elsif ( ($type eq 'PTR' || $type eq 'NS' || $type eq 'CNAME' || $type eq 'TXT') && 4910 # ($tmpmsg->masklen != $cidr->masklen) 4911 # ) { 4912 # # leave $val as-is if the record is "normal" (a PTR, NS, CNAME, or TXT), 4913 # # and the mask does not match the zone 4914 #$warnmsg .= "WTF case: $host $type $val\n"; 4915 # # $warnmsg .= "Discarding suspect record '".$rr->string."'\n" if $self->{strict} eq 'full'; 4916 4917 } else { 4918 $val = $tmpmsg; 4919 $val =~ s/\/(?:32|128)$//; # automagically converts $val back to a string before s/// 4920 #$val =~ s/:0$//g; 4921 } 4922 } 4923 # magic? convert * records to PTR template (not sure this actually makes sense) 4924 #if ($val =~ /^\*/) { 4925 # $val =~ s/\*\.//; 4926 # ($tmpcode,$tmpmsg) = _zone2cidr($val); 4927 # if ($tmpcode eq 'FAIL') { 4928 # $val = "*.$val"; 4929 # $warnmsg .= "Suspect record '".$rr->string."' may not be converted to PTR template correctly: $tmpmsg\n"; 4930 # } else { 4931 # $type = 'PTR template'; 4932 # $val = $tmpmsg; if $tmp 4933 # $val =~ s/\/(?:32|128)$//; # automagically converts $val back to a string before s/// 4934 # } 4935 #} 4936 } # non-SOA revrec $host/$val inversion and munging 4918 4937 4919 4938 my $logentry = "[AXFR ".($rev eq 'n' ? $zone : $cidr)."] "; … … 4983 5002 $logentry .= $logfrag; 4984 5003 } else { 4985 $logentry .= "Added record ' $host$type";5004 $logentry .= "Added record '".($rev eq 'y' ? $val : $host)." $type"; 4986 5005 $logentry .= " [distance $distance]" if $type eq 'MX'; 4987 5006 $logentry .= " [priority $distance] [weight $weight] [port $port]" if $type eq 'SRV'; 4988 $logentry .= " $val', TTL $ttl";5007 $logentry .= " ".($rev eq 'y' ? $host : $val)."', TTL $ttl"; 4989 5008 } 4990 5009 $self->_log(group_id => $group, domain_id => $domain_id, rdns_id => $rdns_id, entry => $logentry);
Note:
See TracChangeset
for help on using the changeset viewer.