From 06563ad3a35b9fa4d00080215b9e7b32b22da650 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Thu, 16 Sep 2004 10:44:47 +0000 Subject: [PATCH] Support more of the milter functionality (header changes) git-svn-id: https://svn.perl.org/qpsmtpd/trunk@318 958fd67b-6ff1-0310-b445-bb7760255be9 --- plugins/milter | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/plugins/milter b/plugins/milter index e5f958b..3997c0b 100644 --- a/plugins/milter +++ b/plugins/milter @@ -75,20 +75,20 @@ sub check_results { $transaction->body_write($result->{value}); } else { - $transaction->header->add($result->{header}, $result->{value}); + push @{$transaction->notes('milter_header_changes')->{add}}, + [$result->{header}, $result->{value}]; } } elsif ($result->{action} eq 'delete') { - $transaction->header->delete($result->{header}); + push @{$transaction->notes('milter_header_changes')->{delete}}, + $result->{header}; } elsif ($result->{action} eq 'accept') { # TODO - figure out what this is used for } elsif ($result->{action} eq 'replace') { - $transaction->header->replace($result->{header}, $result->{value}); - } - elsif ($result->{action} eq 'continue') { - # just carry on as normal + push @{$transaction->notes('milter_header_changes')->{replace}}, + [$result->{header}, $result->{value}]; } } } @@ -102,7 +102,10 @@ sub connect_handler { $milter->protocol_negotiation(); $self->qp->connection->notes(milter => $milter); - + + $self->qp->connection->notes( + milter_header_changes => { add => [], delete => [], replace => [], } + ); my $remote_ip = $self->qp->connection->remote_ip; my $remote_host = $self->qp->connection->remote_host; $self->log(LOGDEBUG, "milter $self->{name} checking connect from $remote_host\[$remote_ip\]"); @@ -221,6 +224,18 @@ sub data_handler { $milter->send_end_body()) }; return(DENY, $@) if $@; + my $milter_header_changes = $transaction->notes('milter_header_changes'); + + foreach my $add (@{$milter_header_changes->{add}}) { + $headers->add($add->[0], $add->[1]); + } + foreach my $del (@{$milter_header_changes->{'delete'}}) { + $headers->delete($del); + } + foreach my $repl (@{$milter_header_changes->{replace}}) { + $headers->replace($repl->[0], $repl->[1]); + } + return DECLINED; }