[−][src]Crate samotop
Status
Reaching stable. The API builds on async/await to offer a convenient asynchronous interface.
Installation
Add this to your Cargo.toml
:
[dependencies]
samotop = "0"
Note that the API is still unstable. Please use the latest release.
Usage
There are a few interesting provisions one could take away from Samotop:
- The server (through
samotop::server::Server
) - it takes IP:port's to listenon()
and you can thenserve()
your own implementation of aTcpService
. - The SMTP service (
SmtpService
) - it takes an async IO and provides an SMTP service defined bySessionService
. - The low level
SmtpCodec
- it translates between IO and aStram
ofReadControl
and aSink
ofWriteControl
. It handles SMTP mail data as well. - The SMTP session parser (
SmtpParser
) - it takes&str
and returns parsed commands or session. - The SMTP session and domain model (
samotop::model::session
,samotop::model::smtp
) - these describe the domain and behavior. - The mail handling stuff that is yet to be written (
MailService
)...
SMTP Server
You can run a plaintext SMTP service without support for STARTTLS.
extern crate async_std; extern crate env_logger; extern crate samotop; use samotop::server::Server; use samotop::service::tcp::DummyTcpService; fn main() { env_logger::init(); let mail = samotop::service::mail::ConsoleMail::new("Aloha"); let sess = samotop::service::session::StatefulSessionService::new(mail); let svc = samotop::service::tcp::SmtpService::new(sess); let svc = samotop::service::tcp::TlsEnabled::no(svc); //TLS disabled let srv = samotop::server::Server::on("localhost:25").serve(svc); async_std::task::block_on(srv).unwrap() }
To enable TLS, provide a rustls TlsAcceptor. Alternatively, implement TlsEnabled for another TLS library.
Dummy server
Any TCP service can be served. See the docs for TcpService
.
Use this to understand how networking IO is handled.
extern crate async_std; extern crate env_logger; extern crate samotop; use samotop::server::Server; use samotop::service::tcp::DummyTcpService; fn main() { env_logger::init(); let mut srv = Server::on("localhost:0").serve(DummyTcpService); async_std::task::block_on(srv).unwrap() }
Modules
grammar | |
model | |
protocol | |
server | |
service |