diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-03 13:32:42 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-03 13:32:42 +0000 |
commit | 88e76379155c888abb15044211abb073e80e78dc (patch) | |
tree | 94142b6ec96c2ebc612823078d0ae90fd1838bd7 /utils | |
parent | 25c928083baa1487f1e1390f9f3c3e99c475f0b1 (diff) | |
download | rspamd-88e76379155c888abb15044211abb073e80e78dc.tar.gz rspamd-88e76379155c888abb15044211abb073e80e78dc.zip |
[Feature] Support rmilter block and dkim signature in CGP helper
Diffstat (limited to 'utils')
-rw-r--r-- | utils/cgp_rspamd.pl | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/utils/cgp_rspamd.pl b/utils/cgp_rspamd.pl index c7c4cef85..90fa43f90 100644 --- a/utils/cgp_rspamd.pl +++ b/utils/cgp_rspamd.pl @@ -63,7 +63,8 @@ sub rspamd_scan { print "$tag FAILURE\n"; } else { - my $def = $js->{'default'}; + my $def = $js->{'default'}; + my $headers = ""; if ( !$def ) { print @@ -85,18 +86,48 @@ sub rspamd_scan { "* Rspamd: Scanned %s; id: <%s>; Score: %.2f / %.2f; Symbols: [%s]\n", $file, $id, $def->{'score'}, $def->{'required_score'}, $symbols; + if ( $js->{'dkim-signature'} ) { + $headers .= "DKIM-Signature: " . $js->{'dkim-signature'}; + } + + if ( $js->{'rmilter'} ) { + my $block = $js->{'rmilter'}; + + if ( $block->{'add_headers'} ) { + while ( my ( $h, $v ) = each( %{ $block->{'add_headers'} } ) ) { + if ( $headers eq "" ) { + $headers .= "$h: $v"; + } + else { + $headers .= "\\e$h: $v"; + } + } + } + } + if ( $action eq 'reject' ) { print "$tag DISCARD\n"; + return; } elsif ( $action eq 'add header' || $action eq 'rewrite subject' ) { - print "$tag ADDHEADER " . cgp_string($header) . " OK\n"; + if ( $headers eq "" ) { + $headers .= "$header"; + } + else { + $headers .= "\\e$header"; + } } elsif ( $action eq 'soft reject' ) { print "$tag REJECT Try again later\n"; + return; } - else { + + if ( $headers eq "" ) { print "$tag OK\n"; } + else { + print "$tag ADDHEADER " . cgp_string($headers) . " OK\n"; + } } } } |