summaryrefslogtreecommitdiff
path: root/Echolot/Pinger/Mix.pm
blob: afe957f57ebbf2336c0af078323cf035ffd95649 (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
package Echolot::Pinger::Mix;

# (c) 2002 Peter Palfrader <peter@palfrader.org>
# $Id: Mix.pm,v 1.1 2002/06/11 09:53:35 weasel Exp $
#

=pod

=head1 Name

Echolot::Pinger::Mix - send mix pings

=head1 DESCRIPTION

This package provides functions for sending mixmaster (type II) pings.

=cut

use strict;
use warnings;
use Carp qw{cluck};
use English;

sub ping($$$$) {
	my ($body, $to, $chain, $keys) = @_;

	my $keyring = Echolot::Config::get()->{'Pinger::Mix'}->{'mixdir'}.'/pubring.mix';
	open (F, '>'.$keyring) or
		cluck("Cannot open $keyring for writing: $!"),
		return 0;
	for my $keyid (keys %$keys) {
		print (F $keys->{$keyid}->{'summary'}, "\n\n");
		print (F $keys->{$keyid}->{'key'},"\n\n");
	};
	close (F) or
		cluck("Cannot close $keyring"),
		return 0;
	
	open(MIX, "|".Echolot::Config::get()->{'Pinger::Mix'}->{'mix'}." -m -S -l $chain") or
		cluck("Cannot exec mixpinger: $!"),
		return 0;
	print MIX "To: $to\n\n$body";
	close (MIX);
	    
	return 1;
};

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