server: Add a debug log for LDAP messages

This commit is contained in:
Valentin Tolmer 2021-11-03 17:52:51 +09:00 committed by nitnelave
parent 7345cc42d0
commit 9a680a7d06

View File

@ -8,7 +8,7 @@ use crate::{
use actix_rt::net::TcpStream; use actix_rt::net::TcpStream;
use actix_server::ServerBuilder; use actix_server::ServerBuilder;
use actix_service::{fn_service, ServiceFactoryExt}; use actix_service::{fn_service, ServiceFactoryExt};
use anyhow::{anyhow, bail, Result}; use anyhow::{bail, Context, Result};
use futures_util::future::ok; use futures_util::future::ok;
use ldap3_server::{proto::LdapMsg, LdapCodec}; use ldap3_server::{proto::LdapMsg, LdapCodec};
use log::*; use log::*;
@ -24,21 +24,20 @@ where
Backend: BackendHandler + LoginHandler + OpaqueHandler, Backend: BackendHandler + LoginHandler + OpaqueHandler,
{ {
use futures_util::SinkExt; use futures_util::SinkExt;
let msg = msg.map_err(|e| anyhow!("Error while receiving LDAP op: {:#}", e))?; let msg = msg.context("while receiving LDAP op")?;
debug!("Received LDAP message: {:?}", &msg);
match session.handle_ldap_message(msg.op).await { match session.handle_ldap_message(msg.op).await {
None => return Ok(false), None => return Ok(false),
Some(result) => { Some(result) => {
for result_op in result.into_iter() { for result_op in result.into_iter() {
if let Err(e) = resp debug!("Replying with LDAP op: {:?}", &result_op);
.send(LdapMsg { resp.send(LdapMsg {
msgid: msg.msgid, msgid: msg.msgid,
op: result_op, op: result_op,
ctrl: vec![], ctrl: vec![],
}) })
.await .await
{ .context("while sending a response: {:#}")?
bail!("Error while sending a response: {:?}", e);
}
} }
if let Err(e) = resp.flush().await { if let Err(e) = resp.flush().await {