diff --git a/ns.pl b/ns.pl index a5df771..40ff658 100755 --- a/ns.pl +++ b/ns.pl @@ -1,22 +1,27 @@ -#!/usr/bin/perl -Tw -# $Id: ns.pl,v 1.6 2005/10/11 11:44:28 olaf Exp $ - +#!/usr/local/bin/perl -Tw +use Proc::Daemon; use Net::DNS; use Net::DNS::Nameserver; use Net::DNS::SEC; - +use File::Slurp; use strict; use Math::RPN; -my $versionstring='"BSRPDNSC version 0.2.4"'; +my $versionstring='"BSRPDNSC version 0.2.5"'; + + + my $rpdomain=lc "rp.secret-wg.org."; my $rp_ns_name=lc "ns.rp.secret-wg.org"; -my $rp_ns_address="213.154.224.43"; -my $rp_ns_bind_address="213.154.224.43"; +my $rp_ns_address="185.49.141.200"; +my $rp_ns_bind_address="185.49.141.200"; my $rp_ns_port="53"; my $reply_ttl=10; my $sig_val=60; -my $keypath="/home/olaf/RPNS/Krp.secret-wg.org.+001+27900.private"; +my $keypath="/home/olaf/RPNS/Krp.secret-wg.org.+005+27900.private"; +my $pubpath="/home/olaf/RPNS/Krp.secret-wg.org.+005+27900.key"; + + my $www_address="193.0.4.49"; my $timeout=$sig_val*60-3*$reply_ttl; # resigns itself after so often @@ -24,6 +29,21 @@ my $timeout=$sig_val*60-3*$reply_ttl; # resigns itself after so often print "Using Net::DNS version ".$Net::DNS::VERSION."\n"; print "Using Net::DNS::SEC version ".$Net::DNS::SEC::VERSION."\n"; + +my $dnskeystring= read_file($pubpath); +# File should contain one key per line (not tested) + +my $keyRR = Net::DNS::RR->new( $dnskeystring); +my $ds = Net::DNS::RR::DS->create( + $keyRR, + digtype => 'SHA256', + ttl => 3600 + ); +print "DS record for parent: \n " .$ds->string() ."\n"; + + + + my %sigargs; $sigargs{"ttl"} = $reply_ttl; $sigargs{"sigval"}= $sig_val; @@ -37,6 +57,9 @@ use Tie::Syslog; my $x=tie *STDOUT, 'Tie::Syslog', 'daemon.info','RPNS','pid','unix'; +my $daemon = Proc::Daemon->new(); +my $childPID= $daemon->Init; + print "Restarting the server"; resign(); alarm $timeout; @@ -57,18 +80,18 @@ $SIG{ALRM} = sub { print "alarm after $timeout seconds (to regenerate SIGs)\n"; sub resign { - @keyRR= ( - Net::DNS::RR->new( "rp.secret-wg.org. 10 IN DNSKEY 256 3 1 AQPkQwQiwlTBYvK8xOx18oOqSpLjuTDmDlfcVUd2Oy5ZWyG2PxN+jDW3 0PQo9Tme337mJfG4s/1m72FjK7xHbPyX") - ) + $keyRR + ) ; - $keySIGRR= create Net::DNS::RR::RRSIG(\@keyRR, + $keySIGRR= create Net::DNS::RR::RRSIG(\@keyRR, $private, %sigargs, ); + @versionRR=( Net::DNS::RR->new('version.bind 0 CH TXT '.$versionstring), @@ -421,15 +444,17 @@ sub reply_handler { return ($rcode, \@ans, \@auth, \@add); } - -if ($ns) { - $ns->main_loop; - } - else { - die "couldn't create nameserver object\n"; - } - - +unless ( $childPID ) { + + + if ($ns) { + $ns->main_loop; + } + else { + die "couldn't create nameserver object\n"; + } + +}