mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 17:45:44 +00:00
improve hole punch (#403)
* fix duplicated peer id (again) * improve udp hole punch 1. always try cone punch for any nat type, tolerate fault stun type. 2. serializing all sym punch request, including server side.
This commit is contained in:
@@ -94,7 +94,7 @@ impl PunchConeHoleClient {
|
||||
pub(crate) async fn do_hole_punching(
|
||||
&self,
|
||||
dst_peer_id: PeerId,
|
||||
) -> Result<Box<dyn Tunnel>, anyhow::Error> {
|
||||
) -> Result<Option<Box<dyn Tunnel>>, anyhow::Error> {
|
||||
tracing::info!(?dst_peer_id, "start hole punching");
|
||||
let tid = rand::random();
|
||||
|
||||
@@ -212,7 +212,7 @@ impl PunchConeHoleClient {
|
||||
{
|
||||
Ok(tunnel) => {
|
||||
tracing::info!(?tunnel, "hole punched");
|
||||
return Ok(tunnel);
|
||||
return Ok(Some(tunnel));
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!(?e, "failed to connect with socket");
|
||||
@@ -221,7 +221,7 @@ impl PunchConeHoleClient {
|
||||
}
|
||||
}
|
||||
|
||||
return Err(anyhow::anyhow!("punch task finished but no hole punched"));
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user