From b6e55f2a496774daaf132a239fb2ed09741cb2c0 Mon Sep 17 00:00:00 2001 From: SakuraFrp Commit Bot Date: Fri, 30 Jun 2023 13:08:34 +0800 Subject: [PATCH] fix relay connection for key exchange message --- src/client.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/client.rs b/src/client.rs index df719a063..4bad417a6 100644 --- a/src/client.rs +++ b/src/client.rs @@ -619,15 +619,16 @@ impl Client { ..Default::default() }); socket.send(&msg_out).await?; - if let Some(Ok(bytes)) = socket.next_timeout(CONNECT_TIMEOUT).await { - if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) { - if let Some(rendezvous_message::Union::RelayResponse(rs)) = msg_in.union { - if !rs.refuse_reason.is_empty() { - bail!(rs.refuse_reason); - } - succeed = true; - break; + + if let Some(msg_in) = + crate::get_next_nonkeyexchange_msg(&mut socket, Some(CONNECT_TIMEOUT)).await + { + if let Some(rendezvous_message::Union::RelayResponse(rs)) = msg_in.union { + if !rs.refuse_reason.is_empty() { + bail!(rs.refuse_reason); } + succeed = true; + break; } } }