]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support rmilter block and dkim signature in CGP helper
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 3 Mar 2017 13:32:42 +0000 (13:32 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 3 Mar 2017 13:32:42 +0000 (13:32 +0000)
utils/cgp_rspamd.pl

index c7c4cef85317810287891af5eb1d2686161f330b..90fa43f9044aed20d6223af711c3da82f8068f1b 100644 (file)
@@ -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";
+          }
         }
       }
     }