| Crates.io | miltr-client |
| lib.rs | miltr-client |
| version | 0.1.3 |
| created_at | 2024-02-26 08:25:40.28949+00 |
| updated_at | 2025-09-19 11:29:56.144734+00 |
| description | A miltr client library in pure rust |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1153179 |
| size | 53,410 |
A client implementation of the milter protocol.
use tokio::net::TcpStream;
use tokio_util::compat::TokioAsyncReadCompatExt;
use miltr_client::Client;
use miltr_common::{
commands::Connect,
optneg::OptNeg,
};
#[tokio::main]
async fn main() {
let mut stream = TcpStream::connect("localhost:8080")
.await
.expect("Failed connecting to milter server")
.compat();
println!("Opened TCP connection");
let options = OptNeg::default();
let client = Client::new(options);
let mut connection = client
.connect_via(&mut stream)
.await
.expect("Failed to setup connection");
// Further processing
}
Currently, the milter client is relatively barebone. It should handle all commands, actions and modification actions correctly. But, everything else is basically up to the user. For example, nothing prevents you from claiming one behavior in option negotiation, but actually doing something else.
The use case for this client library currently is to have an example client to mess around and test behavior with.
This crate uses unsafe_code = "forbid" in it's linting, but is also using
cast-possible-truncation = "allow". So use at your own risk.
This crate follows semver specification with the following exceptions:
Minimum supported rust version:
A bump to the MSRV is not considered a semver major semver change, only a minor one.
Features starting with _. These are considered 'internal' and 'private'. This
is mainly used for fuzz testing. It makes it much easier to fuzz internals directly.
No external user should need to enable those features.
Special credits go to purepythonmilter, a python package containing a complete milter implementation. Without this resource to have a look at "how they did it" this implementation would not have happened.
Another big thank you goes to Anh Vu (vunpa1711@gmail.com), working student at the time at Retarus, who wrote a big part of the integration tests and brought valuable feedback for implementation improvements. Thank you!