aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-01 18:00:56 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-01 18:00:56 +0200
commit109337b904ce1ca03f2f6e6216edc8c1af359870 (patch)
tree3d7c8699e608652b8a323111365d973c9a3d2714 /src/server.rs
parent6682edfc5e13e4b968c95268ee903a0dab538274 (diff)
downloadaerogramme-109337b904ce1ca03f2f6e6216edc8c1af359870.tar.gz
aerogramme-109337b904ce1ca03f2f6e6216edc8c1af359870.zip
Start bal in mailrage
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/server.rs b/src/server.rs
index ed751de..0fca3ec 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -7,10 +7,20 @@ use crate::config::*;
use crate::login::{ldap_provider::*, static_provider::*, *};
use crate::mailbox::Mailbox;
+use boitalettres::proto::{Request, Response};
+use boitalettres::server::accept::addr::{AddrIncoming, AddrStream};
+use boitalettres::server::Server as ImapServer;
+use tracing_subscriber;
+
pub struct Server {
pub login_provider: Box<dyn LoginProvider>,
}
+async fn handle_req(req: Request) -> Result<Response> {
+ tracing::debug!("Got request: {:#?}", req);
+ Ok(Response::ok("Done")?)
+}
+
impl Server {
pub fn new(config: Config) -> Result<Arc<Self>> {
let s3_region = Region::Custom {
@@ -32,11 +42,25 @@ impl Server {
}
pub async fn run(self: &Arc<Self>) -> Result<()> {
- let creds = self.login_provider.login("quentin", "poupou").await?;
+ // tracing_subscriber::fmt::init();
+
+ let incoming = AddrIncoming::new("127.0.0.1:4567").await?;
+
+ let make_service = tower::service_fn(|addr: &AddrStream| {
+ tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
+ let service = tower::ServiceBuilder::new().service_fn(handle_req);
+ futures::future::ok::<_, std::convert::Infallible>(service)
+ });
+
+
+ let server = ImapServer::new(incoming).serve(make_service);
+ let _ = server.await?;
+
+ /*let creds = self.login_provider.login("quentin", "poupou").await?;
let mut mailbox = Mailbox::new(&creds, "TestMailbox".to_string()).await?;
- mailbox.test().await?;
+ mailbox.test().await?;*/
Ok(())
}