- Timestamp:
- 01/20/12 16:28:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r222 r223 1379 1379 1380 1380 # Validation 1381 my $addr = NetAddr::IP->new($val); 1381 1382 if ($rectype == $reverse_typemap{A}) { 1382 return ( "FAIL", "IPv4 addresses must be in the format n.n.n.n")1383 unless $ val =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;1383 return ('FAIL',$typemap{$rectype}." record must be a valid IPv4 address") 1384 unless $addr && !$addr->{isv6}; 1384 1385 } 1385 1386 if ($rectype == $reverse_typemap{AAAA}) { 1386 return ("FAIL", "IPv6 addresses must be in the format h:h:h::h") 1387 unless $val =~ /^[a-fA-F0-9:]+$/ 1388 } 1389 if ($rectype == $reverse_typemap{A} or $rectype == $reverse_typemap{AAAA}) { 1390 my $tmpip = new NetAddr::IP $val or 1391 return ("FAIL", "Address must be a valid IP address"); 1387 return ('FAIL',$typemap{$rectype}." record must be a valid IPv6 address") 1388 unless $addr && $addr->{isv6}; 1392 1389 } 1393 1390 … … 1472 1469 if ($type == $reverse_typemap{MX} || $type == $reverse_typemap{SRV}) { 1473 1470 $dist = shift; 1471 $dist =~ s/\s+//g; 1474 1472 return ('FAIL',"MX or SRV requires distance") if !defined($dist); 1473 return ('FAIL', "Distance must be numeric") unless $dist =~ /^\d+$/; 1475 1474 if ($type == $reverse_typemap{SRV}) { 1476 1475 $weight = shift; 1476 $weight =~ s/\s+//g; 1477 1477 return ('FAIL',"SRV requires weight") if !defined($weight); 1478 return ('FAIL',"Weight must be numeric") unless $weight =~ /^\d+$/; 1478 1479 $port = shift; 1480 $port =~ s/\s+//g; 1479 1481 return ('FAIL',"SRV requires port") if !defined($port); 1482 return ('FAIL',"Port must be numeric") unless $port =~ /^\d+$/; 1480 1483 } 1481 1484 } 1485 1486 # Enforce IP addresses on A and AAAA types 1487 my $addr = NetAddr::IP->new($val); 1488 if ($type == $reverse_typemap{A}) { 1489 return ('FAIL',$typemap{$type}." record must be a valid IPv4 address") 1490 unless $addr && !$addr->{isv6}; 1491 } 1492 if ($type == $reverse_typemap{AAAA}) { 1493 return ('FAIL',$typemap{$type}." record must be a valid IPv6 address") 1494 unless $addr && $addr->{isv6}; 1495 } 1496 1497 # hmm.. this might work. except possibly for something pointing to "deadbeef.ca". <g> 1498 # if ($type == $reverse_typemap{NS} || $type == $reverse_typemap{MX} || $type == $reverse_typemap{SRV}) { 1499 # if ($val =~ /^\s*[\da-f:.]+\s*$/) { 1500 # return ('FAIL',"$val is not a valid IP address") if !$addr; 1501 # } 1502 # } 1482 1503 1483 1504 local $dbh->{AutoCommit} = 0;
Note:
See TracChangeset
for help on using the changeset viewer.