From cb640e48c5cdbb6f04c415dcd666cb627ef2de44 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 9 Dec 2022 20:59:25 +0800 Subject: [PATCH] refactor punch hole --- src/rendezvous_mediator.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 9350085c4..89c1ca227 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -379,7 +379,10 @@ impl RendezvousMediator { ) .await?; let local_addr = socket.local_addr(); - allow_err!(socket_client::connect_tcp(peer_addr, local_addr, 300).await); + // key important here for punch hole to tell gateway incoming peer is safe. + // before we use 300ms, 1000ms seems more safe. + // it can not be async here, because local_addr can not be reused, we must close the connection before use it again. + allow_err!(socket_client::connect_tcp(peer_addr, local_addr, 1000).await); socket }; let mut msg_out = Message::new();