/[echolot]/trunk/Echolot/Config.pm
ViewVC logotype

Contents of /trunk/Echolot/Config.pm

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: 2165 byte(s)
Trimmed down config file and set sane defaults
1 package Echolot::Config;
2
3 # (c) 2002 Peter Palfrader <peter@palfrader.org>
4 # $Id: Config.pm,v 1.2 2002/07/02 14:11:49 weasel Exp $
5 #
6
7 =pod
8
9 =head1 Name
10
11 Echolot::Config - echolot configuration
12
13 =head1 DESCRIPTION
14
15 =cut
16
17 use strict;
18 use warnings;
19 use XML::Parser;
20 use XML::Dumper;
21 use Carp;
22
23 my $CONFIG;
24
25 sub init($) {
26 my ($params) = @_;
27
28 my $DEFAULT;
29 $DEFAULT->{'recipient_delimiter'} = '+';
30 $DEFAULT->{'dev_random'} = '/dev/random';
31 $DEFAULT->{'hash_len'} = 8;
32
33 $DEFAULT = {
34 addresses_default_ttl => 5, # days
35 smarthost => 'localhost',
36 mailindir => 'mail/IN',
37 mailerrordir => 'mail/ERROR',
38 ping_new => 1,
39 show_new => 1,
40 pinger_interval => 300,
41 ping_every_nth_time => 48,
42 resultdir => 'results',
43 gnupghome => 'gnupg',
44 tmpdir => 'tmp',
45 prospective_addresses_ttl => 432000, # 5 days
46 reliable_auto_add_min => 3, # 3 remailes need to list new address
47 commands_file => 'commands.txt',
48 pidfile => 'pingd.pid',
49 expire_keys => 432000, # 5 days
50 expire_confs => 432000, # 5 days
51 expire_pings => 1123200, # 12 days
52 storage => {
53 backend => 'File',
54 File => {
55 basedir => 'data'
56 }
57 },
58
59 homedir => undef,
60 my_localpart => undef,
61 my_domain => undef,
62 };
63
64 {
65 my $parser = new XML::Parser(Style => 'Tree');
66 my $tree = $parser->parsefile('pingd.conf');
67 my $dump = new XML::Dumper;
68 $CONFIG = $dump->xml2pl($tree);
69 }
70
71 for my $key (keys %$DEFAULT) {
72 $CONFIG->{$key} = $DEFAULT->{$key} unless defined $CONFIG->{$key};
73 };
74
75 for my $key (keys %$params) {
76 $CONFIG->{$key} = $DEFAULT->{$key} if defined $CONFIG->{$key};
77 };
78
79
80 for my $key (keys %$CONFIG) {
81 warn ("Config option $key is not defined\n") unless defined $CONFIG->{$key};
82 };
83 };
84
85 sub get() {
86 return $CONFIG;
87 };
88
89 1;
90 # vim: set ts=4 shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.5