From 5e5d8927e29922079211064d8cbb52767a2a6967 Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 11 Mar 2020 02:20:45 +0800 Subject: [PATCH] test if udp/tcp share the same NAT port --- Cargo.lock | 1 + libs/hbb_common | 2 +- src/rendezvous_server.rs | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b25168f..6a1b6ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,6 +159,7 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen-pure 2.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/libs/hbb_common b/libs/hbb_common index 2cc3edf..489ff10 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 2cc3edf0f634adcb1e290c5c8b11bc21de38e763 +Subproject commit 489ff100300235ef3b9e7820f1b13dadc75be5f8 diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index d1adca4..989cca3 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -20,6 +20,15 @@ impl RendezvousServer { let mut rs = Self { peer_map: PeerMap::new(), }; + /* // used to test if udp/tcp share the same NAT port, yes in my test + let addr = addr.to_string(); + hbb_common::tokio::spawn(async { + let mut l = hbb_common::tokio::net::TcpListener::bind(addr).await.unwrap(); + while let Ok((_, addr)) = l.accept().await { + log::debug!("Tcp peer {:?}", addr); + } + }); + */ while let Some(Ok((bytes, addr))) = socket.next().await { rs.handle_msg(&bytes, addr, &mut socket).await?; }