Drop bytes dependency

This commit is contained in:
David Bürgin 2023-01-18 17:02:18 +01:00
parent b6b5d47b2a
commit e2bf0a4def
8 changed files with 36 additions and 42 deletions

View file

@ -10,8 +10,8 @@ The minimum supported Rust version is now 1.61.0.
### Fixed
* The program no longer panics when it cannot write to standard error during
operation.
* The program no longer panics when it cannot write log messages to standard
error during operation.
## 0.3.2 (2022-08-31)

33
Cargo.lock generated
View file

@ -530,7 +530,6 @@ version = "0.3.2"
dependencies = [
"async-trait",
"byte-strings",
"bytes",
"chrono",
"futures",
"indymilter",
@ -576,9 +575,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.24.1"
version = "1.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae"
checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb"
dependencies = [
"autocfg",
"bytes",
@ -750,42 +749,42 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"

View file

@ -13,7 +13,6 @@ exclude = ["/.gitignore", "/.gitlab-ci.yml"]
[dependencies]
async-trait = "0.1.61"
byte-strings = "0.2.2"
bytes = "1.3.0"
chrono = "0.4.23"
futures = "0.3.25"
indymilter = "0.2.0"
@ -21,9 +20,9 @@ ipnet = "2.7.1"
once_cell = "1.17.0"
signal-hook = "0.3.14"
signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"] }
tokio = { version = "1.24.1", features = ["fs", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "sync"] }
tokio = { version = "1.24.2", features = ["fs", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "sync"] }
[dev-dependencies]
indymilter-test = "0.0.3"
rand = "0.8.5"
tokio = { version = "1.24.1", features = ["signal", "time"] }
tokio = { version = "1.24.2", features = ["signal", "time"] }

View file

@ -190,11 +190,12 @@ body back to `spamc`. (This option obviously only makes sense and should only be
used when reports are disabled.)
Finally, a pitfall of `spamc` deserves highlighting: `spamc` by default tries to
resist failure to an extent that it will not indicate failure even if it cannot
connect to SpamAssassin server at all (apart from warnings logged to syslog)! If
it cannot connect to the server, it simply echoes what it received, and so masks
the error condition. This behaviour is labelled safe fallback and is perhaps
best disabled once the system is set up. Disable safe fallback as follows:
resist failure to such an extent that it will not indicate failure even if it
cannot connect to SpamAssassin server at all (apart from warnings logged to
syslog)! If it cannot connect to the server, it simply echoes what it received,
and so masks the error condition. This behaviour is labelled safe fallback and
is perhaps best disabled once the system is set up. Disable safe fallback as
follows:
```
--no-safe-fallback

View file

@ -19,7 +19,6 @@ use crate::{
config::Config,
};
use byte_strings::c_str;
use bytes::Bytes;
use chrono::Local;
use indymilter::{
Actions, Callbacks, Context, EomContext, MacroStage, Macros, NegotiateContext, ProtoOpts,
@ -266,12 +265,12 @@ async fn handle_eoh(context: &mut Context<Connection>) -> Status {
async fn handle_body(
config: Arc<Config>,
context: &mut Context<Connection>,
chunk: Bytes,
chunk: impl AsRef<[u8]>,
) -> Status {
let conn = context.data.connection();
let client = conn.client.as_mut().unwrap();
ok_or_tempfail!(client.send_body_chunk(&chunk).await);
ok_or_tempfail!(client.send_body_chunk(chunk.as_ref()).await);
let max = config.max_message_size();
if client.bytes_written() > max {

View file

@ -336,7 +336,7 @@ enum HeaderMod<'a> {
impl HeaderMod<'_> {
async fn execute(&self, actions: &impl ContextActions) -> Result<()> {
// The milter library is smart enough to treat the name in a
// The milter protocol is smart enough to treat the name in a
// case-insensitive manner, eg Subject may replace sUbject.
match *self {
Self::Add { name, value, prepend } => add_header(actions, name, value, prepend).await?,

View file

@ -53,10 +53,7 @@ mod error;
pub use crate::config::{Config, ConfigBuilder};
use indymilter::IntoListener;
use std::{
future::Future,
io::{self, stderr, Write},
};
use std::{future::Future, io};
/// The name of the SpamAssassin Milter application.
pub const MILTER_NAME: &str = "SpamAssassin Milter";
@ -97,8 +94,7 @@ pub async fn run(
let callbacks = callbacks::make_callbacks(config);
let config = Default::default();
// Propagate any I/O error here: dont start if stderr cannot be written to.
writeln!(stderr(), "{MILTER_NAME} {VERSION} starting")?;
eprintln!("{MILTER_NAME} {VERSION} starting");
let result = indymilter::run(listener, callbacks, config, shutdown).await;

View file

@ -57,8 +57,8 @@ async fn main() {
let addr;
let mut socket_path = None;
let listener = match socket {
Socket::Inet(socket) => {
let listener = match TcpListener::bind(socket).await {
Socket::Inet(addr) => {
let listener = match TcpListener::bind(addr).await {
Ok(listener) => listener,
Err(e) => {
let _ = writeln!(stderr(), "{PROGRAM_NAME}: could not bind TCP socket: {e}");
@ -68,13 +68,13 @@ async fn main() {
Listener::Tcp(listener)
}
Socket::Unix(socket) => {
Socket::Unix(path) => {
// Before creating the socket file, try removing any existing socket
// at the target path. This is to clear out a leftover file from a
// previous, aborted execution.
try_remove_socket(&socket).await;
try_remove_socket(&path).await;
let listener = match UnixListener::bind(socket) {
let listener = match UnixListener::bind(path) {
Ok(listener) => listener,
Err(e) => {
let _ = writeln!(stderr(), "{PROGRAM_NAME}: could not create UNIX domain socket: {e}");