Skip to content
Snippets Groups Projects
Commit 8ffc471a authored by Robert Cutajar's avatar Robert Cutajar
Browse files

Optimized deps

parent 000e1f0a
No related branches found
No related tags found
No related merge requests found
Pipeline #338059355 passed with warnings
......@@ -725,20 +725,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]]
name = "futures"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.15"
......@@ -746,7 +732,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
......@@ -776,12 +761,6 @@ dependencies = [
"waker-fn",
]
[[package]]
name = "futures-sink"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282"
[[package]]
name = "futures-task"
version = "0.3.15"
......@@ -796,7 +775,6 @@ checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967"
dependencies = [
"autocfg",
"futures-core",
"futures-sink",
"futures-task",
"pin-project-lite",
"pin-utils",
......@@ -1646,10 +1624,8 @@ version = "0.13.0-samotop-dev"
dependencies = [
"async-std",
"env_logger",
"futures",
"insta",
"log",
"pin-project",
"regex",
"samotop-core",
"samotop-delivery",
......
......@@ -24,7 +24,7 @@ gitlab = { repository="BrightOpen/Samotop", branch="develop" }
maintenance = { status="actively-developed" }
[features]
default = ["rust-tls", "spf", "parser-peg", "smime", "delivery"]
default = ["rust-tls", "spf", "parser-peg", "smime", "delivery", "mapper"]
delivery = ["samotop-delivery"]
smime = ["samotop-smime"]
spf = ["samotop-with-spf"]
......@@ -32,13 +32,11 @@ rust-tls = ["samotop-with-rustls"]
native-tls = ["samotop-with-native-tls", "samotop-with-native-tls/vendored"]
parser-peg = ["samotop-parser"]
parser-nom = ["samotop-parser-nom"]
mapper = ["regex"]
[dependencies]
log = "0.4"
pin-project = "1.0"
futures = { version="0.3", default-features=false }
async-std = { version="1.9", default-features=false, features=["unstable"] }
regex = "1.5"
regex = { version="1.5", optional=true, default-features=false }
[dependencies.samotop-core]
version = "0.13.0-samotop-dev"
......@@ -83,3 +81,4 @@ optional = true
[dev-dependencies]
env_logger = "0.8"
insta = { version="1.7", features=["redactions"] }
async-std = { version="1.9", default-features=false, features=["attributes"] }
......@@ -18,7 +18,6 @@ EOF
*/
use async_std::task;
use samotop::mail::{Builder, Esmtp};
use samotop::server::TcpServer;
use samotop::smtp::SmtpParser;
......@@ -27,12 +26,9 @@ use std::sync::Arc;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
fn main() -> Result<()> {
#[async_std::main]
async fn main() -> Result<()> {
env_logger::init();
task::block_on(main_fut())
}
async fn main_fut() -> Result<()> {
let mail_service = Builder::default()
.using(NullDispatch)
.using(Esmtp.with(SmtpParser))
......
......@@ -84,31 +84,29 @@ mod tests {
use super::*;
#[test]
fn test() -> Result<()> {
async_std::task::block_on(async move {
// use the domain as a user, converting to linux like user name
let sut = Mapper::new(vec![
(Regex::new(".*@(.*)")?, "$1@localhost".to_owned()),
(Regex::new("[^@a-zA-Z0-9]")?, "-".to_owned()),
]);
let req = AddRecipientRequest {
transaction: Transaction::default(),
rcpt: Recipient::new(SmtpPath::Mailbox {
name: "user".to_owned(),
host: SmtpHost::Domain("example.org".to_owned()),
relays: vec![],
}),
};
#[async_std::test]
async fn test() -> Result<()> {
// use the domain as a user, converting to linux like user name
let sut = Mapper::new(vec![
(Regex::new(".*@(.*)")?, "$1@localhost".to_owned()),
(Regex::new("[^@a-zA-Z0-9]")?, "-".to_owned()),
]);
let req = AddRecipientRequest {
transaction: Transaction::default(),
rcpt: Recipient::new(SmtpPath::Mailbox {
name: "user".to_owned(),
host: SmtpHost::Domain("example.org".to_owned()),
relays: vec![],
}),
};
let res = sut.add_recipient(req).await;
match res {
AddRecipientResult::Inconclusive(request) => {
assert_eq!(request.rcpt.address.address(), "example-org@localhost")
}
other => panic!("Unexpected {:?}", other),
let res = sut.add_recipient(req).await;
match res {
AddRecipientResult::Inconclusive(request) => {
assert_eq!(request.rcpt.address.address(), "example-org@localhost")
}
Ok(())
})
other => panic!("Unexpected {:?}", other),
}
Ok(())
}
}
#[cfg(any(feature = "parser-peg", feature = "parser-nom"))]
#[cfg(all(
feature = "mapper",
any(feature = "parser-peg", feature = "parser-nom")
))]
mod mapper;
#[cfg(any(feature = "parser-peg", feature = "parser-nom"))]
#[cfg(all(
feature = "mapper",
any(feature = "parser-peg", feature = "parser-nom")
))]
pub use self::mapper::*;
pub use samotop_core::mail::*;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment