2 releases
new 0.1.1 | Jan 26, 2025 |
---|---|
0.1.0 | Feb 26, 2024 |
#127 in Email
90 downloads per month
24KB
302 lines
Miltr Client
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.
Safety
This crate uses unsafe_code = "forbid"
in it's linting, but is also using
cast-possible-truncation = "allow"
. So use at your own risk.
Semver
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.
Credits
purepythonmilter
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.
Anh Vu
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!
Dependencies
~2–3MB
~57K SLoC