From d1b1f4190ac0f55eeb08e0f676acb4d717996a06 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 11 Sep 2002 03:10:27 +0000 Subject: Add sendpings command --- Echolot/Commands.pm | 4 +++- Echolot/Pinger.pm | 18 ++++++++++++++---- NEWS | 1 + pingd | 33 ++++++++++++++++++++++++++++++--- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Echolot/Commands.pm b/Echolot/Commands.pm index 6c6901c..5efdf2d 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.10 2002/08/23 07:54:53 weasel Exp $ +# $Id: Commands.pm,v 1.11 2002/09/11 03:10:27 weasel Exp $ # =pod @@ -69,6 +69,8 @@ sub processCommands($) { Echolot::Globals::get()->{'storage'}->set_stuff(@args); } elsif ($command eq 'getkeyconf') { Echolot::Globals::get()->{'scheduler'}->schedule('getkeyconf', 0, time(), \@args ); + } elsif ($command eq 'sendpings') { + Echolot::Globals::get()->{'scheduler'}->schedule('ping', 0, time(), \@args ); } elsif ($command eq 'buildstats') { Echolot::Globals::get()->{'scheduler'}->schedule('buildstats', 0, time() ); } elsif ($command eq 'buildkeys') { diff --git a/Echolot/Pinger.pm b/Echolot/Pinger.pm index b31e339..3fc7d32 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.20 2002/09/04 01:47:01 weasel Exp $ +# $Id: Pinger.pm,v 1.21 2002/09/11 03:10:27 weasel Exp $ # =pod @@ -84,8 +84,10 @@ sub do_ping($$$) { return 1; }; -sub send_pings($) { - my ($scheduled_for) = @_; +sub send_pings($;$) { + my ($scheduled_for, $which) = @_; + + $which = '' unless defined $which; my $call_intervall = Echolot::Config::get()->{'pinger_interval'}; my $send_every_n_calls = Echolot::Config::get()->{'ping_every_nth_time'}; @@ -99,11 +101,19 @@ sub send_pings($) { next unless $remailer->{'pingit'}; my $address = $remailer->{'address'}; + next unless ( + $which eq 'all' || + $which eq $address || + $which eq ''); for my $type (Echolot::Globals::get()->{'storage'}->get_types($address)) { next unless Echolot::Config::get()->{'do_pings'}->{$type}; for my $key (Echolot::Globals::get()->{'storage'}->get_keys($address, $type)) { - next unless ($this_call_id eq (Echolot::Tools::makeShortNumHash($address.$type.$key.$session_id) % $send_every_n_calls)); + next unless ( + $which eq $address || + $which eq 'all' || + (($which eq '') && ($this_call_id eq (Echolot::Tools::makeShortNumHash($address.$type.$key.$session_id) % $send_every_n_calls)))); + print "ping calling $type, $address, $key\n" if Echolot::Config::get()->{'verbose'}; do_ping($type, $address, $key); } diff --git a/NEWS b/NEWS index eeacb73..dd6260a 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Changes in version 2.0rc3 user. * Template cleanup: fix a link and add links to .txt versions to front page. + * Add sendpings command. Changes in version 2.0rc2 - 2002-09-08 * Reopen stdin to /dev/null instead of closing it to avoid diff --git a/pingd b/pingd index 6fc327c..c12af0c 100755 --- a/pingd +++ b/pingd @@ -3,7 +3,7 @@ $| = 1; # (c) 2002 Peter Palfrader -# $Id: pingd,v 1.73 2002/09/08 18:17:31 weasel Exp $ +# $Id: pingd,v 1.74 2002/09/11 03:10:27 weasel Exp $ # =pod @@ -34,6 +34,8 @@ pingd - echolot ping daemon =item B B [I
[I
...]] +=item B B [I
[I
...]] + =item B B =item B B @@ -131,6 +133,11 @@ the next valid remailer-conf reply by the remailer. 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 [I
[I
...]] + +Send a command to immediatly send pings to the given remailers. +If no addresses are given, then requests will be sent to all remailers. + =item B Send a command to immediatly rebuild stats. @@ -177,8 +184,8 @@ Print version number and exit sucessfully. =item B<--nohup> Usefull only with the B, B, B, -B, B, B, B, -or B command. +B, B, B, B, +B, or B command. Don't send a HUP signal to the daemon which instructs it to process the commands after adding the command to the task list. @@ -414,6 +421,22 @@ sub command_getkeyconf(@) { }; }; +sub command_sendpings(@) { + 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("sendpings $address"); + }; +}; + sub pid_exists() { return (-e Echolot::Config::get()->{'pidfile'}); @@ -570,6 +593,7 @@ if ($params->{'help'}) { print (" setremailercaps ... set remailer capabilities manually\n"); print (" deleteremailercaps ... delete remailer capabilities manually\n"); print (" getkeyconf ... request remailer-xxx data immediatly\n"); + print (" sendpings ... request immediate sending of pings\n"); print (" buildstats ... build remailer stats immediatly\n"); print (" buildkeys ... buid keyrings immediatly\n"); print (" buildthesaurus ... build thesaurus immediatly\n"); @@ -608,6 +632,9 @@ if ($COMMAND eq 'add' || $COMMAND eq 'delete') { } elsif ($COMMAND eq 'getkeyconf') { command_getkeyconf(@ARGV); hup_if_wanted($params->{'nohup'}); +} elsif ($COMMAND eq 'sendpings') { + command_sendpings(@ARGV); + hup_if_wanted($params->{'nohup'}); } elsif ($COMMAND eq 'buildstats') { Echolot::Commands::addCommand("buildstats"); hup_if_wanted($params->{'nohup'}); -- cgit v1.2.3