adding dnssec support

This commit is contained in:
2020-11-21 16:11:41 -05:00
parent 8d05bd540c
commit ab0a52c30e
4 changed files with 36 additions and 7 deletions

29
DDNS.pm
View File

@ -8,7 +8,7 @@ use Memoize;
memoize('_gethosts');
our $VERSION = '0.2';
our $VERSION = '0.3';
sub new {
my $me = shift;
@ -24,7 +24,7 @@ sub _validateTypeOrDie {
my ($t) = @_;
die "Invalid type"
unless ($t =~ /^_(vhosts|pureslave|custom)$/);
unless ($t =~ /^_(vhosts|pureslave|custom|dnssec)$/);
}
sub _fqdn {
@ -127,6 +127,7 @@ sub _gethosts {
# Find the type of domin that $dom is. If we don't find it, return
# undef. (The domain $dom ends in a dot; the DNS info we find won't;
# hence the concat of the extra "." after the lc.)
# (Skip _dnssec records in this check.)
sub type {
my ($this, $dom) = @_;
@ -135,7 +136,8 @@ sub type {
my @vh = $this->get();
foreach my $i (@vh) {
if (lc($i->{zone})."." eq lc($dom)) {
return $i->{type};
return $i->{type}
unless ($i->{type} eq '_dnssec');
}
}
@ -148,8 +150,10 @@ sub add {
_validateOrDie($dom);
my $fqdn = _fqdn($dom, $type);
if (my $type = $this->type($dom)) {
die "Domain $dom already exists [of type $type]";
if (my $existingtype = $this->type($dom)) {
die "Domain $dom already exists [of type $existingtype]"
unless ($existingtype eq '_dnssec' ||
$type eq '_dnssec');
}
$this->__docmd("update add $fqdn 60 TXT $master");
@ -180,4 +184,19 @@ sub cleanup {
system("/usr/local/bin/sync-master-vhosts");
}
sub is_dnssec {
my ($this, $dom) = @_;
$dom =~ s/^(.+)\.$/$1/; # remove trailing dot
my @h = $this->_gethosts('_dnssec');
foreach my $i (@h) {
if (lc($i->{zone}) eq $dom) {
return 1;
}
}
return 0;
}
1;