- Timestamp:
- 04/29/14 17:27:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r625 r626 544 544 return ('FAIL',"A record must be a valid IPv4 address") 545 545 unless ${$args{val}} =~ /^\d+\.\d+\.\d+\.\d+$/; 546 $args{addr} = new NetAddr::IP ${$args{host}}; 546 547 return ('FAIL',"A record must be a valid IPv4 address") 547 548 unless $args{addr} && !$args{addr}->{isv6}; … … 867 868 868 869 # AAAA record 870 # Almost but not quite an exact duplicate of A record 869 871 sub _validate_28 { 870 872 my $self = shift; … … 873 875 my %args = @_; 874 876 875 return ('FAIL', 'Reverse zones cannot contain AAAA records') if $args{revrec} eq 'y'; 876 877 # Coerce all hostnames to end in ".DOMAIN" for group/default records, 878 # or the intended parent domain for live records. 879 my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id})); 880 ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/; 881 882 # Check IP is well-formed, and that it's a v6 address 883 return ('FAIL',"$typemap{${$args{rectype}}} record must be a valid IPv6 address") 877 # only for strict type restrictions 878 # return ('FAIL', 'Reverse zones cannot contain AAAA records') if $args{revrec} eq 'y'; 879 880 if ($args{revrec} eq 'y') { 881 # Get the revzone, so we can see if ${$args{val}} is in that zone 882 my $revzone = new NetAddr::IP $self->revName($args{id}, 'y'); 883 884 return ('FAIL', $errstr) if !$self->_inrev($args{val}, $revzone); 885 886 # ${$args{val}} is either a valid IP or a string ending with the .arpa zone name; 887 # now check if it's a well-formed FQDN 888 return ('FAIL', $errstr) if ! _check_hostname_form(${$args{val}}, ${$args{rectype}}, $args{defrec}, $args{revrec}) && 889 ${$args{val}} =~ /\.arpa$/; 890 891 # Check IP is well-formed, and that it's a v4 address 892 # Fail on "compact" IPv4 variants, because they are not consistent and predictable. 893 return ('FAIL',"AAAA record must be a valid IPv6 address") 894 unless ${$args{host}} =~ /^[a-fA-F0-9:]+$/; 895 $args{addr} = new NetAddr::IP ${$args{host}}; 896 return ('FAIL',"AAAA record must be a valid IPv6 address") 884 897 unless $args{addr} && $args{addr}->{isv6}; 885 # coerce IP/value to normalized form for storage 886 ${$args{val}} = $args{addr}->addr; 898 # coerce IP/value to normalized form for storage 899 ${$args{host}} = $args{addr}->addr; 900 901 # I'm just going to ignore the utterly barmy idea of an AAAA record in the *default* 902 # records for a reverse zone; it's bad enough to find one in funky legacy data. 903 904 } else { 905 # revrec ne 'y' 906 907 # Coerce all hostnames to end in ".DOMAIN" for group/default records, 908 # or the intended parent domain for live records. 909 my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id})); 910 ${$args{host}} =~ s/\.*$/\.$pname/ if (${$args{host}} ne '@' && ${$args{host}} !~ /$pname$/); 911 912 # Check if it's a proper formal .arpa name for an IP, and renormalize it to the IP 913 # value if so. Done mainly for symmetry with PTR/AAAA+PTR, and saves a conversion on export. 914 if (${$args{val}} =~ /\.arpa$/) { 915 my ($code,$tmp) = _zone2cidr(${$args{val}}); 916 if ($code ne 'FAIL') { 917 ${$args{val}} = $tmp->addr; 918 $args{addr} = $tmp; 919 } 920 } 921 # Check IP is well-formed, and that it's a v6 address 922 return ('FAIL',"AAAA record must be a valid IPv6 address") 923 unless ${$args{val}} =~ /^[a-fA-F0-9:]+$/; 924 $args{addr} = new NetAddr::IP ${$args{val}}; 925 return ('FAIL',"AAAA record must be a valid IPv6 address") 926 unless $args{addr} && $args{addr}->{isv6}; 927 # coerce IP/value to normalized form for storage 928 ${$args{val}} = $args{addr}->addr; 929 } 887 930 888 931 return ('OK','OK');
Note:
See TracChangeset
for help on using the changeset viewer.