No assertions in negotiate

This commit is contained in:
David Bürgin 2022-01-02 08:44:14 +01:00
parent 31dde3cb43
commit 370bdfeadc
3 changed files with 14 additions and 17 deletions

12
Cargo.lock generated
View file

@ -150,18 +150,18 @@ checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
[[package]]
name = "proc-macro2"
version = "1.0.34"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.10"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [
"proc-macro2",
]
@ -186,9 +186,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.82"
version = "1.0.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
dependencies = [
"proc-macro2",
"quote",

View file

@ -272,7 +272,7 @@ messages with score 5.0 or above into Junk.
## Licence
Copyright © 20202021 David Bürgin
Copyright © 20202022 David Bürgin
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software

View file

@ -37,23 +37,20 @@ type Context = milter::Context<Connection>;
#[milter::on_negotiate(negotiate_callback)]
fn handle_negotiate(
context: Context,
actions: Actions,
protocol_opts: ProtocolOpts,
_: Actions,
_: ProtocolOpts,
) -> milter::Result<(Status, Actions, ProtocolOpts)> {
let mut req_actions = Actions::empty();
let mut actions = Actions::empty();
if !config::get().dry_run() {
req_actions |= Actions::ADD_HEADER | Actions::REPLACE_HEADER;
actions |= Actions::ADD_HEADER | Actions::REPLACE_HEADER;
if !config::get().preserve_body() {
req_actions |= Actions::REPLACE_BODY;
actions |= Actions::REPLACE_BODY;
}
}
let req_protocol_opts =
let protocol_opts =
ProtocolOpts::NO_UNKNOWN | ProtocolOpts::SKIP | ProtocolOpts::HEADER_LEADING_SPACE;
assert!(actions.contains(req_actions), "required milter actions not supported");
assert!(protocol_opts.contains(req_protocol_opts), "required milter protocol options not supported");
context.api.request_macros(Stage::Connect, "")?;
context.api.request_macros(Stage::Helo, "")?;
context.api.request_macros(Stage::Mail, "{auth_authen}")?;
@ -62,7 +59,7 @@ fn handle_negotiate(
context.api.request_macros(Stage::Eoh, "")?;
context.api.request_macros(Stage::Eom, "")?;
Ok((Status::Continue, req_actions, req_protocol_opts))
Ok((Status::Continue, actions, protocol_opts))
}
#[milter::on_connect(connect_callback)]