summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2002-07-03 11:08:21 +0000
committerPeter Palfrader <peter@palfrader.org>2002-07-03 11:08:21 +0000
commitf9a1bf5f001280fb7a22ba9f9613255fff35161d (patch)
treed126e7785a7d562993ce21c6bb2bb238ff1649bd /Echolot
parent574b2ca4b696c34d7f325df2d38384dfabe9ddb4 (diff)
Can set remailer caps manually (needed for remailers like passthru2 and lcs
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Commands.pm8
-rw-r--r--Echolot/Conf.pm31
-rw-r--r--Echolot/Stats.pm4
-rw-r--r--Echolot/Storage/File.pm46
4 files changed, 76 insertions, 13 deletions
diff --git a/Echolot/Commands.pm b/Echolot/Commands.pm
index d00f2c0..d5ef445 100644
--- a/Echolot/Commands.pm
+++ b/Echolot/Commands.pm
@@ -1,7 +1,7 @@
package Echolot::Commands;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Commands.pm,v 1.4 2002/07/03 00:54:40 weasel Exp $
+# $Id: Commands.pm,v 1.5 2002/07/03 11:08:21 weasel Exp $
#
=pod
@@ -71,6 +71,12 @@ sub processCommands($) {
Echolot::Globals::get()->{'scheduler'}->schedule('getkeyconf', time() );
} elsif ($command eq 'delete') {
Echolot::Globals::get()->{'storage'}->delete_remailer(@args);
+ } elsif ($command eq 'setremailercaps') {
+ my $addr = shift @args;
+ my $conf = join(' ', @args);
+ Echolot::Conf::set_caps_manually($addr, $conf);
+ } elsif ($command eq 'deleteremailercaps') {
+ Echolot::Globals::get()->{'storage'}->delete_remailercaps(@args);
} else {
warn("Unkown command: $_\n");
};
diff --git a/Echolot/Conf.pm b/Echolot/Conf.pm
index 6e8a6fd..bc14f84 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.9 2002/07/02 18:03:55 weasel Exp $
+# $Id: Conf.pm,v 1.10 2002/07/03 11:08:21 weasel Exp $
#
=pod
@@ -121,6 +121,35 @@ sub remailer_conf($$$) {
return 1;
};
+sub set_caps_manually($$) {
+ my ($addr, $caps) = @_;
+
+ defined $addr or
+ cluck("Address not defined."),
+ return 0;
+ defined $caps or
+ cluck("Caps not defined."),
+ return 0;
+
+ print "Setting caps for $addr manually to $caps\n"
+ if Echolot::Config::get()->{'verbose'};
+
+ my $remailer = Echolot::Globals::get()->{'storage'}->get_address($addr);
+ defined $remailer or
+ cluck("Remailer address $addr did not give a valid remailer."),
+ return 0;
+ my $id = $remailer->{'id'};
+ defined $id or
+ cluck("Remailer address $addr did not give a remailer with an id."),
+ return 0;
+ my $token = 'conf.'.$id;
+
+ my $conf = "Remailer-Type: set-manually\n$caps";
+ remailer_conf($conf, $token, time + 10 * 365 * 24 * 60 * 60); # FIXME: Y2036
+
+ return 1;
+};
+
sub parse_mix_key($$$) {
my ($reply, $time, $remailer) = @_;
diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm
index e1b68bb..2ed203f 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.9 2002/07/02 23:16:53 weasel Exp $
+# $Id: Stats.pm,v 1.10 2002/07/03 11:08:21 weasel Exp $
#
=pod
@@ -342,7 +342,7 @@ sub build_list2($$) {
printf F "\n\n\nRemailer-Capabilities:\n\n";
for my $remailer (sort {$a->{'caps'} cmp $b->{'caps'}} @$rems) {
- print F $remailer->{'caps'},"\n"
+ print F $remailer->{'caps'},"\n" if defined $remailer->{'caps'};
}
close (F);
diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm
index e082fbd..a075e93 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.24 2002/07/03 01:07:16 weasel Exp $
+# $Id: File.pm,v 1.25 2002/07/03 11:08:21 weasel Exp $
#
=pod
@@ -511,18 +511,28 @@ sub commit_prospective_address($) {
$self->enable_commit(1);
};
+sub get_address($$) {
+ my ($self, $addr) = @_;
+
+ defined ($self->{'METADATA'}->{'addresses'}->{$addr}) or
+ cluck ("$addr does not exist in Metadata"),
+ return undef;
+
+ my $result = {
+ status => $self->{'METADATA'}->{'addresses'}->{$addr}->{'status'},
+ id => $self->{'METADATA'}->{'addresses'}->{$addr}->{'id'},
+ address => $_,
+ fetch => $self->{'METADATA'}->{'addresses'}->{$addr}->{'fetch'},
+ };
+
+ return $result;
+};
+
sub get_addresses($) {
my ($self) = @_;
my @addresses = keys %{$self->{'METADATA'}->{'addresses'}};
- my @return_data = map {
- my %tmp;
- $tmp{'status'} = $self->{'METADATA'}->{'addresses'}->{$_}->{'status'};
- $tmp{'id'} = $self->{'METADATA'}->{'addresses'}->{$_}->{'id'};
- $tmp{'address'} = $_;
- $tmp{'fetch'} = $self->{'METADATA'}->{'addresses'}->{$_}->{'fetch'};
- \%tmp;
- } @addresses;
+ my @return_data = map { $self->get_address($_); } @addresses;
return @return_data;
};
@@ -949,6 +959,24 @@ sub delete_remailer($$) {
return 1;
};
+sub delete_remailercaps($$) {
+ my ($self, $address) = @_;
+
+ print "Deleting conf for remailer $address\n"
+ if Echolot::Config::get()->{'verbose'};
+
+ if (defined $self->{'METADATA'}->{'remailers'}->{$address}) {
+ delete $self->{'METADATA'}->{'remailers'}->{$address}->{'conf'}
+ if defined $self->{'METADATA'}->{'remailers'}->{$address}->{'conf'};
+ } else {
+ cluck("Remailer $address does not exist in remailers")
+ };
+ $self->commit();
+
+ return 1;
+};
+
+
# sub convert($) {