From d583a5d3c0647488bac7b7a33d319fd1a85c05b3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 11 Sep 2010 17:02:59 +0000 Subject: [PATCH] dns updates from Erik L: add ttl support, add check for SRV and finish allowing additional rectypes, allow forward slashes for RFC2317 classless in-arpa delegation, RT#8933 --- FS/FS/Schema.pm | 1 + FS/FS/domain_record.pm | 27 +++++++++++++++++++++------ FS/FS/part_export/domain_sql.pm | 3 +++ FS/FS/svc_domain.pm | 6 ++---- httemplate/view/svc_domain/dns.html | 6 +++++- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index cc6438ab6..459dcabd6 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1795,6 +1795,7 @@ sub tables_hashref { 'recaf', 'char', '', 2, '', '', 'rectype', 'varchar', '', 5, '', '', 'recdata', 'varchar', '', 255, '', '', + 'ttl', 'int', 'NULL', '', '', '', ], 'primary_key' => 'recnum', 'unique' => [], diff --git a/FS/FS/domain_record.pm b/FS/FS/domain_record.pm index e7e9f70b7..9f1eb5318 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 @@ -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; diff --git a/FS/FS/part_export/domain_sql.pm b/FS/FS/part_export/domain_sql.pm index 0ce1b16e3..30103385b 100644 --- a/FS/FS/part_export/domain_sql.pm +++ b/FS/FS/part_export/domain_sql.pm @@ -99,6 +99,7 @@ sub _export_replace { my %schema = $self->_schema_map; my %static = $self->_static_map; + #my %map = (%schema, %static); my @primary_key = (); if ( $self->option('primary_key') =~ /,/ ) { @@ -107,6 +108,7 @@ sub _export_replace { push @primary_key, $old->$keymap(); } } else { + my %map = (%schema, %static); my $keymap = $map{$self->option('primary_key')}; push @primary_key, $old->$keymap(); } @@ -135,6 +137,7 @@ sub _export_delete { my %schema = $self->_schema_map; my %static = $self->_static_map; + my %map = (%schema, %static); my %primary_key = (); if ( $self->option('primary_key') =~ /,/ ) { diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index 7d527e5be..dde6d3c2c 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -303,9 +303,6 @@ defined. An FS::cust_svc record will be created and inserted. The additional field I should be set to I for new domains, I for transfers, or I for no action (registered elsewhere). -A registration or transfer email will be submitted unless -$FS::svc_domain::whois_hack is true. - The additional field I can be used to manually set the admin contact email address on this email. Otherwise, the svc_acct records for this package (see L) are searched. If there is exactly one svc_acct record @@ -565,7 +562,7 @@ sub check { $recref->{domain} = "$1.$2"; $recref->{suffix} ||= $2; # hmmmmmmmm. - } elsif ( $whois_hack && $recref->{domain} =~ /^([\w\-\.]+)\.(\w+)$/ ) { + } elsif ( $whois_hack && $recref->{domain} =~ /^([\w\-\.\/]+)\.(\w+)$/ ) { $recref->{domain} = "$1.$2"; # need to match a list of suffixes - no guarantee they're top-level.. # http://wiki.mozilla.org/TLD_List @@ -623,6 +620,7 @@ sub domain_record { 'A' => 5, 'TXT' => 6, 'PTR' => 7, + 'SRV' => 8, ); my %sort = ( diff --git a/httemplate/view/svc_domain/dns.html b/httemplate/view/svc_domain/dns.html index a73a27e57..6380db7b2 100644 --- a/httemplate/view/svc_domain/dns.html +++ b/httemplate/view/svc_domain/dns.html @@ -26,6 +26,7 @@ Zone Type Data + TTL % foreach my $domain_record ( @records ) { @@ -37,7 +38,9 @@ <% $domain_record->reczone %> <% $type %> - <% $domain_record->recdata %> + <% $domain_record->recdata %> + <% $domain_record->ttl %> + % unless ( $domain_record->rectype eq 'SOA' % || ! $FS::CurrentUser::CurrentUser->access_right('Edit domain nameservice') @@ -80,6 +83,7 @@ % } + -- 2.11.0