fix timestamp matching regex, add lmtp to receving service regex and skip lines not including the main target service name in maillog parser
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -104,6 +104,10 @@ class MailLogParser
|
|||||||
unset($matches);
|
unset($matches);
|
||||||
$line = fgets($file_handle);
|
$line = fgets($file_handle);
|
||||||
|
|
||||||
|
if (strpos($line, 'postfix') === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$timestamp = $this->getLogTimestamp($line);
|
$timestamp = $this->getLogTimestamp($line);
|
||||||
if ($this->startTime < $timestamp) {
|
if ($this->startTime < $timestamp) {
|
||||||
if (preg_match("/postfix\/qmgr.*(?::|\])\s([A-Z\d]+).*from=<?(?:.*\@([a-zA-Z\d\.\-]+))?>?, size=(\d+),/", $line, $matches)) {
|
if (preg_match("/postfix\/qmgr.*(?::|\])\s([A-Z\d]+).*from=<?(?:.*\@([a-zA-Z\d\.\-]+))?>?, size=(\d+),/", $line, $matches)) {
|
||||||
@@ -112,7 +116,7 @@ class MailLogParser
|
|||||||
"domainFrom" => strtolower($matches[2]),
|
"domainFrom" => strtolower($matches[2]),
|
||||||
"size" => $matches[3]
|
"size" => $matches[3]
|
||||||
];
|
];
|
||||||
} elseif (preg_match("/postfix\/(?:pipe|smtp).*(?::|\])\s([A-Z\d]+).*to=<?(?:.*\@([a-zA-Z\d\.\-]+))?>?,/", $line, $matches)) {
|
} elseif (preg_match("/postfix\/(?:pipe|smtp|lmtp).*(?::|\])\s([A-Z\d]+).*to=<?(?:.*\@([a-zA-Z\d\.\-]+))?>?,/", $line, $matches)) {
|
||||||
// Postfix to
|
// Postfix to
|
||||||
if (array_key_exists($matches[1], $this->mails)) {
|
if (array_key_exists($matches[1], $this->mails)) {
|
||||||
$this->mails[$matches[1]]["domainTo"] = strtolower($matches[2]);
|
$this->mails[$matches[1]]["domainTo"] = strtolower($matches[2]);
|
||||||
@@ -149,7 +153,7 @@ class MailLogParser
|
|||||||
private function getLogTimestamp($line)
|
private function getLogTimestamp($line)
|
||||||
{
|
{
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2})/i", $line, $matches)) {
|
if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}).\d{2}:\d{2}:\d{2})/i", $line, $matches)) {
|
||||||
$timestamp = strtotime($matches[1]);
|
$timestamp = strtotime($matches[1]);
|
||||||
if ($timestamp > ($this->startTime + 60 * 60 * 24)) {
|
if ($timestamp > ($this->startTime + 60 * 60 * 24)) {
|
||||||
return strtotime($matches[1] . " -1 year");
|
return strtotime($matches[1] . " -1 year");
|
||||||
@@ -258,6 +262,10 @@ class MailLogParser
|
|||||||
unset($matches);
|
unset($matches);
|
||||||
$line = fgets($file_handle);
|
$line = fgets($file_handle);
|
||||||
|
|
||||||
|
if (strpos($line, 'dovecot') === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$timestamp = $this->getLogTimestamp($line);
|
$timestamp = $this->getLogTimestamp($line);
|
||||||
if ($this->startTime < $timestamp) {
|
if ($this->startTime < $timestamp) {
|
||||||
if (preg_match("/dovecot.*(?::|\]) imap\(.*@([a-z0-9\.\-]+)\)(<\d+><[a-z0-9+\/=]+>)?:.*(?:in=(\d+) out=(\d+)|bytes=(\d+)\/(\d+))/i", $line, $matches)) {
|
if (preg_match("/dovecot.*(?::|\]) imap\(.*@([a-z0-9\.\-]+)\)(<\d+><[a-z0-9+\/=]+>)?:.*(?:in=(\d+) out=(\d+)|bytes=(\d+)\/(\d+))/i", $line, $matches)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user