Skip to content

Commit d126c74

Browse files
authored
Log failed client logins (#173)
* Log failed client logins * more logging * remove clones * remove
1 parent f72dac4 commit d126c74

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/client.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Handle clients by pretending to be a PostgreSQL server.
22
use bytes::{Buf, BufMut, BytesMut};
3-
use log::{debug, error, info, trace};
3+
use log::{debug, error, info, trace, warn};
44
use std::collections::HashMap;
55
use std::time::Instant;
66
use tokio::io::{split, AsyncReadExt, BufReader, ReadHalf, WriteHalf};
@@ -436,7 +436,7 @@ where
436436
);
437437

438438
if password_hash != password_response {
439-
debug!("Password authentication failed");
439+
warn!("Invalid password {{ username: {:?}, pool_name: {:?}, application_name: {:?} }}", pool_name, username, application_name);
440440
wrong_password(&mut write, username).await?;
441441

442442
return Err(Error::ClientError);
@@ -458,6 +458,7 @@ where
458458
)
459459
.await?;
460460

461+
warn!("Invalid pool name {{ username: {:?}, pool_name: {:?}, application_name: {:?} }}", pool_name, username, application_name);
461462
return Err(Error::ClientError);
462463
}
463464
};
@@ -466,7 +467,7 @@ where
466467
let password_hash = md5_hash_password(&username, &pool.settings.user.password, &salt);
467468

468469
if password_hash != password_response {
469-
debug!("Password authentication failed");
470+
warn!("Invalid password {{ username: {:?}, pool_name: {:?}, application_name: {:?} }}", pool_name, username, application_name);
470471
wrong_password(&mut write, username).await?;
471472

472473
return Err(Error::ClientError);
@@ -658,6 +659,8 @@ where
658659
),
659660
)
660661
.await?;
662+
663+
warn!("Invalid pool name {{ username: {:?}, pool_name: {:?}, application_name: {:?} }}", self.pool_name, self.username, self.application_name);
661664
return Err(Error::ClientError);
662665
}
663666
};

0 commit comments

Comments
 (0)