[pmg-devel] [pmg-log-tracker v2 1/2] Introduce before queue dstatus

Stoiko Ivanov s.ivanov at proxmox.com
Thu Apr 30 17:01:49 CEST 2020


Currently the status of a before queue filtered mail is the status of the
downstream delivery in case the downstream rejects or defers a mail.

This information is too little to distinguish between a mail which went
through the rule-system, and a locally generated one
(e.g. bounce or spamreport).

By introducing 3 new distinct dstatus values we can use the information to
correctly display the status of a mail in the GUI.

Reviewed-By: Mira Limbeck <m.limbeck at proxmox.com>
Tested-By: Mira Limbeck <m.limbeck at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/main.rs                         | 21 ++++++++++++++++++++-
 tests/test_output_before_queue      |  8 ++++----
 tests/test_output_before_queue_host |  8 ++++----
 tests/test_output_before_queue_qid  |  8 ++++----
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 7c4b71a..64f3e47 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -427,10 +427,23 @@ fn handle_lmtp_message(msg: &[u8], parser: &mut Parser, complete_line: &[u8]) {
         None => return,
     };
 
+    let mut dstatus = DStatus::Dsn(dsn);
+
+    // the dsn (enhanced status code can only have a class of 2, 4 or 5
+    // see https://tools.ietf.org/html/rfc3463
+    if qe.borrow_mut().bq_filtered {
+        dstatus = match dsn {
+            2 => DStatus::BqPass,
+            4 => DStatus::BqDefer,
+            5 => DStatus::BqReject,
+            _ => return,
+        }
+
+    }
     qe.borrow_mut().add_to_entry(
         to,
         relay,
-        DStatus::Dsn(dsn),
+        dstatus,
         parser.current_record_state.timestamp,
     );
 
@@ -761,6 +774,9 @@ enum DStatus {
     Block,
     Greylist,
     Noqueue,
+    BqPass,
+    BqDefer,
+    BqReject,
     Dsn(u32),
 }
 
@@ -779,6 +795,9 @@ impl std::fmt::Display for DStatus {
             DStatus::Block => 'B',
             DStatus::Greylist => 'G',
             DStatus::Noqueue => 'N',
+            DStatus::BqPass => 'P',
+            DStatus::BqDefer => 'D',
+            DStatus::BqReject => 'R',
             DStatus::Dsn(v) => std::char::from_digit(*v, 10).unwrap(),
         };
         write!(f, "{}", c)
diff --git a/tests/test_output_before_queue b/tests/test_output_before_queue
index 46e90dc..e51710d 100644
--- a/tests/test_output_before_queue
+++ b/tests/test_output_before_queue
@@ -48,10 +48,10 @@ CTIME: 5FDCCD39
 SIZE: 7298
 CLIENT: localhost.localdomain[127.0.0.1],
 MSGID: <xyz>
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
 SMTP:
 L0000001C Dec 18 15:36:32 proxmox-new postfix/smtpd[29902]: connect from test.localdomain[192.168.22.40]
 L0000001D Dec 18 15:36:33 proxmox-new postfix/smtpd[29902]: NOQUEUE: client=test.localdomain[192.168.22.40]
diff --git a/tests/test_output_before_queue_host b/tests/test_output_before_queue_host
index 31d70bf..bf80fd1 100644
--- a/tests/test_output_before_queue_host
+++ b/tests/test_output_before_queue_host
@@ -49,10 +49,10 @@ CTIME: 5FDCCD39
 SIZE: 7298
 CLIENT: localhost.localdomain[127.0.0.1],
 MSGID: <xyz>
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
 SMTP:
 L0000001C Dec 18 15:36:32 proxmox-new postfix/smtpd[29902]: connect from test.localdomain[192.168.22.40]
 L0000001D Dec 18 15:36:33 proxmox-new postfix/smtpd[29902]: NOQUEUE: client=test.localdomain[192.168.22.40]
diff --git a/tests/test_output_before_queue_qid b/tests/test_output_before_queue_qid
index 256287c..31deb90 100644
--- a/tests/test_output_before_queue_qid
+++ b/tests/test_output_before_queue_qid
@@ -10,10 +10,10 @@ CTIME: 5FDCCD39
 SIZE: 7298
 CLIENT: localhost.localdomain[127.0.0.1],
 MSGID: <xyz>
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
-TO:5FDCCC85:1C6B541C5D:A: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test4 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test3 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test2 at localhost> (192.168.22.40[192.168.22.40]:25)
+TO:5FDCCC85:1C6B541C5D:P: from <test at test.localdomain> to <test1 at localhost> (192.168.22.40[192.168.22.40]:25)
 SMTP:
 L0000001C Dec 18 15:36:32 proxmox-new postfix/smtpd[29902]: connect from test.localdomain[192.168.22.40]
 L0000001D Dec 18 15:36:33 proxmox-new postfix/smtpd[29902]: NOQUEUE: client=test.localdomain[192.168.22.40]
-- 
2.20.1




More information about the pmg-devel mailing list