mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-18 10:21:03 +03:00
fix: bound log volume on sites whose rate a peer or retry loop controls
Debug output goes to the log file, so a site that fires per received message or per retry lets someone else decide how much a machine writes to disk. The WebRTC work added the first such sites. - KCP io loop: absorbing ICMP errors as packet loss made a broken socket write ~100 lines a second for the 60s until the pong timeout reaps it. Log by run instead: one line when a run starts, one per ~5s while it persists so a stuck socket stays visible, and one on recovery with the total. - punch_udp: the recv error retries every 10ms for up to MAX_TIME, so one line per occurrence wrote thousands per punch. Log the first, report the count in the timeout message. - ICE candidate paths (client, mediator): the peer sets the candidate rate and the rendezvous route carrying them needs no prior punch, so throttle to one line a minute each with the suppressed count. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ExUfAkYbq8UC9pQCiLy8TQ
This commit is contained in:
@@ -326,6 +326,15 @@ async fn race_transports_prefer_webrtc<'a, T: 'a>(
|
||||
}
|
||||
}
|
||||
|
||||
// A peer decides how many ICE candidates it sends, and the rendezvous route that carries them is
|
||||
// reachable without a prior punch, so these sites would otherwise let someone else set how much
|
||||
// this machine writes to its log file. One line a minute each, carrying the suppressed count.
|
||||
use hbb_common::log_throttle::LogThrottle;
|
||||
const ICE_LOG_INTERVAL: Duration = Duration::from_secs(60);
|
||||
static REJECTED_ICE_LOG: LogThrottle = LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
static UNEXPECTED_ICE_LOG: LogThrottle = LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
static PENDING_ICE_FULL_LOG: LogThrottle = LogThrottle::new(ICE_LOG_INTERVAL);
|
||||
|
||||
fn request_allows_tcp_punch(webrtc_sdp_offer: &str) -> bool {
|
||||
// WebRTC trickle ICE retains the rendezvous socket as its signaling bridge. Only a request
|
||||
// without an offer may close that socket and reuse its local address for TCP punching.
|
||||
@@ -728,7 +737,13 @@ impl Client {
|
||||
if let Err(err) =
|
||||
webrtc.add_remote_ice_candidate(&ice.candidate).await
|
||||
{
|
||||
log::warn!("failed to add WebRTC ICE candidate: {}", err);
|
||||
if let Some(n) = REJECTED_ICE_LOG.due() {
|
||||
log::warn!(
|
||||
"failed to add {} WebRTC ICE candidate(s), last: {}",
|
||||
n,
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1157,16 +1172,20 @@ impl Client {
|
||||
// would discard exactly the ones that traverse NAT and keep the
|
||||
// host ones that only work on a shared LAN.
|
||||
if pending_webrtc_ice.len() >= Self::MAX_PENDING_WEBRTC_ICE {
|
||||
log::warn!(
|
||||
"WebRTC ICE pending buffer full ({}), dropping oldest candidate",
|
||||
Self::MAX_PENDING_WEBRTC_ICE
|
||||
);
|
||||
if let Some(n) = PENDING_ICE_FULL_LOG.due() {
|
||||
log::warn!(
|
||||
"WebRTC ICE pending buffer full ({}), evicted {} oldest",
|
||||
Self::MAX_PENDING_WEBRTC_ICE,
|
||||
n
|
||||
);
|
||||
}
|
||||
pending_webrtc_ice.remove(0);
|
||||
}
|
||||
pending_webrtc_ice.push(ice.candidate);
|
||||
} else {
|
||||
} else if let Some(n) = UNEXPECTED_ICE_LOG.due() {
|
||||
log::debug!(
|
||||
"dropping ICE candidate for unexpected WebRTC session key {}",
|
||||
"dropped {} ICE candidate(s) for unexpected WebRTC session key, last: {}",
|
||||
n,
|
||||
ice.session_key,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user