Run as daemon
This commit is contained in:
parent
767af557b1
commit
20222430c4
65
ns.pl
65
ns.pl
@ -1,22 +1,27 @@
|
|||||||
#!/usr/bin/perl -Tw
|
#!/usr/local/bin/perl -Tw
|
||||||
# $Id: ns.pl,v 1.6 2005/10/11 11:44:28 olaf Exp $
|
use Proc::Daemon;
|
||||||
|
|
||||||
use Net::DNS;
|
use Net::DNS;
|
||||||
use Net::DNS::Nameserver;
|
use Net::DNS::Nameserver;
|
||||||
use Net::DNS::SEC;
|
use Net::DNS::SEC;
|
||||||
|
use File::Slurp;
|
||||||
use strict;
|
use strict;
|
||||||
use Math::RPN;
|
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 $rpdomain=lc "rp.secret-wg.org.";
|
||||||
my $rp_ns_name=lc "ns.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_address="185.49.141.200";
|
||||||
my $rp_ns_bind_address="213.154.224.43";
|
my $rp_ns_bind_address="185.49.141.200";
|
||||||
my $rp_ns_port="53";
|
my $rp_ns_port="53";
|
||||||
my $reply_ttl=10;
|
my $reply_ttl=10;
|
||||||
my $sig_val=60;
|
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 $www_address="193.0.4.49";
|
||||||
|
|
||||||
my $timeout=$sig_val*60-3*$reply_ttl; # resigns itself after so often
|
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 version ".$Net::DNS::VERSION."\n";
|
||||||
print "Using Net::DNS::SEC version ".$Net::DNS::SEC::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;
|
my %sigargs;
|
||||||
$sigargs{"ttl"} = $reply_ttl;
|
$sigargs{"ttl"} = $reply_ttl;
|
||||||
$sigargs{"sigval"}= $sig_val;
|
$sigargs{"sigval"}= $sig_val;
|
||||||
@ -37,6 +57,9 @@ use Tie::Syslog;
|
|||||||
my $x=tie *STDOUT, 'Tie::Syslog', 'daemon.info','RPNS','pid','unix';
|
my $x=tie *STDOUT, 'Tie::Syslog', 'daemon.info','RPNS','pid','unix';
|
||||||
|
|
||||||
|
|
||||||
|
my $daemon = Proc::Daemon->new();
|
||||||
|
my $childPID= $daemon->Init;
|
||||||
|
|
||||||
print "Restarting the server";
|
print "Restarting the server";
|
||||||
resign();
|
resign();
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
@ -58,18 +81,18 @@ $SIG{ALRM} = sub { print "alarm after $timeout seconds (to regenerate SIGs)\n";
|
|||||||
|
|
||||||
sub resign {
|
sub resign {
|
||||||
|
|
||||||
|
|
||||||
@keyRR= (
|
@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,
|
$private,
|
||||||
%sigargs,
|
%sigargs,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@versionRR=(
|
@versionRR=(
|
||||||
Net::DNS::RR->new('version.bind 0 CH TXT '.$versionstring),
|
Net::DNS::RR->new('version.bind 0 CH TXT '.$versionstring),
|
||||||
Net::DNS::RR->new('version.bind 0 CH TXT "http://bert.secret-wg.org/Tools tool 3"')
|
Net::DNS::RR->new('version.bind 0 CH TXT "http://bert.secret-wg.org/Tools tool 3"')
|
||||||
@ -421,15 +444,17 @@ sub reply_handler {
|
|||||||
return ($rcode, \@ans, \@auth, \@add);
|
return ($rcode, \@ans, \@auth, \@add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unless ( $childPID ) {
|
||||||
|
|
||||||
if ($ns) {
|
|
||||||
$ns->main_loop;
|
if ($ns) {
|
||||||
}
|
$ns->main_loop;
|
||||||
else {
|
}
|
||||||
die "couldn't create nameserver object\n";
|
else {
|
||||||
}
|
die "couldn't create nameserver object\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user