/[echolot]/trunk/pingd
ViewVC logotype

Contents of /trunk/pingd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (show annotations) (download)
Tue Jul 2 14:11:49 2002 UTC (10 years, 10 months ago) by weasel
File size: 4766 byte(s)
Trimmed down config file and set sane defaults
1 #!/usr/bin/perl -wT
2
3 # (c) 2002 Peter Palfrader <peter@palfrader.org>
4 # $Id: pingd,v 1.8 2002/07/02 14:11:49 weasel Exp $
5 #
6
7 =pod
8
9 =head1 NAME
10
11 pingd - echolot ping daemon
12
13 =head1 SYNOPSIS
14
15 =over
16
17 =item B<pingd> B<start>
18
19 =item B<pingd> B<stop>
20
21 =item B<pingd> B<add> I<address>
22
23 =back
24
25 =head1 DESCRIPTION
26
27 pingd is a the heart of echolot. Echolot is a pinger for anonymous remailers.
28
29 A Pinger in the context of anonymous remailers is a program that regularily
30 sends messages through remailers to check their reliability. It then calculates
31 reliability statistics which are used by remailer clients to choose the chain
32 of remailers to use.
33
34 Additionally it collects configuration parameters and keys of all remailers and
35 offers them in a format readable by remailer clients.
36
37 When called without parameters pingd schedules tasks like sending pings,
38 processing incoming mail and requesting remailer-xxx data and runs them in
39 configurable intervalls.
40
41 =head1 COMMANDS
42
43 =over
44
45 =item B<start>
46
47 Start the ping daemon.
48
49 =item B<stop>
50
51 Send the running pingd process a SIGTERM.
52
53 =item B<add> I<address>
54
55 Add I<address> to the list of remailers to query for
56 keys and confs.
57
58 =head1 OPTIONS
59
60 none
61
62 =back
63
64 =head1 FILES
65
66 F<pingd.conf>
67
68 =head1 AUTHOR
69
70 Peter Palfrader E<lt>peter@palfrader.org<gt>
71
72 =head1 SEE ALSO
73
74 echolot Documentation
75
76 =head1 BUGS
77
78 Please report them at <lt>URL:http://savannah.gnu.org/bugs/?group=echolot<gt>
79
80 =cut
81
82 use strict;
83 use XML::Parser;
84 use XML::Dumper;
85 use Getopt::Long;
86 use English;
87 use lib qw{ . lib };
88 use Echolot::Config;
89 use Echolot::Globals;
90 use Echolot::Storage::File;
91 use Echolot::Scheduler;
92 use Echolot::Conf;
93 use Echolot::Mailin;
94 use Echolot::Pinger;
95 use Echolot::Stats;
96 use Echolot::Commands;
97
98 $ENV{'PATH'} = '/bin:/usr/bin';
99 delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
100
101
102 my $scheduler;
103
104 sub setSigHandlers() {
105 $SIG{'HUP'} = sub {
106 print "Got SIGINT. scheduling readcommands\n";
107 $scheduler->schedule('readcommands', time() );
108 };
109 $SIG{'INT'} = sub {
110 print "Got SIGINT. scheduling exit\n";
111 $scheduler->schedule('exit', time() );
112 };
113 $SIG{'QUIT'} = sub {
114 print "Got SIGQUIT. scheduling exit\n";
115 $scheduler->schedule('exit', time() );
116 };
117 $SIG{'TERM'} = sub {
118 print "Got SIGTERM. scheduling exit\n";
119 $scheduler->schedule('exit', time() );
120 };
121 };
122
123 sub commit_prospective_address() {
124 Echolot::Globals::get()->{'storage'}->commit_prospective_address();
125 };
126 sub expire() {
127 Echolot::Globals::get()->{'storage'}->expire();
128 };
129
130
131
132
133 #Echolot::Mailin::process();
134 #Echolot::Pinger::send_pings();
135 #Echolot::Mailin::process();
136 #Echolot::Conf::send_requests();
137 #Echolot::Stats::build();
138
139
140
141 my $params;
142 Getopt::Long::config('bundling');
143 if (!GetOptions (
144 'help' => \$params->{'help'},
145 'verbose' => \$params->{'verbose'}
146 )) {
147 die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [-fwhv]\n");
148 };
149 if ($params->{'help'}) {
150 print ("Usage: $PROGRAM_NAME [options]\n"); #FIXME
151 exit 0;
152 };
153
154 my $COMMAND = shift @ARGV;
155 die ("command required\n") unless defined $COMMAND;
156
157
158 Echolot::Config::init( $params );
159 chdir( Echolot::Config::get()->{'homedir'} );
160 Echolot::Globals::init();
161
162
163 if ($COMMAND eq 'add') {
164 my $address = shift @ARGV;
165 die ("add requires argument <address>\n") unless defined $address;
166 die ("argument <address> is not a valid email address\n") unless ($address =~ /^[a-zA-Z0-9+.-]+\@[a-zA-Z0-9+.-]+$/ );
167 Echolot::Commands::addCommand("add $address");
168 # FIXME send hup
169 } elsif ($COMMAND eq 'stop') {
170 die ("stop not implemented yet");
171 } elsif ($COMMAND eq 'start') {
172 Echolot::Globals::initStorage();
173 setSigHandlers();
174
175 $scheduler = new Echolot::Scheduler;
176 $scheduler->add('exit' , -1 , 0, 'exit' );
177 $scheduler->add('readcommands' , -1 , 0, \&Echolot::Commands::processCommands );
178
179 $scheduler->add('processmail' , 60 , 0, \&Echolot::Mailin::process );
180 $scheduler->add('ping' , Echolot::Config::get()->{'pinger_interval'} , 0, \&Echolot::Pinger::send_pings );
181 $scheduler->add('buildstats' , 60 , 0, \&Echolot::Stats::build );
182
183 $scheduler->add('commitprospectives' , 30*60 , 0, \&commit_prospective_address );
184 $scheduler->add('expire' , 15*60 , 0, \&expire );
185 $scheduler->add('getkeyconf' , 24*60*60 , 0, \&Echolot::Conf::send_requests );
186
187 $scheduler->run();
188
189 Echolot::Globals::get()->{'storage'}->commit();
190 Echolot::Globals::get()->{'storage'}->finish();
191 } else {
192 die ("Command $COMMAND unknown");
193 };
194
195 exit 0;
196
197 # vim: set ts=4 shiftwidth=4:

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5