feat: Basic HTTP listener
This commit is contained in:
parent
c77223048c
commit
452da73413
7 changed files with 350 additions and 7 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -3,10 +3,14 @@
|
|||
mod cli;
|
||||
mod db;
|
||||
mod error;
|
||||
#[cfg(feature = "http")]
|
||||
mod http;
|
||||
mod ldap;
|
||||
mod listener;
|
||||
mod stream;
|
||||
|
||||
#[cfg(feature = "http")]
|
||||
use crate::http::http_listen;
|
||||
use cli::CliArgs;
|
||||
use db::{Database, DatabaseInterface, MemoryDatabase, User};
|
||||
use error::GlobalError;
|
||||
|
|
@ -39,14 +43,21 @@ async fn main() -> Result<(), GlobalError> {
|
|||
// .init();
|
||||
// tracing::subscriber::set_global_default(subscriber)?;
|
||||
|
||||
let listener = ListenerPath::new(&cli.listen)?.listener().await?;
|
||||
let ldap_listener = ListenerPath::new(&cli.listen_ldap)?.listener().await?;
|
||||
|
||||
let mut db = MemoryDatabase::new();
|
||||
create_dummy_users(&mut db).await;
|
||||
|
||||
#[cfg(feature = "http")]
|
||||
{
|
||||
let http_listener = ListenerPath::new(&cli.listen_http)?.listener().await?;
|
||||
let http_db = db.clone();
|
||||
tokio::spawn(http_listen(http_listener, http_db));
|
||||
}
|
||||
|
||||
// If the connection is None, it's because the client aborted early
|
||||
// so there's nothing to do about it.
|
||||
while let Some(stream) = listener.accept_ldap().await? {
|
||||
while let Some(stream) = ldap_listener.accept_ldap().await? {
|
||||
let db = db.clone();
|
||||
tokio::spawn(ldap_handler(stream, db));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue