From 4556e8641919997ee102d066dd173a15da3bdff5 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 17 Jul 2002 17:53:44 +0000 Subject: getkeyconf command takes optional addresses getkeyconf config option was replaced by getkeyconf_interval and getkeyconf_every_nth_time Not all requests are sent at the same time Scheduler takes argument to pass to functions --- Echolot/Commands.pm | 4 ++-- Echolot/Conf.pm | 51 +++++++++++++++++++++++++++++++++++---------------- Echolot/Config.pm | 5 +++-- Echolot/Pinger.pm | 7 +++---- Echolot/Scheduler.pm | 18 ++++++++++++------ NEWS | 5 +++++ TODO | 3 +-- doc/pingd.conf.pod | 16 +++++++++++----- pingd | 29 +++++++++++++++++++++++------ 9 files changed, 95 insertions(+), 43 deletions(-) diff --git a/Echolot/Commands.pm b/Echolot/Commands.pm index e502a91..c0a6b59 100644 --- a/Echolot/Commands.pm +++ b/Echolot/Commands.pm @@ -1,7 +1,7 @@ package Echolot::Commands; # (c) 2002 Peter Palfrader -# $Id: Commands.pm,v 1.8 2002/07/16 02:59:17 weasel Exp $ +# $Id: Commands.pm,v 1.9 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -68,7 +68,7 @@ sub processCommands($) { } elsif ($command eq 'set') { Echolot::Globals::get()->{'storage'}->set_stuff(@args); } elsif ($command eq 'getkeyconf') { - Echolot::Globals::get()->{'scheduler'}->schedule('getkeyconf', time() ); + Echolot::Globals::get()->{'scheduler'}->schedule('getkeyconf', time(), \@args ); } elsif ($command eq 'buildstats') { Echolot::Globals::get()->{'scheduler'}->schedule('buildstats', time() ); } elsif ($command eq 'buildkeys') { diff --git a/Echolot/Conf.pm b/Echolot/Conf.pm index e1b7098..2dc1b53 100644 --- a/Echolot/Conf.pm +++ b/Echolot/Conf.pm @@ -1,7 +1,7 @@ package Echolot::Conf; # (c) 2002 Peter Palfrader -# $Id: Conf.pm,v 1.19 2002/07/17 16:50:04 weasel Exp $ +# $Id: Conf.pm,v 1.20 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -37,31 +37,50 @@ sub is_not_a_remailer($) { }; }; -sub send_requests() { +sub send_requests(;$) { + my ($which) = @_; + + $which = '' unless defined $which; + + my $call_intervall = Echolot::Config::get()->{'getkeyconf_interval'}; + my $send_every_n_calls = Echolot::Config::get()->{'getkeyconf_every_nth_time'}; + + my $timemod = (time() / $call_intervall); + my $this_call_id = $timemod % $send_every_n_calls; + Echolot::Globals::get()->{'storage'}->delay_commit(); + for my $remailer (Echolot::Globals::get()->{'storage'}->get_addresses()) { next unless ($remailer->{'status'} eq 'active'); next unless ($remailer->{'fetch'}); - print "Sending requests to ".$remailer->{'address'}."\n" - if Echolot::Config::get()->{'verbose'}; - - my $source_text = Echolot::Config::get()->{'remailerxxxtext'}; - my $template = HTML::Template->new( - scalarref => \$source_text, - strict => 0, - global_vars => 1 ); - $template->param ( address => $remailer->{'address'} ); - $template->param ( operator_address => Echolot::Config::get()->{'operator_address'} ); - my $body = $template->output(); + my $address = $remailer->{'address'}; for my $type (qw{conf key help stats adminkey}) { + + next if ($this_call_id ne (Echolot::Tools::makeShortNumHash($address.$type) % $send_every_n_calls) && + $which ne 'all' && + $which ne $address ); + + print "Sending $type requests to ".$address."\n" + if Echolot::Config::get()->{'verbose'}; + + my $source_text = Echolot::Config::get()->{'remailerxxxtext'}; + my $template = HTML::Template->new( + scalarref => \$source_text, + strict => 0, + global_vars => 1 ); + $template->param ( address => $address ); + $template->param ( operator_address => Echolot::Config::get()->{'operator_address'} ); + my $body = $template->output(); + Echolot::Tools::send_message( - 'To' => $remailer->{'address'}, + 'To' => $address, 'Subject' => 'remailer-'.$type, 'Token' => $type.'.'.$remailer->{'id'}, - 'Body' => $body) + 'Body' => $body); + + Echolot::Globals::get()->{'storage'}->decrease_ttl($address) if ($type eq 'conf'); }; - Echolot::Globals::get()->{'storage'}->decrease_ttl($remailer->{'address'}); }; Echolot::Globals::get()->{'storage'}->enable_commit(); }; diff --git a/Echolot/Config.pm b/Echolot/Config.pm index 412e3a8..e01461e 100644 --- a/Echolot/Config.pm +++ b/Echolot/Config.pm @@ -1,7 +1,7 @@ package Echolot::Config; # (c) 2002 Peter Palfrader -# $Id: Config.pm,v 1.28 2002/07/16 02:48:57 weasel Exp $ +# $Id: Config.pm,v 1.29 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -81,7 +81,8 @@ sub init($) { buildthesaurus => 60*60, # hourly commitprospectives => 8*60*60, # commit prospective addresses every 8 hours expire => 24*60*60, # daily - getkeyconf => 24*60*60, # daily + getkeyconf_interval => 5*60, # send out requests every 5 minutes + getkeyconf_every_nth_time => 24*60/5, # send out the same request to the same remailer once a day check_resurrection => 7*24*60*60, # weekly pinger_interval => 5*60, # send out pings every 5 minutes diff --git a/Echolot/Pinger.pm b/Echolot/Pinger.pm index 57efaa8..2ddf571 100644 --- a/Echolot/Pinger.pm +++ b/Echolot/Pinger.pm @@ -1,7 +1,7 @@ package Echolot::Pinger; # (c) 2002 Peter Palfrader -# $Id: Pinger.pm,v 1.16 2002/07/17 17:06:44 weasel Exp $ +# $Id: Pinger.pm,v 1.17 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -87,14 +87,13 @@ sub send_pings() { my $call_intervall = Echolot::Config::get()->{'pinger_interval'}; my $send_every_n_calls = Echolot::Config::get()->{'ping_every_nth_time'}; - my $now = time(); + my $timemod = (time() / $call_intervall); + my $this_call_id = $timemod % $send_every_n_calls; my @remailers = Echolot::Globals::get()->{'storage'}->get_remailers(); for my $remailer (@remailers) { next unless $remailer->{'pingit'}; my $address = $remailer->{'address'}; - my $timemod = ($now / $call_intervall); - my $this_call_id = $timemod % $send_every_n_calls; for my $type (Echolot::Globals::get()->{'storage'}->get_types($address)) { diff --git a/Echolot/Scheduler.pm b/Echolot/Scheduler.pm index 624a548..c122769 100644 --- a/Echolot/Scheduler.pm +++ b/Echolot/Scheduler.pm @@ -1,7 +1,7 @@ package Echolot::Scheduler; # (c) 2002 Peter Palfrader -# $Id: Scheduler.pm,v 1.9 2002/07/16 02:48:57 weasel Exp $ +# $Id: Scheduler.pm,v 1.10 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -20,7 +20,7 @@ the ping daemon. =cut use strict; -use Carp qw{cluck}; +use Carp qw{cluck confess}; my $ORDER = 1; @@ -47,6 +47,9 @@ it get's called 10 minutes after the hour. sub add($$$$$) { my ($self, $name, $interval, $offset, $what) = @_; + confess("Must not add zero intervall for job $name") + unless $interval; + if (defined $self->{'tasks'}->{$name}) { @{ $self->{'schedule'} } = grep { $_->{'name'} ne $name } @{ $self->{'schedule'} }; }; @@ -70,8 +73,8 @@ Schedule execution of I for I. If I is not given it is calculate from I and I passed to B. =cut -sub schedule($$;$) { - my ($self, $name, $for) = @_; +sub schedule($$;$$) { + my ($self, $name, $for, $arguments) = @_; (defined $self->{'tasks'}->{$name}) or cluck("Task $name is not defined"), @@ -89,11 +92,14 @@ sub schedule($$;$) { ($for <= $now) and $for += $interval; }; + $arguments = [] unless defined $arguments; + push @{ $self->{'schedule'} }, { start => $for, order => $self->{'tasks'}->{$name}->{'order'}, - name => $name + name => $name, + arguments => $arguments }; @{ $self->{'schedule'} } = sort { $a->{'start'} <=> $b->{'start'} or $a->{'order'} <=> $b->{'order'} } @@ -139,7 +145,7 @@ sub run($) { my $what = $self->{'tasks'}->{$name}->{'what'}; print "Running $name at ".(time())." (scheduled for $now)\n" if Echolot::Config::get()->{'verbose'}; last if ($what eq 'exit'); - &$what(); + &$what( @{ $task->{'arguments'} } ); $self->schedule($name, $now + $self->{'tasks'}->{$name}->{'interval'}) if ($self->{'tasks'}->{$name}->{'interval'} > 0); diff --git a/NEWS b/NEWS index 8d693a7..7071c95 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,11 @@ Changes in version * In the distribution the pingd.conf file has been renamed to pingd.conf. So it should be possible to just untar the new tar.gz over the old installation (you have a backup anyway, don't you?). + * The getkeyconf command takes optional addresses to request config + data from. + * The getkeyconf config option was replaced by getkeyconf_interval and + getkeyconf_every_nth_time. Not all requests are sent at the same time + any more. Changes in version 2.0beta15 - 2002-07-16 * Have echolot version in stats HTML pages diff --git a/TODO b/TODO index 3b41d89..aaf8749 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,9 @@ -$Id: TODO,v 1.34 2002/07/17 02:35:29 weasel Exp $ +$Id: TODO,v 1.35 2002/07/17 17:53:44 weasel Exp $ for 2.0: Why does austria perform that bad with mix pings. can be done later, nice if for 2.0: - getkeyconf command could take option: address [address ...] list broken chains ping nymservers chain preload and postload diff --git a/doc/pingd.conf.pod b/doc/pingd.conf.pod index 279496f..6e12158 100644 --- a/doc/pingd.conf.pod +++ b/doc/pingd.conf.pod @@ -251,13 +251,19 @@ How often to expire old keys, pingds and remailers Default: 'expire' => 24*60*60, # daily Example: 'expire' => 8*60*60, # every 8 hours -=item B [seconds] +=item B [seconds] -How often to query remailers for new keys and configuration data -(remailer-xxx). +=item B [integer] - Default: 'getkeyconf' => 24*60*60, # daily - Example: 'getkeyconf' => 2*24*60*60, # every other day +How often to query remailers for new keys and configuration data +(remailer-xxx). Some requests are sent every B +seconds. The same request to the same remailer is sent only every +B time. + + Default: 'getkeyconf_interval' => 5*60, # send out requests every 5 minutes + 'getkeyconf_every_nth_time' => 24*60/5, # send out the same request to the same remailer once a day + Example: 'getkeyconf_interval' => 10*60, + 'getkeyconf_every_nth_time' => 2*24*60/10, # new request every other day =item B [seconds] diff --git a/pingd b/pingd index cd13994..63612c4 100755 --- a/pingd +++ b/pingd @@ -3,7 +3,7 @@ $| = 1; # (c) 2002 Peter Palfrader -# $Id: pingd,v 1.44 2002/07/16 03:02:53 weasel Exp $ +# $Id: pingd,v 1.45 2002/07/17 17:53:44 weasel Exp $ # =pod @@ -32,7 +32,7 @@ pingd - echolot ping daemon =item B B I
-=item B B +=item B B [I
[I
...]] =item B B @@ -126,9 +126,10 @@ For instance: Delete remailer-conf data for I
. The config data will be reset from the next valid remailer-conf reply by the remailer. -=item B +=item B [I
[I
...]] Send a command to immediatly request keys and configuration from remailers. +If no addresses are given, then requests will be sent to all remailers. =item B @@ -356,11 +357,27 @@ sub command_deleteremailercaps(@) { push @addresses, $address; }; - for my $address (@argv) { + for my $address (@addresses) { Echolot::Commands::addCommand("deleteremailercaps $address"); }; }; +sub command_getkeyconf(@) { + my @argv = @_; + + my @addresses; + for my $address (@argv) { + die ("argument $address is not a valid email address\n") unless ($address =~ /^[a-zA-Z0-9+._-]+\@[a-zA-Z0-9+.-]+$/ ); + push @addresses, $address; + }; + + push @addresses, 'all' unless (scalar @addresses); + + for my $address (@addresses) { + Echolot::Commands::addCommand("getkeyconf $address"); + }; +}; + sub pid_exists() { return (-e Echolot::Config::get()->{'pidfile'}); @@ -392,7 +409,7 @@ sub daemon_run($) { $scheduler->add('commitprospectives' , Echolot::Config::get()->{'commitprospectives'} , 0, \&commit_prospective_address ); $scheduler->add('expire' , Echolot::Config::get()->{'expire'} , 0, \&expire ); - $scheduler->add('getkeyconf' , Echolot::Config::get()->{'getkeyconf'} , 0, \&Echolot::Conf::send_requests ); + $scheduler->add('getkeyconf' , Echolot::Config::get()->{'getkeyconf_interval'}, 0, \&Echolot::Conf::send_requests ); $scheduler->add('check_resurrection' , Echolot::Config::get()->{'check_resurrection'} , 0, \&Echolot::Conf::check_resurrection ); Echolot::Globals::get()->{'scheduler'}->schedule('readcommands', time() ) @@ -529,7 +546,7 @@ if ($COMMAND eq 'add' || $COMMAND eq 'delete') { command_setremailercaps(@ARGV); hup_if_wanted($params->{'nohup'}); } elsif ($COMMAND eq 'getkeyconf') { - Echolot::Commands::addCommand("getkeyconf"); + command_getkeyconf(@ARGV); hup_if_wanted($params->{'nohup'}); } elsif ($COMMAND eq 'buildstats') { Echolot::Commands::addCommand("buildstats"); -- cgit v1.2.3