Suppress displaying unsupported records so that DNSSEC (RRSIG records) are no issue

(closes #2)
This commit is contained in:
2019-08-01 15:34:39 +02:00
parent 348b8d9a29
commit 47a697d458

View File

@@ -3,10 +3,10 @@
# #
# dyndns.pl - CGI-BIN script to handle Dynamic DNS updates through http # dyndns.pl - CGI-BIN script to handle Dynamic DNS updates through http
# #
# Version 1.0, latest version, documentation and bugtracker available at: # Version 1.1, latest version, documentation and bugtracker available at:
# https://gitlab.lindenaar.net/scripts/dyndns # https://gitlab.lindenaar.net/scripts/dyndns
# #
# Copyright (c) 2013 Frederik Lindenaar # Copyright (c) 2013 - 2019 Frederik Lindenaar
# #
# This script is free software: you can redistribute and/or modify it under the # This script is free software: you can redistribute and/or modify it under the
# terms of version 3 of the GNU General Public License as published by the Free # terms of version 3 of the GNU General Public License as published by the Free
@@ -104,7 +104,7 @@ sub DNS_decode_rr($) {
return $rr->nsdname if($rr->type eq 'NS'); return $rr->nsdname if($rr->type eq 'NS');
return $rr->exchange.' (priority '.$rr->preference.')' if($rr->type eq 'MX'); return $rr->exchange.' (priority '.$rr->preference.')' if($rr->type eq 'MX');
return $rr->cpu.', '.$rr->os if($rr->type eq 'HINFO'); return $rr->cpu.', '.$rr->os if($rr->type eq 'HINFO');
die "No support for $rr->type in DNS_get()!, aborted!"; die "No support for $rr " . $rr->type . " in DNS_decode_rr()!, aborted!";
} }
# Retrieve a single value from the DNS server of a given type or everything # Retrieve a single value from the DNS server of a given type or everything
@@ -191,13 +191,13 @@ sub DNS_Update($$$$$$$) {
if(my $response = getResolver()->send($dnsupdate)) { if(my $response = getResolver()->send($dnsupdate)) {
$debugmessage .= $response->string . "\n" if($debug); $debugmessage .= $response->string . "\n" if($debug);
if ($response->header->rcode eq 'NOERROR') { if ($response->header->rcode eq 'NOERROR') {
return (200, "OK - DNS update for $dnshost succeeded: " . return (200, "OK - DNS update for $dnshost succeeded: " .
$response->header->rcode . $debugmessage); $response->header->rcode . $debugmessage);
} else { } else {
# REFUSED, FORMERR # REFUSED, FORMERR
return (400, "ERROR - DNS update for $dnshost failed: " . return (400, "ERROR - DNS update for $dnshost failed: " .
$response->header->rcode . $debugmessage); $response->header->rcode . $debugmessage);
} }
} else { } else {
@@ -233,7 +233,7 @@ sub handle_update($$$$$$) {
# And report back the status # And report back the status
print $cgi->header(-status=>$statuscode, -type=>'text/plain'), $statusmessage; print $cgi->header(-status=>$statuscode, -type=>'text/plain'), $statusmessage;
} }
sub handle_expire($$$$$$) { sub handle_expire($$$$$$) {
my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_; my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_;
@@ -265,7 +265,7 @@ sub handle_expire($$$$$$) {
} }
} }
# And report back the status # And report back the status
print $cgi->header(-status=>200, -type=>'text/plain'), print $cgi->header(-status=>200, -type=>'text/plain'),
"OK - DNS expiry for $dnsdomain succeeded\n" . $debugmsg; "OK - DNS expiry for $dnsdomain succeeded\n" . $debugmsg;
} }
} }
@@ -285,9 +285,9 @@ sub handle_view($$$$$$) {
$cgi->th(['Field', 'Value']) $cgi->th(['Field', 'Value'])
]); ]);
foreach my $rr (DNS_get($dnshost)->answer) { foreach my $rr (DNS_get($dnshost)->answer) {
print $cgi->Tr([ if(my $label = $DNS_label{$rr->type}) {
$cgi->td([$DNS_label{$rr->type}, DNS_decode_rr($rr)]) print $cgi->Tr([ $cgi->td([$label, DNS_decode_rr($rr)]) ]);
]); }
} }
print $cgi->end_table(); print $cgi->end_table();
@@ -310,11 +310,11 @@ sub handle_list($$$$$$) {
my $lastname = ''; my $lastname = '';
foreach my $rr (getResolver->axfr($dnsdomain)) { foreach my $rr (getResolver->axfr($dnsdomain)) {
next if($rr->name eq $dnsdomain); next if($rr->name eq $dnsdomain);
print $cgi->Tr([ if(my $label = $DNS_label{$rr->type}) {
$cgi->td([ ($lastname cmp $rr->name) ? $rr->name : '', print $cgi->Tr([ $cgi->td([ ($lastname cmp $rr->name) ? $rr->name : '',
$DNS_label{$rr->type}, DNS_decode_rr($rr)]) $label, DNS_decode_rr($rr)]) ]);
]); $lastname = $rr->name;
$lastname = $rr->name; }
} }
print $cgi->end_table(); print $cgi->end_table();
@@ -329,9 +329,9 @@ my $CE = 'Configuration Error:';
die "$CE \$AuthMode '$AuthMode' is unsupported must be remote, static or both\n" die "$CE \$AuthMode '$AuthMode' is unsupported must be remote, static or both\n"
unless $AuthMode=~/remote|static|both/; unless $AuthMode=~/remote|static|both/;
die "$CE \$StaticSigner must be set for \$AuthMode '$AuthMode'\n" die "$CE \$StaticSigner must be set for \$AuthMode '$AuthMode'\n"
unless ($StaticSigner or $AuthMode eq 'remote'); unless ($StaticSigner or $AuthMode eq 'remote');
die "$CE \$StaticKey must be set for \$AuthMode '$AuthMode'\n" die "$CE \$StaticKey must be set for \$AuthMode '$AuthMode'\n"
unless ($StaticKey or $AuthMode eq 'remote'); unless ($StaticKey or $AuthMode eq 'remote');
die "$CE \$RequireRR is set to unsupported type '$RequireRR'\n" die "$CE \$RequireRR is set to unsupported type '$RequireRR'\n"
if ($RequireRR and not $DNS_label{$RequireRR}); if ($RequireRR and not $DNS_label{$RequireRR});
die "$CE \$ExpireAfter '$ExpireAfter' is not supported\n" die "$CE \$ExpireAfter '$ExpireAfter' is not supported\n"
@@ -374,3 +374,4 @@ if($host eq '' and $mode cmp 'list' and $mode cmp 'expire') {
-type=>'text/plain'), -type=>'text/plain'),
"ERROR - File Not Found / Invalid Mode '$mode' specified\n"; "ERROR - File Not Found / Invalid Mode '$mode' specified\n";
} }