Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #21 from flaneur2020/fix-async-on-auth
Browse files Browse the repository at this point in the history
make authenticate() async in the AsyncMysqlShim
  • Loading branch information
sundy-li authored Mar 3, 2022
2 parents 8febbba + c2331e9 commit af29f7b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub trait AsyncMysqlShim<W: Write + Send> {
}

/// authenticate method for the specified plugin
fn authenticate(
async fn authenticate(
&self,
_auth_plugin: &str,
_username: &[u8],
Expand Down Expand Up @@ -792,7 +792,7 @@ pub struct AsyncMysqlIntermediary<B, S: AsyncRead + AsyncWrite + Unpin> {
writer: packet::PacketWriter<Cursor<Vec<u8>>>,
}

impl<B: AsyncMysqlShim<Cursor<Vec<u8>>> + Send, S: AsyncRead + AsyncWrite + Unpin>
impl<B: AsyncMysqlShim<Cursor<Vec<u8>>> + Send + Sync, S: AsyncRead + AsyncWrite + Unpin>
AsyncMysqlIntermediary<B, S>
{
/// Create a new server over two one-way channels and process client commands until the client
Expand Down Expand Up @@ -962,12 +962,16 @@ impl<B: AsyncMysqlShim<Cursor<Vec<u8>>> + Send, S: AsyncRead + AsyncWrite + Unpi

self.writer.set_seq(seq + 1);

if !self.shim.authenticate(
auth_plugin_expect,
&handshake.username,
&scramble,
auth_response.as_slice(),
) {
if !self
.shim
.authenticate(
auth_plugin_expect,
&handshake.username,
&scramble,
auth_response.as_slice(),
)
.await
{
let err_msg = format!(
"Authenticate failed, user: {:?}, auth_plugin: {:?}",
String::from_utf8_lossy(&handshake.username),
Expand Down

0 comments on commit af29f7b

Please sign in to comment.