https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7649

            Bug ID: 7649
           Summary: FEATURE PATCH: Added output for spamd logs to show
                    relay ip addresses
           Product: Spamassassin
           Version: 3.4.1
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: spamc/spamd
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: Undefined

--- spamd       2018-10-23 14:27:28.948367854 +0200
+++ ../spamd    2018-10-23 13:17:52.001146322 +0200
@@ -1985,7 +1985,29 @@
   }

   my $scantime = sprintf( "%.1f", time - $start_time );
-
+ 
############################################################################################
 
+  ## 
+  ## Hack added by to add relay server addresses to base report (can be used
by fail2ban, etc)
+  ##  
+  my @from_addrs = $mail->get_pristine_header("Received"); 
+  my $nums = @from_addrs; 
+  my $line; 
+  my @raddrs; 
+  my %seen;
+  my @raddrs_uniq;
+  foreach $line (@from_addrs){ 
+  if($line=~/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/) { 
+  if($1 == 127 && $2 == 0 && $3 == 0 && $4 == 1) { 
+  }else{ 
+  push(@raddrs, "$1.$2.$3.$4"); 
+  } 
+  } # end if 
+  } # end foreach 
+  %seen = ();
+  @raddrs_uniq = grep { ! $seen{$_} ++ } @raddrs;
+  my $from_addrs2 = join(",",@raddrs_uniq); 
+  
+ 
############################################################################################
   info("spamd: $was_it_spam ($msg_score/$msg_threshold) for $current_user:$>
in"
        . " $scantime seconds, $actual_length bytes." );

@@ -1995,7 +2017,8 @@
             "user=".$current_user, "uid=".$>,
             "required_score=".$msg_threshold,
             "rhost=".$remote_hostname, "raddr=".$remote_hostaddr,
-            "rport=".$remote_port);
+            "rport=".$remote_port,
+            "num_relays=".$nums, "sender_ips=".$from_addrs2);

   {
     # no re "strict";  # since perl 5.21.8: Ranges of ASCII printables...

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to