| 1 |
package Echolot::Conf;
|
| 2 |
|
| 3 |
# (c) 2002 Peter Palfrader <peter@palfrader.org>
|
| 4 |
# $Id: Conf.pm,v 1.3 2002/06/10 06:24:31 weasel Exp $
|
| 5 |
#
|
| 6 |
|
| 7 |
=pod
|
| 8 |
|
| 9 |
=head1 Name
|
| 10 |
|
| 11 |
Echolot::Conf - remailer Configuration/Capabilities
|
| 12 |
|
| 13 |
=head1 DESCRIPTION
|
| 14 |
|
| 15 |
This package provides functions for requesting, parsing, and analyzing
|
| 16 |
remailer-conf and remailer-key replies.
|
| 17 |
|
| 18 |
=cut
|
| 19 |
|
| 20 |
use strict;
|
| 21 |
use warnings;
|
| 22 |
use Carp qw{cluck};
|
| 23 |
|
| 24 |
|
| 25 |
sub send_requests() {
|
| 26 |
Echolot::Globals::get()->{'storage'}->delay_commit();
|
| 27 |
for my $remailer (Echolot::Globals::get()->{'storage'}->get_addresses()) {
|
| 28 |
next unless ($remailer->{'status'} eq 'active');
|
| 29 |
for my $type (qw{conf key help stats}) {
|
| 30 |
Echolot::Tools::send_message(
|
| 31 |
'To' => $remailer->{'address'},
|
| 32 |
'Subject' => 'remailer-'.$type,
|
| 33 |
'Token' => $type.'.'.$remailer->{'id'})
|
| 34 |
};
|
| 35 |
Echolot::Globals::get()->{'storage'}->decrease_ttl($remailer->{'address'});
|
| 36 |
};
|
| 37 |
Echolot::Globals::get()->{'storage'}->enable_commit();
|
| 38 |
};
|
| 39 |
|
| 40 |
sub remailer_conf($$$) {
|
| 41 |
my ($conf, $token, $time) = @_;
|
| 42 |
|
| 43 |
my ($id) = $token =~ /^conf\.(\d+)$/;
|
| 44 |
(defined $id) or
|
| 45 |
cluck ("Returned token '$token' has no id at all"),
|
| 46 |
return 0;
|
| 47 |
|
| 48 |
cluck("Could not find id in token '$token'"), return 0 unless defined $id;
|
| 49 |
my ($remailer_type) = ($conf =~ /^\s*Remailer-Type:\s* (.*?) \s*$/imx);
|
| 50 |
cluck("No remailer type found in remailer_conf from '$token'"), return 0 unless defined $remailer_type;
|
| 51 |
my ($remailer_caps) = ($conf =~ /^\s*( \$remailer{".*"} \s*=\s* "<.*@.*>.*"; )\s*$/imx);
|
| 52 |
cluck("No remailer caps found in remailer_conf from '$token'"), return 0 unless defined $remailer_caps;
|
| 53 |
my ($remailer_nick, $remailer_address) = ($remailer_caps =~ /^\s* \$remailer{"(.*)"} \s*=\s* "<(.*@.*)>.*"; \s*$/ix);
|
| 54 |
cluck("No remailer nick found in remailer_caps from '$token': '$remailer_caps'"), return 0 unless defined $remailer_nick;
|
| 55 |
cluck("No remailer address found in remailer_caps from '$token': '$remailer_caps'"), return 0 unless defined $remailer_address;
|
| 56 |
|
| 57 |
|
| 58 |
my $remailer = Echolot::Globals::get()->{'storage'}->get_address_by_id($id);
|
| 59 |
cluck("No remailer found for id '$id'"), return 0 unless defined $remailer;
|
| 60 |
if ($remailer->{'address'} ne $remailer_address) {
|
| 61 |
# Address mismatch -> Ignore reply and add $remailer_address to prospective addresses
|
| 62 |
cluck("Remailer address mismatch $remailer->{'address'} vs $remailer_address. Adding latter to prospective remailers.");
|
| 63 |
Echolot::Globals::get()->{'storage'}->add_prospective_address($remailer_address, 'self-capsstring-conf', $remailer_address);
|
| 64 |
} else {
|
| 65 |
Echolot::Globals::get()->{'storage'}->restore_ttl( $remailer->{'address'} );
|
| 66 |
Echolot::Globals::get()->{'storage'}->set_caps($remailer_type, $remailer_caps, $remailer_nick, $remailer_address, $time);
|
| 67 |
}
|
| 68 |
|
| 69 |
|
| 70 |
# Fetch prospective remailers from reliable's remailer-conf reply:
|
| 71 |
my @lines = split /\r?\n/, $conf;
|
| 72 |
while (@lines) {
|
| 73 |
my $head = $lines[0];
|
| 74 |
chomp $head;
|
| 75 |
shift @lines;
|
| 76 |
last if ($head eq 'SUPPORTED CPUNK (TYPE I) REMAILERS');
|
| 77 |
};
|
| 78 |
|
| 79 |
while (@lines) {
|
| 80 |
my $head = $lines[0];
|
| 81 |
chomp $head;
|
| 82 |
shift @lines;
|
| 83 |
last unless ($head =~ /<(.*?@.*?)>/);
|
| 84 |
Echolot::Globals::get()->{'storage'}->add_prospective_address($1, 'reliable-caps-reply-type1', $remailer_address);
|
| 85 |
};
|
| 86 |
|
| 87 |
while (@lines) {
|
| 88 |
my $head = $lines[0];
|
| 89 |
chomp $head;
|
| 90 |
shift @lines;
|
| 91 |
last if ($head eq 'SUPPORTED MIXMASTER (TYPE II) REMAILERS');
|
| 92 |
};
|
| 93 |
|
| 94 |
while (@lines) {
|
| 95 |
my $head = $lines[0];
|
| 96 |
chomp $head;
|
| 97 |
last unless ($head =~ /\s(.*?@.*?)\s/);
|
| 98 |
shift @lines;
|
| 99 |
Echolot::Globals::get()->{'storage'}->add_prospective_address($1, 'reliable-caps-reply-type2', $remailer_address);
|
| 100 |
};
|
| 101 |
|
| 102 |
return 1;
|
| 103 |
};
|
| 104 |
|
| 105 |
sub remailer_key($$$) {
|
| 106 |
my ($conf, $token, $time) = @_;
|
| 107 |
|
| 108 |
my ($id) = $token =~ /^key\.(\d+)$/;
|
| 109 |
(defined $id) or
|
| 110 |
cluck ("Returned token '$token' has no id at all"),
|
| 111 |
return 0;
|
| 112 |
|
| 113 |
my $remailer = Echolot::Globals::get()->{'storage'}->get_address_by_id($id);
|
| 114 |
cluck("No remailer found for id '$id'"), return 0 unless defined $remailer;
|
| 115 |
# -----Begin Mix Key-----
|
| 116 |
# 7f6d997678b19ccac110f6e669143126
|
| 117 |
# 258
|
| 118 |
# AASyedeKiP1/UKyfrBz2K6gIhv4jfXIaHo8dGmwD
|
| 119 |
# KqkG3DwytgSySSY3wYm0foT7KvEnkG2aTi/uJva/
|
| 120 |
# gymE+tsuM8l8iY1FOiXwHWLDdyUBPbrLjRkgm7GD
|
| 121 |
# Y7ogSjPhVLeMpzkSyO/ryeUfLZskBUBL0LxjLInB
|
| 122 |
# YBR3o6p/RiT0EQAAAAAAAAAAAAAAAAAAAAAAAAAA
|
| 123 |
# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
| 124 |
# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
| 125 |
# AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
| 126 |
# AAAAAAAAAAAAAAAAAAAAAQAB
|
| 127 |
# -----End Mix Key-----
|
| 128 |
|
| 129 |
my %mixmasters;
|
| 130 |
# rot26 rot26@mix.uucico.de 7f6d997678b19ccac110f6e669143126 2.9b33 MC
|
| 131 |
my @mix_confs = ($conf =~ /^[a-z0-9]+ \s+ \S+\@\S+ \s+ [0-9a-f]{32} (?:\s+ \S+ \s+ \S+)?/xmg);
|
| 132 |
my @mix_keys = ($conf =~ /^-----Begin \s Mix \s Key-----\r?\n
|
| 133 |
[0-9a-f]{32}\r?\n
|
| 134 |
\d+\r?\n
|
| 135 |
(?:[a-zA-Z0-9+\/]*\r?\n)+
|
| 136 |
-----End \s Mix \s Key-----$/xmg );
|
| 137 |
for (@mix_confs) {
|
| 138 |
my ($nick, $address, $keyid, $version, $caps) = /^([a-z0-9]+) \s+ (\S+@\S+) \s+ ([0-9a-f]{32}) (?:(\S+) \s+ (\S+))?/x;
|
| 139 |
$mixmasters{$keyid} = {
|
| 140 |
nick => $nick,
|
| 141 |
address => $address,
|
| 142 |
version => $version,
|
| 143 |
caps => $caps,
|
| 144 |
summary => $_
|
| 145 |
};
|
| 146 |
};
|
| 147 |
for (@mix_keys) {
|
| 148 |
my ($keyid) = /^-----Begin \s Mix \s Key-----\r?\n
|
| 149 |
([0-9a-f]{32})\r?\n
|
| 150 |
\d+\r?\n
|
| 151 |
(?:[a-zA-Z0-9+\/]*\r?\n)+
|
| 152 |
-----End \s Mix \s Key-----$/xmg;
|
| 153 |
$mixmasters{$keyid}->{'key'} = $_;
|
| 154 |
};
|
| 155 |
|
| 156 |
for my $keyid (keys %mixmasters) {
|
| 157 |
my $remailer_address = $mixmasters{$keyid}->{'address'};
|
| 158 |
(defined $mixmasters{$keyid}->{'nick'} && ! defined $mixmasters{$keyid}->{'key'}) and
|
| 159 |
cluck("Mixmaster key header without key in reply from $remailer_address"),
|
| 160 |
next;
|
| 161 |
(! defined $mixmasters{$keyid}->{'nick'} && defined $mixmasters{$keyid}->{'key'}) and
|
| 162 |
cluck("Mixmaster key without key header in reply from $remailer_address"),
|
| 163 |
next;
|
| 164 |
|
| 165 |
if ($remailer->{'address'} ne $remailer_address) {
|
| 166 |
# Address mismatch -> Ignore reply and add $remailer_address to prospective addresses
|
| 167 |
cluck("Remailer address mismatch $remailer->{'address'} vs $remailer_address. Adding latter to prospective remailers.");
|
| 168 |
Echolot::Globals::get()->{'storage'}->add_prospective_address($remailer_address, 'self-capsstring-key', $remailer_address);
|
| 169 |
} else {
|
| 170 |
Echolot::Globals::get()->{'storage'}->restore_ttl( $remailer->{'address'} );
|
| 171 |
Echolot::Globals::get()->{'storage'}->set_key(
|
| 172 |
'mix',
|
| 173 |
$mixmasters{$keyid}->{'nick'},
|
| 174 |
$mixmasters{$keyid}->{'address'},
|
| 175 |
$mixmasters{$keyid}->{'key'},
|
| 176 |
$keyid,
|
| 177 |
$mixmasters{$keyid}->{'version'},
|
| 178 |
$mixmasters{$keyid}->{'caps'},
|
| 179 |
$mixmasters{$keyid}->{'summary'},
|
| 180 |
$time);
|
| 181 |
}
|
| 182 |
};
|
| 183 |
|
| 184 |
return 1;
|
| 185 |
};
|
| 186 |
|
| 187 |
sub remailer_stats($$$) {
|
| 188 |
my ($conf, $token, $time) = @_;
|
| 189 |
|
| 190 |
#print "Remailer stats\n";
|
| 191 |
};
|
| 192 |
|
| 193 |
sub remailer_help($$$) {
|
| 194 |
my ($conf, $token, $time) = @_;
|
| 195 |
|
| 196 |
#print "Remailer help\n";
|
| 197 |
};
|
| 198 |
|
| 199 |
1;
|
| 200 |
# vim: set ts=4 shiftwidth=4:
|