summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-02-16 09:09:57 +0000
committerPeter Palfrader <peter@palfrader.org>2003-02-16 09:09:57 +0000
commit04265aabca9e8d0dadd4efb8d194e9d679df1c6d (patch)
tree0d6446847c2b265e835bba5d1c1c925712997b59 /Echolot
parent88e90e95c7b92268618c2ed62b7621b03c77fc26 (diff)
Ping broken chains more often ("Intensive Care")
Expire chainpings
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Chain.pm23
-rw-r--r--Echolot/Conf.pm5
-rw-r--r--Echolot/Config.pm5
-rw-r--r--Echolot/Stats.pm13
-rw-r--r--Echolot/Storage/File.pm44
5 files changed, 76 insertions, 14 deletions
diff --git a/Echolot/Chain.pm b/Echolot/Chain.pm
index 14186a2..63e4a5b 100644
--- a/Echolot/Chain.pm
+++ b/Echolot/Chain.pm
@@ -1,7 +1,7 @@
package Echolot::Chain;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Chain.pm,v 1.4 2003/02/16 03:06:51 weasel Exp $
+# $Id: Chain.pm,v 1.5 2003/02/16 09:09:57 weasel Exp $
#
=pod
@@ -22,6 +22,8 @@ use Echolot::Log;
use Echolot::Pinger::Mix;
use Echolot::Pinger::CPunk;
+my %INTENSIVE_CARE;
+
sub do_mix_chainping($$$$$$$$) {
my ($addr1, $type1, $keyid1, $addr2, $type2, $keyid2, $to, $body) = @_;
@@ -135,6 +137,13 @@ sub send_pings($;$$) {
my $this_call_id = $timemod % $send_every_n_calls;
my $session_id = int ($scheduled_for / ($call_intervall * $send_every_n_calls));
+ # Same thing for Intensive Care -- yet unknown or already broken chains
+ my $send_every_n_calls_ic = Echolot::Config::get()->{'chainping_ic_every_nth_time'};
+
+ my $timemod_ic = int ($scheduled_for / $call_intervall);
+ my $this_call_id_ic = $timemod_ic % $send_every_n_calls_ic;
+ my $session_id_ic = int ($scheduled_for / ($call_intervall * $send_every_n_calls_ic));
+
my @remailers = Echolot::Globals::get()->{'storage'}->get_remailers();
for my $rem1 (@remailers) {
next unless $rem1->{'pingit'};
@@ -165,9 +174,13 @@ sub send_pings($;$$) {
my $key2 = get_latest_key($addr2, $type2);
+ my $call_id = Echolot::Tools::makeShortNumHash($addr1.$addr2.$chaintype.$session_id ) % $send_every_n_calls;
+ my $call_id_ic = Echolot::Tools::makeShortNumHash($addr1.$addr2.$chaintype.$session_id_ic) % $send_every_n_calls_ic;
next unless (
(($which1 eq $addr1 || $which1 eq 'all' ) && ($which2 eq $addr2 || $which2 eq 'all')) ||
- (($which1 eq '' && $which2 eq '') && ($this_call_id eq (Echolot::Tools::makeShortNumHash($addr1.$addr2.$chaintype.$session_id) % $send_every_n_calls))));
+ (($which1 eq '' && $which2 eq '') && (
+ $this_call_id eq $call_id ||
+ (defined $INTENSIVE_CARE{$chaintype}->{$addr1.' '.$addr2} && $this_call_id_ic eq $call_id_ic))));
Echolot::Log::debug("chainping calling $chaintype, $addr1 ($type1, $key1) - $addr2 ($type2, $key2)");
do_chainping($chaintype, $addr1, $type1, $key1, $addr2, $type2, $key2);
@@ -177,6 +190,12 @@ sub send_pings($;$$) {
return 1;
};
+sub set_intensive_care($@) {
+ my ($chaintype, $intensive_care) = @_;
+
+ %{$INTENSIVE_CARE{$chaintype}} = map { ($_->{'addr1'}.' '.$_->{'addr2'}) => $_->{'reason'} } @$intensive_care;
+ Echolot::Log::debug("intensive care $chaintype:\n" . join("\n", map { "\t\t$_: $INTENSIVE_CARE{$chaintype}->{$_}" } keys %{$INTENSIVE_CARE{$chaintype}} ));
+};
sub receive($$$) {
my ($msg, $token, $timestamp) = @_;
diff --git a/Echolot/Conf.pm b/Echolot/Conf.pm
index d5b9505..176df6a 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.37 2003/02/16 03:38:09 weasel Exp $
+# $Id: Conf.pm,v 1.38 2003/02/16 09:09:57 weasel Exp $
#
=pod
@@ -381,7 +381,8 @@ sub parse_cpunk_key($$$) {
my @included_keys = $stdout =~ /^pub:.*$/mg;
(scalar @included_keys >= 2) &&
- Echolot::Log::info ("Cannot handle more than one key per block correctly yet. Found ".(scalar @included_keys)." in one block from ".$remailer->{'address'}.".");
+ # FIXME handle more than one key per block nicely
+ Echolot::Log::debug ("Cannot handle more than one key per block nicely (correctly) yet. Found ".(scalar @included_keys)." in one block from ".$remailer->{'address'}.".");
for my $included_key (@included_keys) {
my ($type, $keyid, $uid) = $included_key =~ /pub::\d+:(\d+):([0-9A-F]+):[^:]+:[^:]*:::([^:]+):/;
(defined $uid) or
diff --git a/Echolot/Config.pm b/Echolot/Config.pm
index 89b33ae..b9522f6 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.52 2003/02/16 05:46:54 weasel Exp $
+# $Id: Config.pm,v 1.53 2003/02/16 09:09:57 weasel Exp $
#
=pod
@@ -100,7 +100,8 @@ sub init($) {
ping_every_nth_time => 48, # send out pings to the same remailer every 48 calls, i.e. every 4 hours
chainpinger_interval => 5*60, # send out pings every 5 minutes
- chainping_every_nth_time => 810, # send out pings to the same chain every 810 calls, i.e. every 3 days
+ chainping_every_nth_time => 864, # send out pings to the same chain every 864 calls, i.e. every 3 days
+ chainping_ic_every_nth_time => 810, # send out pings to broken or unknown chains every 288 calls, i.e. every day
chainping_period => 10*24*60*60, # 12 days
chainping_fudge => 0.3, # if less than 0.3 * rel1 * rel2 make it, the chain is really broken
chainping_grace => 1.5, # don't count pings sent no longer than 1.5 * (lat1 + lat2) ago
diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm
index 14fd2a5..c51fd10 100644
--- a/Echolot/Stats.pm
+++ b/Echolot/Stats.pm
@@ -1,7 +1,7 @@
package Echolot::Stats;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Stats.pm,v 1.42 2003/02/16 03:40:48 weasel Exp $
+# $Id: Stats.pm,v 1.43 2003/02/16 09:09:57 weasel Exp $
#
=pod
@@ -486,7 +486,7 @@ sub find_broken_chains($$$) {
$LAST_BROKENCHAIN_RUN{$chaintype} = time();
my $pings = Echolot::Globals::get()->{'storage'}->get_chainpings($chaintype);
-
+ my @intensive_care = ();
my %remailers = map { $_->{'address'} => $_ } @$rems;
my $stats;
@@ -529,6 +529,9 @@ sub find_broken_chains($$$) {
my $theoretical_rel = $remailers{$addr1}->{'stats'}->{'avr_reliability'} *
$remailers{$addr2}->{'stats'}->{'avr_reliability'};
my $out = $stats->{$addr1}->{$addr2}->{'out'};
+ ($out < Echolot::Config::get()->{'chainping_minsample'}) and
+ push (@intensive_care, { addr1 => $addr1, addr2 => $addr2, reason => "only $out samples" }),
+ next;
my $done = $stats->{$addr1}->{$addr2}->{'done'};
$done = 0 unless defined $done;
($out > 0) or
@@ -539,10 +542,12 @@ sub find_broken_chains($$$) {
next if ($real_rel > $theoretical_rel * Echolot::Config::get()->{'chainping_fudge'});
my $nick1 = $remailers{$addr1}->{'nick'};
my $nick2 = $remailers{$addr2}->{'nick'};
- push @broken_chains, "($nick1 $nick2)";
+ push @broken_chains, "($nick1 $nick2) $done/$out";
+ push @intensive_care, { addr1 => $addr1, addr2 => $addr2, reason => "bad: $done/$out" };
};
};
$BROKEN_CHAINS{$chaintype} = \@broken_chains;
+ Echolot::Chain::set_intensive_care($chaintype, \@intensive_care);
} else {
Echolot::Log::debug ("Broken Chains $chaintype are up to date."),
};
@@ -551,7 +556,7 @@ sub find_broken_chains($$$) {
push @result, @{ $BROKEN_CHAINS{$chaintype} };
my %unique;
@result = grep { ! $unique{$_}++; } @result;
- return join "\n", @result;
+ return join "\n", sort { $a cmp $b} @result;
};
sub build_lists() {
diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm
index 9309a03..bf0a57e 100644
--- a/Echolot/Storage/File.pm
+++ b/Echolot/Storage/File.pm
@@ -1,7 +1,7 @@
package Echolot::Storage::File;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: File.pm,v 1.50 2003/02/16 03:06:51 weasel Exp $
+# $Id: File.pm,v 1.51 2003/02/16 09:09:57 weasel Exp $
#
=pod
@@ -735,7 +735,7 @@ sub get_chainpings($$) {
my ($self, $chaintype) = @_;
my $fh = $self->get_chainping_fh($chaintype, 'out') or
- Echolot::Log::warn ("assigned filehandle for $chaintype out chainpings."),
+ Echolot::Log::warn ("have no assigned filehandle for $chaintype out chainpings."),
return undef;
seek($fh, 0, SEEK_SET) or
Echolot::Log::warn("Cannot seek to start of $chaintype out chainpings $!."),
@@ -1544,6 +1544,7 @@ sub expire($) {
my $expire_keys = $now - Echolot::Config::get()->{'expire_keys'};
my $expire_conf = $now - Echolot::Config::get()->{'expire_confs'};
my $expire_pings = $now - Echolot::Config::get()->{'expire_pings'};
+ my $expire_chainpings = $now - Echolot::Config::get()->{'expire_chainpings'};
for my $remailer_addr ( keys %{$self->{'METADATA'}->{'remailers'}} ) {
for my $type ( keys %{$self->{'METADATA'}->{'remailers'}->{$remailer_addr}->{'keys'}} ) {
@@ -1574,8 +1575,8 @@ sub expire($) {
for my $type ( keys %{$self->{'METADATA'}->{'remailers'}->{$remailer_addr}->{'keys'}} ) {
for my $key ( keys %{$self->{'METADATA'}->{'remailers'}->{$remailer_addr}->{'keys'}->{$type}} ) {
- my @out = grep {$_ > $expire_pings} Echolot::Globals::get()->{'storage'}->get_pings($remailer_addr, $type, $key, 'out');
- my @done = grep {$_->[0] > $expire_pings} Echolot::Globals::get()->{'storage'}->get_pings($remailer_addr, $type, $key, 'done');
+ my @out = grep {$_ > $expire_pings} $self->get_pings($remailer_addr, $type, $key, 'out');
+ my @done = grep {$_->[0] > $expire_pings} $self->get_pings($remailer_addr, $type, $key, 'done');
# write ping to done
@@ -1613,6 +1614,41 @@ sub expire($) {
};
};
+ for my $type ( keys %{$self->{'CHAINPING_FHS'}} ) {
+ my $pings = $self->get_chainpings($type);
+
+ @{ $pings->{'out'} } = map {
+ my $a = $_;
+ join (' ', map ({ $a->{$_} } qw{sent addr1 type1 key1 addr2 type2 key2}))
+ } grep {
+ $_->{'sent'} > $expire_chainpings
+ }
+ @{ $pings->{'out'} };
+ @{ $pings->{'done'} } = map {
+ my $a = $_;
+ join (' ', map ({ $a->{$_} } qw{sent addr1 type1 key1 addr2 type2 key2 lat}))
+ } grep {
+ $_->{'sent'} > $expire_chainpings
+ }
+ @{ $pings->{'done'} };
+
+ for my $dir (qw{out done}) {
+ my $fh = $self->get_chainping_fh($type, $dir) or
+ Echolot::Log::warn ("have no assigned filehandle for $type $dir chainpings."),
+ return undef;
+ seek($fh, 0, SEEK_SET) or
+ Echolot::Log::warn("Cannot seek to start of $dir chainpings $type $!."),
+ return undef;
+ truncate($fh, 0) or
+ Echolot::Log::warn("Cannot truncate $dir chainpings $type file to zero length: $!."),
+ return undef;
+ print($fh (join "\n", @{$pings->{$dir}}), (scalar @{$pings->{$dir}} ? "\n" : '') ) or
+ Echolot::Log::warn("Error when writing to $dir chainpings $type file: $!."),
+ return undef;
+ $fh->flush();
+ };
+ };
+
$self->commit();
return 1;