Permalink
Browse files

http_config plugin

other minor changes

update STATUS and Changes


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@96 958fd67b-6ff1-0310-b445-bb7760255be9
  • Loading branch information...
1 parent 9d5610a commit f9113eb73a815114769afc6c8ef6575a3d6ecf73 @abh abh committed Nov 6, 2002
Showing with 73 additions and 1 deletion.
  1. +15 −0 Changes
  2. +2 −0 STATUS
  3. +50 −0 plugins/http_config
  4. +6 −1 plugins/quit_fortune
View
15 Changes
@@ -1,3 +1,18 @@
+0.20 - development
+
+ Store hooks runtime config globally so they will work within the
+ transaction objects too.
+
+ content_log plugin - log the content of all mails for
+ debugging. Robert Spier <robert@perl.org>.
+
+ http_config plugin - get configuration via http
+
+ plugins can take arguments via their line in the "plugins" file
+
+ make the quit_fortune plugin check that the fortune program exists
+
+
0.12 - 2002/10/17
Better error messages when a plugin fails
View
2 STATUS
@@ -12,6 +12,8 @@ plugin support;
plugin access to the data line by line during the DATA phase
(instead of just after)
+ if qmail-queue can't be loaded we still return 250 ?!
+
TRACE in Constants.pm is not actually being used. Should it be?
View
@@ -0,0 +1,50 @@
+=head1 NAME
+
+http_config
+
+=head1 DESCRIPTION
+
+Example config plugin. Gets configuration data via http requests.
+
+=head1 CONFIG
+
+http_config is configured at plugin loading time via the plugins
+config. Load the plugin with a list of urls like the folllowing.
+
+ http_config http://localhost/~smtpd/config/ http://www.example.com/cgi-bin/qp?config=
+
+Looking to config "me", qpsmtpd will try loading
+http://localhost/~smtpd/config/me and if failing that then try
+http://www.example.com/cgi-bin/qp?config=me
+
+=head1 BUGS
+
+http_config doesn't do any caching. It should do some simple caching
+to be used in production.
+
+=cut
+
+use LWP::Simple qw(get);
+
+my @urls;
+
+sub register {
+ my ($self, $qp, @args) = @_;
+ @urls = @args;
+ $self->register_hook("config", "http_config");
+}
+
+sub http_config {
+ my ($self, $transaction, $config) = @_;
+ $self->log(0, "http_config called with $config");
+ for my $url (@urls) {
+ $self->log(10, "http_config loading from $url");
+ my @config = split /[\r\n]+/, (get "$url$config" || "");
+ chomp @config;
+ @config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/ } @config;
+ close CF;
+ $self->log(0, "returning http_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
+ return (OK, @config) if @config;
+ }
+ return DECLINED;
+}
View
@@ -10,7 +10,12 @@ sub quit_handler {
# fun, so skip it.
return (DECLINED) if ($qp->connection->hello || '') eq "ehlo";
- my @fortune = `/usr/games/fortune -s`;
+ my $fortune = '/usr/games/fortune';
+ return DECLINED unless -e $fortune;
+
+ # local %ENV = ();
+
+ my @fortune = `$fortune -s`;
@fortune = map { chop; s/^/ \/ /; $_ } @fortune;
$qp->respond(221, $qp->config('me') . " closing connection.", @fortune);
return DONE;

0 comments on commit f9113eb

Please sign in to comment.