summaryrefslogtreecommitdiff
path: root/Echolot/Report.pm
blob: 22e2bf966c82974332314cb819062ec1db211989 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Echolot::Report;

# (c) 2002 Peter Palfrader <peter@palfrader.org>
# $Id: Report.pm,v 1.2 2003/04/29 16:31:21 weasel Exp $
#

=pod

=head1 Name

Echolot::Report - Summarize status of remailers

=head1 DESCRIPTION

This package prints the summary of remailers/addresses.

=cut

use strict;
use English;
use Echolot::Log;

sub print_summary(;$) {
	my ($manual) = @_;

	my @addresses = sort { $a->{'address'} cmp $b->{'address'} } Echolot::Globals::get()->{'storage'}->get_addresses();
	my %remailers = map { $_->{'address'} => $_ } Echolot::Globals::get()->{'storage'}->get_remailers();
	my $report = "*** Status summary ***\n";

	for my $remailer (@addresses) {
		my $addr = $remailer->{'address'};
		$report .= "$addr (ID: $remailer->{'id'}): ".uc($remailer->{'status'})."; ".
			"Fetch/Ping/Show: ".
			($remailer->{'fetch'} ? '1' : '0') .
			($remailer->{'pingit'} ? '1' : '0') .
			($remailer->{'showit'} ? '1' : '0') .
			"; TTL: $remailer->{'ttl'}\n";
		$report .= "  Resurection TTL: $remailer->{'resurrection_ttl'}\n" if (defined $remailer->{'resurrection_ttl'} && ($remailer->{'status'} eq 'ttl timeout'));
		if (defined $remailers{$addr}) {
			$report .= "  $remailers{$addr}->{'status'}\n";
			for my $type (Echolot::Globals::get()->{'storage'}->get_types($addr)) {
				$report .= "  Type: $type: ".join(', ', Echolot::Globals::get()->{'storage'}->get_keys($addr, $type))."\n";
			};
		};
	};
	if (defined $manual) {
		Echolot::Log::notice($report);
	} else {
		Echolot::Log::info($report);
	}

	return 1;
};

1;
# vim: set ts=4 shiftwidth=4: