Implement CAA record
Docs say caa_property but implementation uses caa_tag (support both) Ref: #3
This commit is contained in:
		| @@ -33,7 +33,7 @@ sub _notice { | |||||||
| my %supported_types = ( | my %supported_types = ( | ||||||
|     A => "yes", |     A => "yes", | ||||||
|     AAAA => "yes", |     AAAA => "yes", | ||||||
|     CAA => "not yet implemented", |     CAA => "yes", | ||||||
|     CNAME => "yes", |     CNAME => "yes", | ||||||
|     DNAME => "yes", |     DNAME => "yes", | ||||||
|     MX => "yes", |     MX => "yes", | ||||||
| @@ -127,6 +127,12 @@ sub format_record($$$$) { | |||||||
|         $record->{srv_weight} = $weight; |         $record->{srv_weight} = $weight; | ||||||
|         $record->{srv_port} = $port; |         $record->{srv_port} = $port; | ||||||
|         $record->{data} = $data; |         $record->{data} = $data; | ||||||
|  |     } elsif ($type eq 'CAA') { | ||||||
|  |         my ($flags, $property, $data) = split(/\s+/, $value); | ||||||
|  |         $record->{caa_flags} = $flags; | ||||||
|  |         $record->{caa_property} = $property; | ||||||
|  |         $record->{caa_tag} = $property; | ||||||
|  |         $record->{data} = $data; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return $record; |     return $record; | ||||||
| @@ -143,6 +149,12 @@ sub reformat_data($$) { | |||||||
|             $data->{srv_port}, |             $data->{srv_port}, | ||||||
|             $data->{data} |             $data->{data} | ||||||
|         ); |         ); | ||||||
|  |     } elsif($type eq 'CAA') { | ||||||
|  |         return sprintf('%d %s %s', | ||||||
|  |             $data->{caa_flags}, | ||||||
|  |             $data->{caa_property} || $data->{caa_tag}, | ||||||
|  |             $data->{data} | ||||||
|  |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return $data->{data}; |     return $data->{data}; | ||||||
| @@ -177,6 +189,7 @@ sub check_and_update_record($$$$$) { | |||||||
|         # Create new record |         # Create new record | ||||||
|         my $new = format_record($zone, $type, $host, $value); |         my $new = format_record($zone, $type, $host, $value); | ||||||
|         _notice("Created new record: %s %s %s", $host, $type, $value); |         _notice("Created new record: %s %s %s", $host, $type, $value); | ||||||
|  |         _debug($new); | ||||||
|         my $res = $ua->post( |         my $res = $ua->post( | ||||||
|             $url, |             $url, | ||||||
|             "Content-Type" => "application/json", |             "Content-Type" => "application/json", | ||||||
| @@ -231,6 +244,7 @@ foreach my $z (keys %{$in->[0]->{zones}}) { | |||||||
|         unless (defined $seen{$record}) { |         unless (defined $seen{$record}) { | ||||||
|             # _info("Considering %s %s", $record->{host}, $record->{type}); |             # _info("Considering %s %s", $record->{host}, $record->{type}); | ||||||
|             my $skip; |             my $skip; | ||||||
|  |             $skip = 1 if is_unsupported($record->{type}); | ||||||
|             if ($in->[0]->{ignore}->{$z}->{$record->{host}}) { |             if ($in->[0]->{ignore}->{$z}->{$record->{host}}) { | ||||||
|                 # check if type is specified |                 # check if type is specified | ||||||
|                 if(keys %{$in->[0]->{ignore}->{$z}->{$record->{host}}}) { |                 if(keys %{$in->[0]->{ignore}->{$z}->{$record->{host}}}) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user