Commit 47a697d45854146757414952d89402f57c4d742f

Authored by Frederik Lindenaar
1 parent 348b8d9a

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

(closes #2)
Showing 1 changed file with 19 additions and 18 deletions
dyndns.pl
@@ -3,10 +3,10 @@ @@ -3,10 +3,10 @@
3 # 3 #
4 # dyndns.pl - CGI-BIN script to handle Dynamic DNS updates through http 4 # dyndns.pl - CGI-BIN script to handle Dynamic DNS updates through http
5 # 5 #
6 -# Version 1.0, latest version, documentation and bugtracker available at: 6 +# Version 1.1, latest version, documentation and bugtracker available at:
7 # https://gitlab.lindenaar.net/scripts/dyndns 7 # https://gitlab.lindenaar.net/scripts/dyndns
8 # 8 #
9 -# Copyright (c) 2013 Frederik Lindenaar 9 +# Copyright (c) 2013 - 2019 Frederik Lindenaar
10 # 10 #
11 # This script is free software: you can redistribute and/or modify it under the 11 # This script is free software: you can redistribute and/or modify it under the
12 # terms of version 3 of the GNU General Public License as published by the Free 12 # terms of version 3 of the GNU General Public License as published by the Free
@@ -104,7 +104,7 @@ sub DNS_decode_rr($) { @@ -104,7 +104,7 @@ sub DNS_decode_rr($) {
104 return $rr->nsdname if($rr->type eq 'NS'); 104 return $rr->nsdname if($rr->type eq 'NS');
105 return $rr->exchange.' (priority '.$rr->preference.')' if($rr->type eq 'MX'); 105 return $rr->exchange.' (priority '.$rr->preference.')' if($rr->type eq 'MX');
106 return $rr->cpu.', '.$rr->os if($rr->type eq 'HINFO'); 106 return $rr->cpu.', '.$rr->os if($rr->type eq 'HINFO');
107 - die "No support for $rr->type in DNS_get()!, aborted!"; 107 + die "No support for $rr " . $rr->type . " in DNS_decode_rr()!, aborted!";
108 } 108 }
109 109
110 # Retrieve a single value from the DNS server of a given type or everything 110 # Retrieve a single value from the DNS server of a given type or everything
@@ -191,13 +191,13 @@ sub DNS_Update($$$$$$$) { @@ -191,13 +191,13 @@ sub DNS_Update($$$$$$$) {
191 191
192 if(my $response = getResolver()->send($dnsupdate)) { 192 if(my $response = getResolver()->send($dnsupdate)) {
193 $debugmessage .= $response->string . "\n" if($debug); 193 $debugmessage .= $response->string . "\n" if($debug);
194 - 194 +
195 if ($response->header->rcode eq 'NOERROR') { 195 if ($response->header->rcode eq 'NOERROR') {
196 - return (200, "OK - DNS update for $dnshost succeeded: " . 196 + return (200, "OK - DNS update for $dnshost succeeded: " .
197 $response->header->rcode . $debugmessage); 197 $response->header->rcode . $debugmessage);
198 } else { 198 } else {
199 # REFUSED, FORMERR 199 # REFUSED, FORMERR
200 - return (400, "ERROR - DNS update for $dnshost failed: " . 200 + return (400, "ERROR - DNS update for $dnshost failed: " .
201 $response->header->rcode . $debugmessage); 201 $response->header->rcode . $debugmessage);
202 } 202 }
203 } else { 203 } else {
@@ -233,7 +233,7 @@ sub handle_update($$$$$$) { @@ -233,7 +233,7 @@ sub handle_update($$$$$$) {
233 # And report back the status 233 # And report back the status
234 print $cgi->header(-status=>$statuscode, -type=>'text/plain'), $statusmessage; 234 print $cgi->header(-status=>$statuscode, -type=>'text/plain'), $statusmessage;
235 235
236 -} 236 +}
237 237
238 sub handle_expire($$$$$$) { 238 sub handle_expire($$$$$$) {
239 my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_; 239 my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_;
@@ -265,7 +265,7 @@ sub handle_expire($$$$$$) { @@ -265,7 +265,7 @@ sub handle_expire($$$$$$) {
265 } 265 }
266 } 266 }
267 # And report back the status 267 # And report back the status
268 - print $cgi->header(-status=>200, -type=>'text/plain'), 268 + print $cgi->header(-status=>200, -type=>'text/plain'),
269 "OK - DNS expiry for $dnsdomain succeeded\n" . $debugmsg; 269 "OK - DNS expiry for $dnsdomain succeeded\n" . $debugmsg;
270 } 270 }
271 } 271 }
@@ -285,9 +285,9 @@ sub handle_view($$$$$$) { @@ -285,9 +285,9 @@ sub handle_view($$$$$$) {
285 $cgi->th(['Field', 'Value']) 285 $cgi->th(['Field', 'Value'])
286 ]); 286 ]);
287 foreach my $rr (DNS_get($dnshost)->answer) { 287 foreach my $rr (DNS_get($dnshost)->answer) {
288 - print $cgi->Tr([  
289 - $cgi->td([$DNS_label{$rr->type}, DNS_decode_rr($rr)])  
290 - ]); 288 + if(my $label = $DNS_label{$rr->type}) {
  289 + print $cgi->Tr([ $cgi->td([$label, DNS_decode_rr($rr)]) ]);
  290 + }
291 } 291 }
292 print $cgi->end_table(); 292 print $cgi->end_table();
293 293
@@ -310,11 +310,11 @@ sub handle_list($$$$$$) { @@ -310,11 +310,11 @@ sub handle_list($$$$$$) {
310 my $lastname = ''; 310 my $lastname = '';
311 foreach my $rr (getResolver->axfr($dnsdomain)) { 311 foreach my $rr (getResolver->axfr($dnsdomain)) {
312 next if($rr->name eq $dnsdomain); 312 next if($rr->name eq $dnsdomain);
313 - print $cgi->Tr([  
314 - $cgi->td([ ($lastname cmp $rr->name) ? $rr->name : '',  
315 - $DNS_label{$rr->type}, DNS_decode_rr($rr)])  
316 - ]);  
317 - $lastname = $rr->name; 313 + if(my $label = $DNS_label{$rr->type}) {
  314 + print $cgi->Tr([ $cgi->td([ ($lastname cmp $rr->name) ? $rr->name : '',
  315 + $label, DNS_decode_rr($rr)]) ]);
  316 + $lastname = $rr->name;
  317 + }
318 } 318 }
319 print $cgi->end_table(); 319 print $cgi->end_table();
320 320
@@ -329,9 +329,9 @@ my $CE = 'Configuration Error:'; @@ -329,9 +329,9 @@ my $CE = 'Configuration Error:';
329 die "$CE \$AuthMode '$AuthMode' is unsupported must be remote, static or both\n" 329 die "$CE \$AuthMode '$AuthMode' is unsupported must be remote, static or both\n"
330 unless $AuthMode=~/remote|static|both/; 330 unless $AuthMode=~/remote|static|both/;
331 die "$CE \$StaticSigner must be set for \$AuthMode '$AuthMode'\n" 331 die "$CE \$StaticSigner must be set for \$AuthMode '$AuthMode'\n"
332 - unless ($StaticSigner or $AuthMode eq 'remote'); 332 + unless ($StaticSigner or $AuthMode eq 'remote');
333 die "$CE \$StaticKey must be set for \$AuthMode '$AuthMode'\n" 333 die "$CE \$StaticKey must be set for \$AuthMode '$AuthMode'\n"
334 - unless ($StaticKey or $AuthMode eq 'remote'); 334 + unless ($StaticKey or $AuthMode eq 'remote');
335 die "$CE \$RequireRR is set to unsupported type '$RequireRR'\n" 335 die "$CE \$RequireRR is set to unsupported type '$RequireRR'\n"
336 if ($RequireRR and not $DNS_label{$RequireRR}); 336 if ($RequireRR and not $DNS_label{$RequireRR});
337 die "$CE \$ExpireAfter '$ExpireAfter' is not supported\n" 337 die "$CE \$ExpireAfter '$ExpireAfter' is not supported\n"
@@ -374,3 +374,4 @@ if($host eq '' and $mode cmp 'list' and $mode cmp 'expire') { @@ -374,3 +374,4 @@ if($host eq '' and $mode cmp 'list' and $mode cmp 'expire') {
374 -type=>'text/plain'), 374 -type=>'text/plain'),
375 "ERROR - File Not Found / Invalid Mode '$mode' specified\n"; 375 "ERROR - File Not Found / Invalid Mode '$mode' specified\n";
376 } 376 }
  377 +