Browse Source

test if udp/tcp share the same NAT port

open-trade 5 years ago
parent
commit
5e5d8927e2
3 changed files with 11 additions and 1 deletions
  1. 1 0
      Cargo.lock
  2. 1 1
      libs/hbb_common
  3. 9 0
      src/rendezvous_server.rs

+ 1 - 0
Cargo.lock

@@ -159,6 +159,7 @@ dependencies = [
159 159
  "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
160 160
  "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
161 161
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
162
+ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
162 163
  "protobuf 2.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
163 164
  "protobuf-codegen-pure 2.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
164 165
  "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",

+ 1 - 1
libs/hbb_common

@@ -1 +1 @@
1
-Subproject commit 2cc3edf0f634adcb1e290c5c8b11bc21de38e763
1
+Subproject commit 489ff100300235ef3b9e7820f1b13dadc75be5f8

+ 9 - 0
src/rendezvous_server.rs

@@ -20,6 +20,15 @@ impl RendezvousServer {
20 20
         let mut rs = Self {
21 21
             peer_map: PeerMap::new(),
22 22
         };
23
+        /* // used to test if udp/tcp share the same NAT port, yes in my test
24
+        let addr = addr.to_string();
25
+        hbb_common::tokio::spawn(async {
26
+            let mut l = hbb_common::tokio::net::TcpListener::bind(addr).await.unwrap();
27
+            while let Ok((_, addr)) = l.accept().await {
28
+                log::debug!("Tcp peer {:?}", addr);
29
+            }
30
+        });
31
+        */
23 32
         while let Some(Ok((bytes, addr))) = socket.next().await {
24 33
             rs.handle_msg(&bytes, addr, &mut socket).await?;
25 34
         }