summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-02-15 11:43:41 +0000
committerPeter Palfrader <peter@palfrader.org>2003-02-15 11:43:41 +0000
commite61c9c9f2e96a129f31a1bf49d4f2514137a3b01 (patch)
tree3759bc4364e782fa7cb177571ad195cb82121c36
parent7adc1b95176205694c1b34878b185a41c82373e9 (diff)
Chain pinging fixes
-rw-r--r--Echolot/Chain.pm12
-rw-r--r--Echolot/Config.pm3
-rw-r--r--Echolot/Mailin.pm16
-rw-r--r--Echolot/Pinger/CPunk.pm9
-rw-r--r--Echolot/Stats.pm14
-rw-r--r--Echolot/Storage/File.pm10
-rw-r--r--Echolot/Tools.pm12
7 files changed, 42 insertions, 34 deletions
diff --git a/Echolot/Chain.pm b/Echolot/Chain.pm
index 9f08b81..02494ae 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.2 2003/02/15 00:44:39 weasel Exp $
+# $Id: Chain.pm,v 1.3 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -41,7 +41,7 @@ sub do_mix_chainping($$$$$$$$) {
return 1;
};
-sub do_cpunk_ping($$$$$$$$) {
+sub do_cpunk_chainping($$$$$$$$) {
my ($addr1, $type1, $keyid1, $addr2, $type2, $keyid2, $to, $body) = @_;
my $keyhash = {};
@@ -116,8 +116,8 @@ sub get_latest_key($$) {
my $latest = 0;
my $chosen = undef;
for my $keyid (Echolot::Globals::get()->{'storage'}->get_keys($address, $type)) {
- my $key = Echolot::Globals::get()->{'storage'}->get_key($address, $type, $keyid);
- $chosen = $keyid if $latest < $key->{'last_updated'};
+ my %key = Echolot::Globals::get()->{'storage'}->get_key($address, $type, $keyid);
+ $chosen = $keyid if $latest < $key{'last_update'};
};
return $chosen;
};
@@ -194,7 +194,7 @@ sub receive($$$) {
};
$body = $msg unless defined $body;
- my ($chaintype) = $body =~ /^chaintype (.*)$/m;
+ my ($chaintype) = $body =~ /^chaintype: (.*)$/m;
my ($addr1) = $body =~ /^remailer1: (.*)$/m;
my ($type1) = $body =~ /^type1: (.*)$/m;
my ($key1) = $body =~ /^key1: (.*)$/m;
@@ -216,7 +216,7 @@ sub receive($$$) {
Echolot::Log::warn("Received chainping at $timestamp has wrong mac; $cleanstring."),
return 0;
- Echolot::Globals::get()->{'storage'}->register_chainpingdone($chaintype, $addr1, $type1, $key1, $addr2, $type2, $key2, $now - $sent) or
+ Echolot::Globals::get()->{'storage'}->register_chainpingdone($chaintype, $addr1, $type1, $key1, $addr2, $type2, $key2, $sent, $now - $sent) or
return 0;
return 1;
diff --git a/Echolot/Config.pm b/Echolot/Config.pm
index 4138472..50d7ca7 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.48 2003/02/14 05:14:43 weasel Exp $
+# $Id: Config.pm,v 1.49 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -131,6 +131,7 @@ sub init($) {
commands_file => 'commands.txt',
pidfile => 'pingd.pid',
+ 'save-errormails' => 0,
write_meta_files => 1,
meta_extension => '.meta',
diff --git a/Echolot/Mailin.pm b/Echolot/Mailin.pm
index 2d0d196..266ccff 100644
--- a/Echolot/Mailin.pm
+++ b/Echolot/Mailin.pm
@@ -1,7 +1,7 @@
package Echolot::Mailin;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Mailin.pm,v 1.12 2003/02/14 05:12:50 weasel Exp $
+# $Id: Mailin.pm,v 1.13 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -82,7 +82,7 @@ sub handle($) {
Echolot::Conf::remailer_adminkey($body, $type, $timestamp), return 1 if ($type =~ /^adminkey\./);
Echolot::Pinger::receive($body, $type, $timestamp), return 1 if ($type eq 'ping');
- Echolot::Chain($body, $type, $timestamp), return 1 if ($type eq 'chainping');
+ Echolot::Chain::receive($body, $type, $timestamp), return 1 if ($type eq 'chainping');
Echolot::Log::warn("Didn't know what to do with '$to'."),
return 0;
@@ -214,10 +214,14 @@ sub process() {
Echolot::Globals::get()->{'storage'}->delay_commit();
for my $mail (@$mails) {
unless (handle($mail)) {
- Echolot::Log::info("Trashing mail with unknown destination (probably a bounce).");
- #my $name = make_sane_name();
- #storemail($mailerrordir, $mail) or
- # Echolot::Log::warn("Could not store a mail.");
+ if (Echolot::Config::get()->{'save-errormails'}) {
+ Echolot::Log::info("Saving mail with unknown destination (probably a bounce) to mail-errordir.");
+ my $name = make_sane_name();
+ storemail($mailerrordir, $mail) or
+ Echolot::Log::warn("Could not store a mail.");
+ } else {
+ Echolot::Log::info("Trashing mail with unknown destination (probably a bounce).");
+ };
};
};
Echolot::Globals::get()->{'storage'}->enable_commit();
diff --git a/Echolot/Pinger/CPunk.pm b/Echolot/Pinger/CPunk.pm
index a82e791..6f4ca62 100644
--- a/Echolot/Pinger/CPunk.pm
+++ b/Echolot/Pinger/CPunk.pm
@@ -1,7 +1,7 @@
package Echolot::Pinger::CPunk;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: CPunk.pm,v 1.12 2003/02/14 04:56:16 weasel Exp $
+# $Id: CPunk.pm,v 1.13 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -136,8 +136,11 @@ sub encrypt_to($$$$) {
#($stderr eq '') or
#Echolot::Log::warn("GnuPG returned something in stderr: '$stderr' while encrypting to '$recipient'."),
#return undef;
- (($status =~ /^^\[GNUPG:\] BEGIN_ENCRYPTION\s/m) &&
- ($status =~ /^^\[GNUPG:\] END_ENCRYPTION\s/m)) or
+ ($status =~ /^\[GNUPG:\] KEYEXPIRED (\d+)/m) and
+ Echolot::Log::info("Key $recipient expired at ".scalar gmtime($1)." UTC"),
+ return undef;
+ (($status =~ /^\[GNUPG:\] BEGIN_ENCRYPTION\s/m) &&
+ ($status =~ /^\[GNUPG:\] END_ENCRYPTION\s/m)) or
Echolot::Log::info("GnuPG status '$status' didn't indicate message to '$recipient' was encrypted correctly (stderr: $stderr; args: ".join(' ', @$command_args).")."),
return undef;
diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm
index 515107d..39eef51 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.38 2003/01/14 05:25:35 weasel Exp $
+# $Id: Stats.pm,v 1.39 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -705,12 +705,12 @@ sub build_pgpring_type($$$$) {
($stdout eq '') or
Echolot::Log::info("GnuPG returned something in stdout '$stdout' while adding key for '$addr': So what?");
- unless ($status =~ /^^\[GNUPG:\] IMPORTED /m) {
- if ($status =~ /^^\[GNUPG:\] IMPORT_RES /m) {
- Echolot::Log::info("GnuPG status '$status' indicates more than one key for '$addr' imported. Ignoring.");
- } else {
- Echolot::Log::info("GnuPG status '$status' didn't indicate key for '$addr' was imported correctly. Ignoring.");
- };
+ # See DETAIL.gz in GnuPG's doc directory for syntax of GnuPG status
+ my ($count, $count_imported) = $status =~ /^\[GNUPG:\] IMPORT_RES (\d+) \d+ (\d+)/m;
+ if ($count_imported > 1) {
+ Echolot::Log::info("GnuPG status '$status' indicates more than one key for '$addr' imported. Ignoring.");
+ } elsif ($count_imported < 1) {
+ Echolot::Log::info("GnuPG status '$status' didn't indicate key for '$addr' was imported correctly. Ignoring.");
};
$keyids->{$final_keyid} = $remailer->{'showit'};
};
diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm
index e330d98..c22b325 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.48 2003/02/14 06:01:29 weasel Exp $
+# $Id: File.pm,v 1.49 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -533,7 +533,7 @@ sub register_pingout($$$$$) {
Echolot::Log::warn("Error when writing to $remailer_addr; type=$type; key=$key; out pings: $!."),
return undef;
$fh->flush();
- Echolot::Log::info("registering pingout for $remailer_addr ($type; $key).");
+ Echolot::Log::debug("registering pingout for $remailer_addr ($type; $key).");
return 1;
};
@@ -586,7 +586,7 @@ sub register_pingdone($$$$$$) {
Echolot::Log::warn("Error when writing to outgoing pings file for remailer $remailer_addr; key=$key file: $!."),
return undef;
$fh->flush();
- Echolot::Log::info("registering pingdone from ".(scalar localtime $sent_time)." with latency $latency for $remailer_addr ($type; $key).");
+ Echolot::Log::debug("registering pingdone from ".(scalar localtime $sent_time)." with latency $latency for $remailer_addr ($type; $key).");
return 1;
};
@@ -737,7 +737,7 @@ sub register_chainpingout($$$$$$$$$) {
Echolot::Log::warn("Error when writing to chaintype $chaintype out pings: $!."),
return undef;
$fh->flush();
- Echolot::Log::info("registering chainping $chaintype out through $addr1 ($type1; $key1) via $addr1 ($type2; $key2).");
+ Echolot::Log::debug("registering chainping $chaintype out through $addr1 ($type1; $key1) via $addr2 ($type2; $key2).");
return 1;
};
@@ -765,7 +765,7 @@ sub register_chainpingdone($$$$$$$$$$) {
Echolot::Log::warn("Error when writing to $chaintype/done pings: $!."),
return undef;
$fh->flush();
- Echolot::Log::info("registering pingdone from ".(scalar localtime $sent_time)." with latency $latency chainping $chaintype out through $addr1 ($type1; $key1) via $addr1 ($type2; $key2).");
+ Echolot::Log::debug("registering chainpingdone from ".(scalar localtime $sent_time)." with latency $latency chainping $chaintype out through $addr1 ($type1; $key1) via $addr2 ($type2; $key2).");
return 1;
};
diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm
index db9d785..86adb91 100644
--- a/Echolot/Tools.pm
+++ b/Echolot/Tools.pm
@@ -1,7 +1,7 @@
package Echolot::Tools;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Tools.pm,v 1.14 2003/01/14 05:25:35 weasel Exp $
+# $Id: Tools.pm,v 1.15 2003/02/15 11:43:41 weasel Exp $
#
=pod
@@ -291,14 +291,14 @@ sub crypt_symmetrically($$) {
waitpid $pid, 0;
if ($direction eq 'encrypt') {
- (($status =~ /^^\[GNUPG:\] BEGIN_ENCRYPTION\s/m) &&
- ($status =~ /^^\[GNUPG:\] END_ENCRYPTION\s/m)) or
+ (($status =~ /^\[GNUPG:\] BEGIN_ENCRYPTION\s/m) &&
+ ($status =~ /^\[GNUPG:\] END_ENCRYPTION\s/m)) or
Echolot::Log::info("GnuPG status '$status' didn't indicate message was encrypted correctly (stderr: $stderr). Returning."),
return undef;
} elsif ($direction eq 'decrypt') {
- (($status =~ /^^\[GNUPG:\] BEGIN_DECRYPTION\s/m) &&
- ($status =~ /^^\[GNUPG:\] DECRYPTION_OKAY\s/m) &&
- ($status =~ /^^\[GNUPG:\] END_DECRYPTION\s/m)) or
+ (($status =~ /^\[GNUPG:\] BEGIN_DECRYPTION\s/m) &&
+ ($status =~ /^\[GNUPG:\] DECRYPTION_OKAY\s/m) &&
+ ($status =~ /^\[GNUPG:\] END_DECRYPTION\s/m)) or
Echolot::Log::info("GnuPG status '$status' didn't indicate message was decrypted correctly (stderr: $stderr). Returning."),
return undef;
};