adding to log lines

This commit is contained in:
mischa 2022-08-20 08:18:32 +00:00
parent 25591c1875
commit e217de4fc9

View File

@ -64,7 +64,7 @@ while (my $line = <>) {
if ($event eq "tx-mail" && $code eq "ok") { if ($event eq "tx-mail" && $code eq "ok") {
$ooo{$sid} = 1; $ooo{$sid} = 1;
$from = $address; $from = $address;
print $fh (gettime() . "Virtual Vacation: created session $sid\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid created session $sid\n") if ($opt_d);
if ($from =~ m/^(postmaster|hostmaster|noreply|no-reply|bounce.*)@/i) { $ooo{$sid} = 0; } if ($from =~ m/^(postmaster|hostmaster|noreply|no-reply|bounce.*)@/i) { $ooo{$sid} = 0; }
} elsif ($event eq "tx-mail" && $code ne "ok") { } elsif ($event eq "tx-mail" && $code ne "ok") {
$ooo{$sid} = 0; $ooo{$sid} = 0;
@ -73,7 +73,7 @@ while (my $line = <>) {
$email = $address; $email = $address;
} elsif ($event eq "tx-rcpt" && $code ne "ok") { } elsif ($event eq "tx-rcpt" && $code ne "ok") {
delete $ooo{$sid}; delete $ooo{$sid};
print $fh (gettime() . "Virtual Vacation: removed session $sid\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid removed session $sid\n") if ($opt_d);
} }
} }
if ($line =~ m/^filter/) { if ($line =~ m/^filter/) {
@ -83,28 +83,28 @@ while (my $line = <>) {
if (!$data) { $data = ""; } if (!$data) { $data = ""; }
if ($data =~ m/^precedence:\s+(bulk|list|junk)/i) { if ($data =~ m/^precedence:\s+(bulk|list|junk)/i) {
$ooo{$sid} = 0; $ooo{$sid} = 0;
print $fh (gettime() . "Virtual Vacation: header found $data\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid header found $data\n") if ($opt_d);
} }
if ($data =~ m/^list-(help|id|owner|post|subscribe|unsubscribe):.*/i) { if ($data =~ m/^list-(help|id|owner|post|subscribe|unsubscribe):.*/i) {
$ooo{$sid} = 0; $ooo{$sid} = 0;
print $fh (gettime() . "Virtual Vacation: header found $data\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid header found $data\n") if ($opt_d);
} }
if ($data =~ m/^x-loop:\s+opensmtpd\ admin\ virtual\ vacation/i) { $ooo{$sid} = 0; } if ($data =~ m/^x-loop:\s+opensmtpd\ admin\ virtual\ vacation/i) { $ooo{$sid} = 0; }
print STDOUT "filter-dataline|$sid|$token|$data\n"; print STDOUT "filter-dataline|$sid|$token|$data\n";
} }
if ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 1) { if ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 1) {
print $fh (gettime() . "Virtual Vacation: To: $email, From: $from\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid to: $email, from: $from\n") if ($opt_d);
my $query = qq{SELECT subject,body FROM vacation WHERE email='$email' and active=1}; my $query = qq{SELECT subject,body FROM vacation WHERE email='$email' and active=1};
my $sth = doquery($query); my $sth = doquery($query);
my $rv = $sth->rows; my $rv = $sth->rows;
if ($rv == 1) { if ($rv == 1) {
print $fh (gettime() . "Virtual Vacation: Found OOO for $email\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid found OOO for $email\n") if ($opt_d);
my @vacation_msg = $sth->fetchrow_array; my @vacation_msg = $sth->fetchrow_array;
$query = qq{SELECT cache FROM vacation WHERE email='$email' AND FIND_IN_SET('$from',cache)}; $query = qq{SELECT cache FROM vacation WHERE email='$email' AND FIND_IN_SET('$from',cache)};
$sth = doquery($query); $sth = doquery($query);
$rv = $sth->rows; $rv = $sth->rows;
if ($rv == 0) { if ($rv == 0) {
print $fh (gettime() . "Virtual Vacation: Sending OOO to $from\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid sending OOO to $from\n") if ($opt_d);
$query = qq{UPDATE vacation SET cache=CONCAT(cache,',','$from') WHERE email='$email'}; $query = qq{UPDATE vacation SET cache=CONCAT(cache,',','$from') WHERE email='$email'};
$sth = doquery($query); $sth = doquery($query);
open my $fh_email, "|-", "/usr/sbin/sendmail -t"; open my $fh_email, "|-", "/usr/sbin/sendmail -t";
@ -117,11 +117,11 @@ while (my $line = <>) {
close $fh_email; close $fh_email;
} }
delete $ooo{$sid}; delete $ooo{$sid};
print $fh (gettime() . "Virtual Vacation: removed session $sid\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid removed session $sid\n") if ($opt_d);
} }
} elsif ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 0) { } elsif ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 0) {
delete $ooo{$sid}; delete $ooo{$sid};
print $fh (gettime() . "Virtual Vacation: removed session $sid\n") if ($opt_d); print $fh (gettime() . "Virtual Vacation: $sid removed session $sid\n") if ($opt_d);
} }
} }
} }