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

Mira Limbeck m.limbeck at proxmox.com
Thu Apr 30 11:00:25 CEST 2020


comment inline

On 4/28/20 8:51 PM, Stoiko Ivanov wrote:
> 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.
>
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
>   src/main.rs                         | 19 ++++++++++++++++++-
>   tests/test_output_before_queue      |  8 ++++----
>   tests/test_output_before_queue_host |  8 ++++----
>   tests/test_output_before_queue_qid  |  8 ++++----
>   4 files changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/src/main.rs b/src/main.rs
> index 7c4b71a..9e3883f 100644
> --- a/src/main.rs
> +++ b/src/main.rs
> @@ -427,10 +427,21 @@ fn handle_lmtp_message(msg: &[u8], parser: &mut Parser, complete_line: &[u8]) {
>           None => return,
>       };
>   
> +    let mut dstatus = DStatus::Dsn(dsn);
> +
> +    if qe.borrow_mut().bq_filtered {
> +        dstatus = match dsn {
> +            2 => DStatus::BqPass,
> +            4 => DStatus::BqDefer,
> +            5 => DStatus::BqReject,

A comment would be nice that explains that only values 2, 4, 5 should be 
possible and all other values are considered to be errors and we return 
early.

> +            _ => return,
> +        }
> +
> +    }
>       qe.borrow_mut().add_to_entry(
>           to,
>           relay,
> -        DStatus::Dsn(dsn),
> +        dstatus,
>           parser.current_record_state.timestamp,
>       );
>   
> @@ -761,6 +772,9 @@ enum DStatus {
>       Block,
>       Greylist,
>       Noqueue,
> +    BqPass,
> +    BqDefer,
> +    BqReject,
>       Dsn(u32),
>   }
>   
> @@ -779,6 +793,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]



More information about the pmg-devel mailing list