summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-02-28 18:02:31 +0000
committerPeter Palfrader <peter@palfrader.org>2003-02-28 18:02:31 +0000
commitc8870e1233f5312561b50997ee693ac2a4be58bb (patch)
treef3fda62cec22c837e66dcc229269e8da6b799654 /Echolot
parent1f8f0f17e48297aceb1fb5255139b9be8cc7b62d (diff)
Summarize bad chains (i.e. have (foo *) if needed)
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Config.pm3
-rw-r--r--Echolot/Stats.pm57
2 files changed, 53 insertions, 7 deletions
diff --git a/Echolot/Config.pm b/Echolot/Config.pm
index c64f295..6b1be41 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.61 2003/02/20 19:39:03 weasel Exp $
+# $Id: Config.pm,v 1.62 2003/02/28 18:02:31 weasel Exp $
#
=pod
@@ -111,6 +111,7 @@ sub init($) {
chainping_grace => 1.5, # don't count pings sent no longer than 1.5 * (lat1 + lat2) ago
chainping_update => 4*60*60, # chain stats should never be older than 4 hours
chainping_minsample => 3, # have at least sent 3 pings before judging any chain
+ chainping_allbad_factor => 0.5, # at least 50% of possible chains (A x) need to fail for (A *) to be listed in broken chains
addresses_default_ttl => 5, # getkeyconf seconds (days)
check_resurrection_ttl => 8, # check_resurrection seconds (weeks)
diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm
index 7316af3..0002ea8 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.51 2003/02/20 17:02:38 weasel Exp $
+# $Id: Stats.pm,v 1.52 2003/02/28 18:02:31 weasel Exp $
#
=pod
@@ -476,6 +476,54 @@ sub build_rems($) {
return \@rems;
};
+sub compress_broken_chain($@) {
+ my ($num, @list) = @_;
+
+ my %unique = ();
+ @list = sort { $a cmp $b} grep { ! $unique{$_}++; } @list;
+
+ my %bad_left;
+ my %bad_right;
+ for my $chain (@list) {
+ chomp;
+ my ($left, $right) = $chain =~ m/\((\S+) \s (\S+)\)/x or
+ Echolot::Log::warn("Could not parse bad chain '$chain'."),
+ next;
+ $bad_right{$right}++;
+ $bad_right{$right} += $num if ($left eq '*');
+ $bad_left {$left }++;
+ $bad_left {$left } += $num if ($right eq '*');
+ };
+
+
+ my $threshold = $num * Echolot::Config::get()->{'chainping_allbad_factor'};
+ my @result = ();
+ for my $key (keys %bad_right) {
+ delete $bad_right{$key}, next if $bad_right{$key} < $threshold;
+ push @result, "(* $key)";
+ };
+ for my $key (keys %bad_left) {
+ delete $bad_left{$key}, next if $bad_left{$key} < $threshold;
+ push @result, "($key *)";
+ };
+
+ for my $chain (@list) {
+ chomp;
+ my ($left, $right) = $chain =~ m/\((\S+) \s (\S+)\)/x or
+ # Echolot::Log::warn("Could not parse bad chain '$chain'."), -- don't warn again
+ push(@result, $chain),
+ next;
+ next if defined $bad_right{$right};
+ next if defined $bad_left {$left };
+ push(@result, $chain),
+ };
+
+ %unique = ();
+ @result = sort { $a cmp $b} grep { ! $unique{$_}++; } @result;
+
+ return @list;
+};
+
sub find_broken_chains($$$) {
my ($chaintype, $rems, $hard) = @_;
@@ -560,11 +608,8 @@ sub find_broken_chains($$$) {
push @pub, map { $_->{'chain'} } grep { $_->{'public'} } @{ $BROKEN_CHAINS{$chaintype} };
push @priv, map { $_->{'chain'} } @{ $BROKEN_CHAINS{$chaintype} };
- my %unique;
- %unique = ();
- my $pub = join "\n", sort { $a cmp $b} grep { ! $unique{$_}++; } @pub;
- %unique = ();
- my $priv = join "\n", sort { $a cmp $b} grep { ! $unique{$_}++; } @priv;
+ my $pub = join "\n", compress_broken_chain(scalar @$rems, @pub);
+ my $priv = join "\n", compress_broken_chain(scalar @$rems, @priv);
return ($pub, $priv);
};