Changeset 229
- Timestamp:
- 02/08/12 16:00:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r228 r229 241 241 # A record 242 242 sub _validate_1 { 243 my $dbh = shift; 244 my $defrec = shift; 245 my $revrec = shift; 246 my $id = shift; # parent (group_id for defrecs, rdns_id for reverse records, 247 # domain_id for domain records) 248 249 # These next two should be references, so we can pass them back altered. Yes, we really want to do that. 250 my $host = shift; 251 my $val = shift; 252 my $addr = shift; 253 254 return ('FAIL', 'Reverse zones cannot contain A records') if $revrec eq 'y'; 255 256 # Coerce all hostnames to end in ".DOMAIN" for group/default records, 257 # or the intended parent domain for live records. 258 my $pname = ($defrec eq 'y' ? 'DOMAIN' : domainName($dbh,$id)); 259 $$host =~ s/\.*$/\.$pname/ if $$host !~ /$pname$/; 260 261 # Check IP is well-formed, and that it's a v4 address 262 return ('FAIL',"A record must be a valid IPv4 address") 263 unless $addr && !$addr->{isv6}; 264 # coerce IP/value to normalized form for storage 265 $$val = $addr->addr; 266 243 267 return ('OK','OK'); 244 268 } # done A record … … 281 305 # AAAA record 282 306 sub _validate_28 { 307 my $dbh = shift; 308 my $defrec = shift; 309 my $revrec = shift; 310 my $id = shift; # parent (group_id for defrecs, rdns_id for reverse records, 311 # domain_id for domain records) 312 313 # These next two should be references, so we can pass them back altered. Yes, we really want to do that. 314 my $host = shift; 315 my $val = shift; 316 my $addr = shift; 317 318 return ('FAIL', 'Reverse zones cannot contain AAAA records') if $revrec eq 'y'; 319 320 # Coerce all hostnames to end in ".DOMAIN" for group/default records, 321 # or the intended parent domain for live records. 322 my $pname = ($defrec eq 'y' ? 'DOMAIN' : domainName($dbh,$id)); 323 $$host =~ s/\.*$/\.$pname/ if $$host !~ /$pname$/; 324 325 # Check IP is well-formed, and that it's a v6 address 326 return ('FAIL',"AAAA record must be a valid IPv6 address") 327 unless $addr && $addr->{isv6}; 328 # coerce IP/value to normalized form for storage 329 $$val = $addr->addr; 330 283 331 return ('OK','OK'); 284 332 } # done AAAA record
Note:
See TracChangeset
for help on using the changeset viewer.