summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2002-06-10 05:12:55 +0000
committerPeter Palfrader <peter@palfrader.org>2002-06-10 05:12:55 +0000
commit5e5e774e4ad7b008115d5c89b9748aefbef3ad3a (patch)
tree58dfb50702de84aeb2ad4b5a012ad4ed06d7a714
parentecd052098413f87701ba00e28f88563248a177f6 (diff)
Parse remailer-key replies
-rw-r--r--Echolot/Conf.pm87
1 files changed, 85 insertions, 2 deletions
diff --git a/Echolot/Conf.pm b/Echolot/Conf.pm
index b19b25c..3fa0660 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.1 2002/06/05 04:05:40 weasel Exp $
+# $Id: Conf.pm,v 1.2 2002/06/10 05:12:55 weasel Exp $
#
=pod
@@ -41,6 +41,10 @@ sub remailer_conf($$$) {
my ($conf, $token, $time) = @_;
my ($id) = $token =~ /^conf\.(\d+)$/;
+ (defined $id) &&
+ cluck ("Returned token '$token' has no id at all"),
+ return 0;
+
cluck("Could not find id in token '$token'"), return 0 unless defined $id;
my ($remailer_type) = ($conf =~ /^\s*Remailer-Type:\s* (.*?) \s*$/imx);
cluck("No remailer type found in remailer_conf from '$token'"), return 0 unless defined $remailer_type;
@@ -52,6 +56,7 @@ sub remailer_conf($$$) {
my $remailer = Echolot::Globals::get()->{'storage'}->get_address_by_id($id);
+ cluck("No remailer found for id '$id'"), return 0 unless defined $remailer;
if ($remailer->{'address'} ne $remailer_address) {
# Address mismatch -> Ignore reply and add $remailer_address to prospective addresses
cluck("Remailer address mismatch $remailer->{'address'} vs $remailer_address. Adding latter to prospective remailers.");
@@ -60,12 +65,90 @@ sub remailer_conf($$$) {
Echolot::Globals::get()->{'storage'}->restore_ttl( $remailer->{'address'} );
Echolot::Globals::get()->{'storage'}->set_caps($remailer_type, $remailer_caps, $remailer_nick, $remailer_address, $time);
}
+
+ return 1;
};
sub remailer_key($$$) {
my ($conf, $token, $time) = @_;
- print "Remailer key\n";
+ my ($id) = $token =~ /^key\.(\d+)$/;
+ (defined $id) or
+ cluck ("Returned token '$token' has no id at all"),
+ return 0;
+
+ my $remailer = Echolot::Globals::get()->{'storage'}->get_address_by_id($id);
+ cluck("No remailer found for id '$id'"), return 0 unless defined $remailer;
+# -----Begin Mix Key-----
+# 7f6d997678b19ccac110f6e669143126
+# 258
+# AASyedeKiP1/UKyfrBz2K6gIhv4jfXIaHo8dGmwD
+# KqkG3DwytgSySSY3wYm0foT7KvEnkG2aTi/uJva/
+# gymE+tsuM8l8iY1FOiXwHWLDdyUBPbrLjRkgm7GD
+# Y7ogSjPhVLeMpzkSyO/ryeUfLZskBUBL0LxjLInB
+# YBR3o6p/RiT0EQAAAAAAAAAAAAAAAAAAAAAAAAAA
+# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+# AAAAAAAAAAAAAAAAAAAAAQAB
+# -----End Mix Key-----
+
+ my %mixmasters;
+ # rot26 rot26@mix.uucico.de 7f6d997678b19ccac110f6e669143126 2.9b33 MC
+ my @mix_confs = ($conf =~ /^[a-z0-9]+ \s+ \S+\@\S+ \s+ [0-9a-f]{32} (?:\s+ \S+ \s+ \S+)?/xmg);
+ my @mix_keys = ($conf =~ /^-----Begin \s Mix \s Key-----\r?\n
+ [0-9a-f]{32}\r?\n
+ \d+\r?\n
+ (?:[a-zA-Z0-9+\/]*\r?\n)+
+ -----End \s Mix \s Key-----$/xmg );
+ for (@mix_confs) {
+ my ($nick, $address, $keyid, $version, $caps) = /^([a-z0-9]+) \s+ (\S+@\S+) \s+ ([0-9a-f]{32}) (?:(\S+) \s+ (\S+))?/x;
+ $mixmasters{$keyid} = {
+ nick => $nick,
+ address => $address,
+ version => $version,
+ caps => $caps,
+ summary => $_
+ };
+ };
+ for (@mix_keys) {
+ my ($keyid) = /^-----Begin \s Mix \s Key-----\r?\n
+ ([0-9a-f]{32})\r?\n
+ \d+\r?\n
+ (?:[a-zA-Z0-9+\/]*\r?\n)+
+ -----End \s Mix \s Key-----$/xmg;
+ $mixmasters{$keyid}->{'key'} = $_;
+ };
+
+ for my $keyid (keys %mixmasters) {
+ my $remailer_address = $mixmasters{$keyid}->{'address'};
+ (defined $mixmasters{$keyid}->{'nick'} && ! defined $mixmasters{$keyid}->{'key'}) and
+ cluck("Mixmaster key header without key in reply from $remailer_address"),
+ next;
+ (! defined $mixmasters{$keyid}->{'nick'} && defined $mixmasters{$keyid}->{'key'}) and
+ cluck("Mixmaster key without key header in reply from $remailer_address"),
+ next;
+
+ if ($remailer->{'address'} ne $remailer_address) {
+ # Address mismatch -> Ignore reply and add $remailer_address to prospective addresses
+ cluck("Remailer address mismatch $remailer->{'address'} vs $remailer_address. Adding latter to prospective remailers.");
+ Echolot::Globals::get()->{'storage'}->add_prospective_address($remailer_address, 'key-reply');
+ } else {
+ Echolot::Globals::get()->{'storage'}->restore_ttl( $remailer->{'address'} );
+ Echolot::Globals::get()->{'storage'}->set_key(
+ 'mix',
+ $mixmasters{$keyid}->{'nick'},
+ $mixmasters{$keyid}->{'address'},
+ $mixmasters{$keyid}->{'key'},
+ $keyid,
+ $mixmasters{$keyid}->{'version'},
+ $mixmasters{$keyid}->{'caps'},
+ $mixmasters{$keyid}->{'summary'},
+ $time);
+ }
+ };
+
+ return 1;
};
sub remailer_stats($$$) {