rendezvous_mediator.rs
Contains an unbounded block loopRust test marker or harness
SHA-256d7291f3e05b5c73afc0c57328658a747933505a98214f35e53c9b68432d32ee6
MaleculeH₂(Cm₃Db)Md₂(InPa)
Evidence
1use std::{
2 collections::{hash_map::RandomState, HashMap, VecDeque},
3 hash::BuildHasher,
4 net::SocketAddr,
5 sync::{
6 atomic::{AtomicBool, AtomicUsize, Ordering},
7 Arc, RwLock,
8 },
9 time::{Duration, Instant},
10};
11
12use uuid::Uuid;
13
14use hbb_common::{
15 allow_err,
16 anyhow::{self, bail},
17 config::{self, option2bool, use_ws, Config, CONNECT_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
18 futures::future::join_all,
19 log,
20 protobuf::Message as _,
21 rendezvous_proto::*,
22 sleep,
23 socket_client::{self, connect_tcp, is_ipv4, new_direct_udp_for, new_udp_for},
24 tokio::{
25 self, select,
26 sync::{mpsc, Mutex},
27 time::interval,
28 },
29 udp::FramedSocket,
30 webrtc::WebRTCStream,
31 AddrMangle, IntoTargetAddr, ResultType, Stream, TargetAddr,
32};
33use base::config::keys::*;
34
35use crate::{
36 check_port,
37 server::{check_zombie, new as new_server, ConnectionMeta, ServerPtr},
38};
39
⋯4 lines
275:9… crate::test_nat_type();
276 if config::is_outgoing_only() {
277 loop {
278 sleep(1.).await;
279 }
280 }
281 crate::hbbs_http::sync::start();
282 #[cfg(target_os = "wi …
367:28… server: ServerPtr, host: String) -> ResultType<()> {
368 let host = check_port(&host, RENDEZVOUS_PORT);
369 log::info!("start udp: {host}");
370 let (mut socket, mut addr) = new_udp_for(&host, CONNEC …
1208:59… ).await?;
1209 let data = msg_out.write_to_bytes()?;
1210 socket.send_to(&data, addr).await?;
1211 // The reply is out, and with it the answer and the v6 address: declined is the listen
1212 // …
1714:53… ue to pk changed, will resend register_pk");
1715 }
1716 }
1717}
1718
1719#[cfg(test)]
1720mod tests {
1721 use super::{
1722 connection_meta, mpsc, tokio, AnswererSlot, IceRoute, IntoTargetAddr, PunchHoleSent,
1723 RendezvousMediator, RendezvousMessage, MAX_WEBRTC_ANSWERERS, TCP_PUNCHES, UDP_PUNCHES,
1724 };
1725 use hbb_common::protobuf::Message as _;
1726
1727 // The places are the bound and they come bac …