X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdomain_record.pm;h=8d767d510241d96e8f329e50be43357330ab9cf1;hb=b49c1bd5510a5f10b05bffacc6cc8b6a1b2153e8;hp=3c65a1a05dd5543852fe5c7f6b7f239e8f618c27;hpb=4750962f384c8061f4b5c78201a449b1f41c56c7;p=freeside.git diff --git a/FS/FS/domain_record.pm b/FS/FS/domain_record.pm index 3c65a1a05..8d767d510 100644 --- a/FS/FS/domain_record.pm +++ b/FS/FS/domain_record.pm @@ -1,7 +1,7 @@ package FS::domain_record; use strict; -use vars qw( @ISA $noserial_hack $DEBUG ); +use vars qw( @ISA $noserial_hack $DEBUG $me ); use FS::Conf; #use FS::Record qw( qsearch qsearchs ); use FS::Record qw( qsearchs dbh ); @@ -11,6 +11,7 @@ use FS::svc_www; @ISA = qw(FS::Record); $DEBUG = 0; +$me = '[FS::domain_record]'; =head1 NAME @@ -51,6 +52,8 @@ supported: =item recdata - data for this entry +=item ttl - time to live + =back =head1 METHODS @@ -59,7 +62,7 @@ supported: =item new HASHREF -Creates a new entry. To add the example to the database, see L<"insert">. +Creates a new entry. To add the entry to the database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the I method. @@ -229,7 +232,7 @@ sub replace { =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid entry. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -265,10 +268,12 @@ sub check { $self->recaf =~ /^(IN)$/ or return "Illegal recaf: ". $self->recaf; $self->recaf($1); - $self->rectype =~ /^(SOA|NS|MX|A|PTR|CNAME|TXT|_mstr)$/ - or return "Illegal rectype (only SOA NS MX A PTR CNAME TXT recognized): ". - $self->rectype; - $self->rectype($1); + $self->ttl =~ /^([0-9]{0,6})$/ or return "Illegal ttl: ". $self->ttl; + $self->ttl($1); + + my %rectypes = map { $_=>1 } ( @{ $self->rectypes }, '_mstr' ); + return 'Illegal rectype: '. $self->rectype + unless exists $rectypes{$self->rectype} && $rectypes{$self->rectype}; return "Illegal reczone for ". $self->rectype. ": ". $self->reczone if $self->rectype !~ /^MX$/i && $self->reczone =~ /\*/; @@ -291,6 +296,10 @@ sub check { $self->recdata =~ /^((\d{1,3}\.){3}\d{1,3})$/ or return "Illegal data for A record: ". $self->recdata; $self->recdata($1); + } elsif ( $self->rectype eq 'AAAA' ) { + $self->recdata =~ /^([\da-z:]+)$/ + or return "Illegal data for AAAA record: ". $self->recdata; + $self->recdata($1); } elsif ( $self->rectype eq 'PTR' ) { if ( $conf->exists('zone-underscore') ) { $self->recdata =~ /^([a-z0-9_\.\-]+)$/i @@ -312,11 +321,17 @@ sub check { $self->recdata('"'. $self->recdata. '"'); #? } # or return "Illegal data for TXT record: ". $self->recdata; + } elsif ( $self->rectype eq 'SRV' ) { + $self->recdata =~ /^(\d+)\s+(\d+)\s+(\d+)\s+([a-z0-9\.\-]+)$/i + or return "Illegal data for SRV record: ". $self->recdata; + $self->recdata("$1 $2 $3 $4"); } elsif ( $self->rectype eq '_mstr' ) { $self->recdata =~ /^((\d{1,3}\.){3}\d{1,3})$/ or return "Illegal data for _master pseudo-record: ". $self->recdata; } else { - die "ack!"; + warn "$me no specific check for ". $self->rectype. " records yet"; + $error = $self->ut_text('recdata'); + return $error if $error; } $self->SUPER::check; @@ -419,6 +434,18 @@ sub reverse_record { or new FS::domain_record { %hash, 'recdata' => $self->zone.'.' }; } +=item rectypes + +=cut +#http://en.wikipedia.org/wiki/List_of_DNS_record_types +#DHCID? other things? +sub rectypes { + [ qw(SOA A AAAA CNAME MX NS PTR SPF SRV TXT), #most common types + #qw(DNAME), #uncommon types + qw(DLV DNSKEY DS NSEC NSEC3 NSEC3PARAM RRSIG), #DNSSEC types + ]; +} + =back =head1 BUGS