summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Commands.pm4
-rw-r--r--Echolot/Conf.pm51
-rw-r--r--Echolot/Config.pm5
-rw-r--r--Echolot/Pinger.pm7
-rw-r--r--Echolot/Scheduler.pm18
5 files changed, 55 insertions, 30 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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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<name> for I<for>. If I<for> is not given it is calculate
from I<interval> and I<offset> passed to B<new>.
=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);