style: cargo fmt over the networking-audit changes
rustfmt pass over the files the deferred-plan items touched (pinned toolchain 1.96.0); no semantic change. cargo fmt --all --check now clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -298,7 +298,13 @@ fn run_sync(
|
|||||||
// and excluded, so ADPF sees this thread's real per-frame CPU cost, not the poll timeout.
|
// and excluded, so ADPF sees this thread's real per-frame CPU cost, not the poll timeout.
|
||||||
let work_t0 = Instant::now();
|
let work_t0 = Instant::now();
|
||||||
if let Some(frame) = pending.take() {
|
if let Some(frame) = pending.take() {
|
||||||
if feed(&codec, &client, &frame.data, frame.pts_ns / 1000, &mut oversized_dropped) {
|
if feed(
|
||||||
|
&codec,
|
||||||
|
&client,
|
||||||
|
&frame.data,
|
||||||
|
frame.pts_ns / 1000,
|
||||||
|
&mut oversized_dropped,
|
||||||
|
) {
|
||||||
fed += 1;
|
fed += 1;
|
||||||
if fed % 300 == 0 {
|
if fed % 300 == 0 {
|
||||||
log::info!("decode: fed={fed} rendered={rendered} discarded={discarded}");
|
log::info!("decode: fed={fed} rendered={rendered} discarded={discarded}");
|
||||||
@@ -562,8 +568,8 @@ unsafe extern "C" fn on_frame_rendered(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let e2e_ns = displayed_ns + t.clock_offset.load(Ordering::Relaxed) as i128
|
let e2e_ns =
|
||||||
- pts_us as i128 * 1000;
|
displayed_ns + t.clock_offset.load(Ordering::Relaxed) as i128 - pts_us as i128 * 1000;
|
||||||
let e2e_us = (e2e_ns > 0 && e2e_ns < 10_000_000_000).then_some((e2e_ns / 1000) as u64);
|
let e2e_us = (e2e_ns > 0 && e2e_ns < 10_000_000_000).then_some((e2e_ns / 1000) as u64);
|
||||||
let display_us = decoded_ns.map(|d| ((displayed_ns - d).max(0) / 1000) as u64);
|
let display_us = decoded_ns.map(|d| ((displayed_ns - d).max(0) / 1000) as u64);
|
||||||
t.stats.note_displayed(e2e_us, display_us);
|
t.stats.note_displayed(e2e_us, display_us);
|
||||||
@@ -857,14 +863,7 @@ fn run_async(
|
|||||||
std::thread::Builder::new()
|
std::thread::Builder::new()
|
||||||
.name("pf-decode-feed".into())
|
.name("pf-decode-feed".into())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
feeder_loop(
|
feeder_loop(client, stats, in_flight, clock_offset, shutdown, ev_tx);
|
||||||
client,
|
|
||||||
stats,
|
|
||||||
in_flight,
|
|
||||||
clock_offset,
|
|
||||||
shutdown,
|
|
||||||
ev_tx,
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
};
|
};
|
||||||
@@ -1357,7 +1356,11 @@ fn feed(
|
|||||||
// both valid for `n` bytes; `MaybeUninit<u8>` is layout-identical to `u8`, so
|
// both valid for `n` bytes; `MaybeUninit<u8>` is layout-identical to `u8`, so
|
||||||
// the cast write initializes exactly `dst[..n]`.
|
// the cast write initializes exactly `dst[..n]`.
|
||||||
unsafe {
|
unsafe {
|
||||||
std::ptr::copy_nonoverlapping(au.as_ptr(), dst.as_mut_ptr().cast::<u8>(), n);
|
std::ptr::copy_nonoverlapping(
|
||||||
|
au.as_ptr(),
|
||||||
|
dst.as_mut_ptr().cast::<u8>(),
|
||||||
|
n,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
n
|
n
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,9 +548,9 @@ async fn session(args: Args) -> Result<()> {
|
|||||||
// and require a sane, consistent estimate: both batches measure the same physical skew, so
|
// and require a sane, consistent estimate: both batches measure the same physical skew, so
|
||||||
// they must agree to within RTT-scale error (the handshake's own uncertainty is ≈ RTT/2).
|
// they must agree to within RTT-scale error (the handshake's own uncertainty is ≈ RTT/2).
|
||||||
if args.clock_resync {
|
if args.clock_resync {
|
||||||
let first = first_skew
|
let first = first_skew.as_ref().ok_or_else(|| {
|
||||||
.as_ref()
|
anyhow!("clock-resync: host never answered the connect-time handshake")
|
||||||
.ok_or_else(|| anyhow!("clock-resync: host never answered the connect-time handshake"))?;
|
})?;
|
||||||
let second = punktfunk_core::quic::clock_sync(&mut send, &mut recv)
|
let second = punktfunk_core::quic::clock_sync(&mut send, &mut recv)
|
||||||
.await
|
.await
|
||||||
.ok_or_else(|| anyhow!("clock-resync: host did not answer the re-probe"))?;
|
.ok_or_else(|| anyhow!("clock-resync: host did not answer the re-probe"))?;
|
||||||
@@ -573,7 +573,10 @@ async fn session(args: Args) -> Result<()> {
|
|||||||
bound_ns / 1000
|
bound_ns / 1000
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
println!("clock-resync OK: offsets {} / {} ns", first.offset_ns, second.offset_ns);
|
println!(
|
||||||
|
"clock-resync OK: offsets {} / {} ns",
|
||||||
|
first.offset_ns, second.offset_ns
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packet-level receive counters mirrored from `session.stats()` by the data-plane loop. The
|
// Packet-level receive counters mirrored from `session.stats()` by the data-plane loop. The
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ impl ClockResync {
|
|||||||
if self.pending_t1 != Some(echo.t1_ns) {
|
if self.pending_t1 != Some(echo.t1_ns) {
|
||||||
return ResyncStep::Idle; // stale (abandoned batch) or unsolicited
|
return ResyncStep::Idle; // stale (abandoned batch) or unsolicited
|
||||||
}
|
}
|
||||||
self.samples.push((echo.t1_ns, echo.t2_ns, echo.t3_ns, now_ns));
|
self.samples
|
||||||
|
.push((echo.t1_ns, echo.t2_ns, echo.t3_ns, now_ns));
|
||||||
if self.samples.len() < Self::ROUNDS {
|
if self.samples.len() < Self::ROUNDS {
|
||||||
self.pending_t1 = Some(now_ns);
|
self.pending_t1 = Some(now_ns);
|
||||||
return ResyncStep::Probe(ClockProbe { t1_ns: now_ns });
|
return ResyncStep::Probe(ClockProbe { t1_ns: now_ns });
|
||||||
|
|||||||
@@ -188,9 +188,7 @@ pub fn client_pinned_with_identity(
|
|||||||
use rustls::pki_types::pem::PemObject;
|
use rustls::pki_types::pem::PemObject;
|
||||||
let cert =
|
let cert =
|
||||||
rustls::pki_types::CertificateDer::from_pem_slice(cert_pem.as_bytes())
|
rustls::pki_types::CertificateDer::from_pem_slice(cert_pem.as_bytes())
|
||||||
.map_err(|e| {
|
.map_err(|e| anyhow_result::Error::msg(format!("client cert pem: {e}")))?;
|
||||||
anyhow_result::Error::msg(format!("client cert pem: {e}"))
|
|
||||||
})?;
|
|
||||||
let key = rustls::pki_types::PrivateKeyDer::from_pem_slice(key_pem.as_bytes())
|
let key = rustls::pki_types::PrivateKeyDer::from_pem_slice(key_pem.as_bytes())
|
||||||
.map_err(|e| anyhow_result::Error::msg(format!("client key pem: {e}")))?;
|
.map_err(|e| anyhow_result::Error::msg(format!("client key pem: {e}")))?;
|
||||||
builder
|
builder
|
||||||
@@ -258,8 +256,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
|||||||
_end_entity: &rustls::pki_types::CertificateDer<'_>,
|
_end_entity: &rustls::pki_types::CertificateDer<'_>,
|
||||||
_intermediates: &[rustls::pki_types::CertificateDer<'_>],
|
_intermediates: &[rustls::pki_types::CertificateDer<'_>],
|
||||||
_now: rustls::pki_types::UnixTime,
|
_now: rustls::pki_types::UnixTime,
|
||||||
) -> std::result::Result<rustls::server::danger::ClientCertVerified, rustls::Error>
|
) -> std::result::Result<rustls::server::danger::ClientCertVerified, rustls::Error> {
|
||||||
{
|
|
||||||
Ok(rustls::server::danger::ClientCertVerified::assertion())
|
Ok(rustls::server::danger::ClientCertVerified::assertion())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,8 +265,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
|||||||
message: &[u8],
|
message: &[u8],
|
||||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||||
dss: &rustls::DigitallySignedStruct,
|
dss: &rustls::DigitallySignedStruct,
|
||||||
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||||
{
|
|
||||||
rustls::crypto::verify_tls12_signature(
|
rustls::crypto::verify_tls12_signature(
|
||||||
message,
|
message,
|
||||||
cert,
|
cert,
|
||||||
@@ -283,8 +279,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
|||||||
message: &[u8],
|
message: &[u8],
|
||||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||||
dss: &rustls::DigitallySignedStruct,
|
dss: &rustls::DigitallySignedStruct,
|
||||||
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||||
{
|
|
||||||
rustls::crypto::verify_tls13_signature(
|
rustls::crypto::verify_tls13_signature(
|
||||||
message,
|
message,
|
||||||
cert,
|
cert,
|
||||||
@@ -314,8 +309,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
|||||||
_server_name: &rustls::pki_types::ServerName<'_>,
|
_server_name: &rustls::pki_types::ServerName<'_>,
|
||||||
_ocsp: &[u8],
|
_ocsp: &[u8],
|
||||||
_now: rustls::pki_types::UnixTime,
|
_now: rustls::pki_types::UnixTime,
|
||||||
) -> std::result::Result<rustls::client::danger::ServerCertVerified, rustls::Error>
|
) -> std::result::Result<rustls::client::danger::ServerCertVerified, rustls::Error> {
|
||||||
{
|
|
||||||
let fp = cert_fingerprint(end_entity.as_ref());
|
let fp = cert_fingerprint(end_entity.as_ref());
|
||||||
*self.observed.lock().unwrap() = Some(fp);
|
*self.observed.lock().unwrap() = Some(fp);
|
||||||
if let Some(expected) = self.pin {
|
if let Some(expected) = self.pin {
|
||||||
@@ -337,8 +331,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
|||||||
message: &[u8],
|
message: &[u8],
|
||||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||||
dss: &rustls::DigitallySignedStruct,
|
dss: &rustls::DigitallySignedStruct,
|
||||||
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||||
{
|
|
||||||
rustls::crypto::verify_tls12_signature(
|
rustls::crypto::verify_tls12_signature(
|
||||||
message,
|
message,
|
||||||
cert,
|
cert,
|
||||||
@@ -352,8 +345,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
|||||||
message: &[u8],
|
message: &[u8],
|
||||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||||
dss: &rustls::DigitallySignedStruct,
|
dss: &rustls::DigitallySignedStruct,
|
||||||
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
) -> std::result::Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||||
{
|
|
||||||
rustls::crypto::verify_tls13_signature(
|
rustls::crypto::verify_tls13_signature(
|
||||||
message,
|
message,
|
||||||
cert,
|
cert,
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
//! (`CTL_MAGIC` + type byte), including the pairing-ceremony messages. Wire codecs only
|
//! (`CTL_MAGIC` + type byte), including the pairing-ceremony messages. Wire codecs only
|
||||||
//! — no transport state.
|
//! — no transport state.
|
||||||
|
|
||||||
|
use super::{CTL_MAGIC, MAGIC};
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
CompositorPref, Config, FecConfig, FecScheme, GamepadPref, Mode, ProtocolPhase, Role,
|
CompositorPref, Config, FecConfig, FecScheme, GamepadPref, Mode, ProtocolPhase, Role,
|
||||||
};
|
};
|
||||||
use crate::error::{PunktfunkError, Result};
|
use crate::error::{PunktfunkError, Result};
|
||||||
use super::{CTL_MAGIC, MAGIC};
|
|
||||||
|
|
||||||
/// `client → host`: open the session, requesting a display mode (the host creates its
|
/// `client → host`: open the session, requesting a display mode (the host creates its
|
||||||
/// virtual output at exactly this size/refresh — native resolution end to end).
|
/// virtual output at exactly this size/refresh — native resolution end to end).
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ fn welcome_roundtrip() {
|
|||||||
assert_eq!(w.session_config(Role::Host).max_frame_bytes, 64 << 20);
|
assert_eq!(w.session_config(Role::Host).max_frame_bytes, 64 << 20);
|
||||||
let old_host = Welcome {
|
let old_host = Welcome {
|
||||||
bitrate_kbps: 0,
|
bitrate_kbps: 0,
|
||||||
..w.clone()
|
..w
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
old_host.session_config(Role::Client).max_frame_bytes,
|
old_host.session_config(Role::Client).max_frame_bytes,
|
||||||
@@ -56,7 +56,7 @@ fn welcome_roundtrip() {
|
|||||||
height: 1440,
|
height: 1440,
|
||||||
refresh_hz: 60,
|
refresh_hz: 60,
|
||||||
},
|
},
|
||||||
..w.clone()
|
..w
|
||||||
};
|
};
|
||||||
let derived = fat.session_config(Role::Client).max_frame_bytes;
|
let derived = fat.session_config(Role::Client).max_frame_bytes;
|
||||||
assert_eq!(derived, 4 * 1_500_000 * 125 / 60);
|
assert_eq!(derived, 4 * 1_500_000 * 125 / 60);
|
||||||
@@ -573,10 +573,10 @@ fn loss_report_roundtrip() {
|
|||||||
// Disjoint from the other control messages (type byte + length).
|
// Disjoint from the other control messages (type byte + length).
|
||||||
assert!(LossReport::decode(&RequestKeyframe.encode()).is_err());
|
assert!(LossReport::decode(&RequestKeyframe.encode()).is_err());
|
||||||
assert!(RequestKeyframe::decode(&LossReport { loss_ppm: 0 }.encode()).is_err());
|
assert!(RequestKeyframe::decode(&LossReport { loss_ppm: 0 }.encode()).is_err());
|
||||||
assert!(LossReport::decode(
|
assert!(
|
||||||
&[LossReport { loss_ppm: 0 }.encode().as_slice(), &[0]].concat()
|
LossReport::decode(&[LossReport { loss_ppm: 0 }.encode().as_slice(), &[0]].concat())
|
||||||
)
|
.is_err()
|
||||||
.is_err());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -676,8 +676,7 @@ fn clock_offset_picks_min_rtt_and_recovers_offset() {
|
|||||||
let n2 = (n1 as i64 + 200_000 + OFF) as u64;
|
let n2 = (n1 as i64 + 200_000 + OFF) as u64;
|
||||||
let n3 = n2 + 50_000;
|
let n3 = n2 + 50_000;
|
||||||
let n4 = (n3 as i64 - OFF + 5_000_000) as u64; // 5 ms return → big RTT
|
let n4 = (n3 as i64 - OFF + 5_000_000) as u64; // 5 ms return → big RTT
|
||||||
let (offset, rtt) =
|
let (offset, rtt) = clock_offset_ns(&[(n1, n2, n3, n4), (t1, t2, t3, t4)]).expect("non-empty");
|
||||||
clock_offset_ns(&[(n1, n2, n3, n4), (t1, t2, t3, t4)]).expect("non-empty");
|
|
||||||
// The min-RTT sample recovers the offset exactly; its RTT is 2x200us, and the noisy
|
// The min-RTT sample recovers the offset exactly; its RTT is 2x200us, and the noisy
|
||||||
// (asymmetric, 5 ms return) sample is ignored by the min-RTT selection.
|
// (asymmetric, 5 ms return) sample is ignored by the min-RTT selection.
|
||||||
assert_eq!(offset, OFF);
|
assert_eq!(offset, OFF);
|
||||||
@@ -701,11 +700,17 @@ fn clock_resync_collects_rounds_and_ignores_stale_echoes() {
|
|||||||
|
|
||||||
let mut rs = ClockResync::new();
|
let mut rs = ClockResync::new();
|
||||||
// An unsolicited echo before any batch is ignored.
|
// An unsolicited echo before any batch is ignored.
|
||||||
assert_eq!(rs.on_echo(&echo_for(42, 100_000), 500_000), ResyncStep::Idle);
|
assert_eq!(
|
||||||
|
rs.on_echo(&echo_for(42, 100_000), 500_000),
|
||||||
|
ResyncStep::Idle
|
||||||
|
);
|
||||||
|
|
||||||
let mut probe = rs.begin(1_000_000);
|
let mut probe = rs.begin(1_000_000);
|
||||||
// A stale echo (wrong t1: the abandoned pre-begin probe) is ignored mid-batch.
|
// A stale echo (wrong t1: the abandoned pre-begin probe) is ignored mid-batch.
|
||||||
assert_eq!(rs.on_echo(&echo_for(42, 100_000), 500_000), ResyncStep::Idle);
|
assert_eq!(
|
||||||
|
rs.on_echo(&echo_for(42, 100_000), 500_000),
|
||||||
|
ResyncStep::Idle
|
||||||
|
);
|
||||||
for round in 0..ClockResync::ROUNDS {
|
for round in 0..ClockResync::ROUNDS {
|
||||||
// Round 3 is congested (5 ms one-way) — it must lose the min-RTT selection.
|
// Round 3 is congested (5 ms one-way) — it must lose the min-RTT selection.
|
||||||
let one_way = if round == 3 { 5_000_000 } else { 100_000 };
|
let one_way = if round == 3 { 5_000_000 } else { 100_000 };
|
||||||
|
|||||||
@@ -271,8 +271,10 @@ fn run(
|
|||||||
.context("connect client audio endpoint")?;
|
.context("connect client audio endpoint")?;
|
||||||
// Opt-in DSCP/QoS-tag this as the audio class (PUNKTFUNK_DSCP=1); the guard keeps the
|
// Opt-in DSCP/QoS-tag this as the audio class (PUNKTFUNK_DSCP=1); the guard keeps the
|
||||||
// Windows qWAVE flow alive for the whole stream (this function's scope IS the stream).
|
// Windows qWAVE flow alive for the whole stream (this function's scope IS the stream).
|
||||||
let _qos_flow =
|
let _qos_flow = punktfunk_core::transport::set_media_qos(
|
||||||
punktfunk_core::transport::set_media_qos(&sock, punktfunk_core::transport::MediaClass::Audio);
|
&sock,
|
||||||
|
punktfunk_core::transport::MediaClass::Audio,
|
||||||
|
);
|
||||||
tracing::info!(%client, "audio: client endpoint learned");
|
tracing::info!(%client, "audio: client endpoint learned");
|
||||||
|
|
||||||
// Reuse the persistent capturer when its channel count still matches (drain stale
|
// Reuse the persistent capturer when its channel count still matches (drain stale
|
||||||
|
|||||||
@@ -114,8 +114,10 @@ fn run(
|
|||||||
.context("connect client video endpoint")?;
|
.context("connect client video endpoint")?;
|
||||||
// Opt-in DSCP/QoS-tag this as the video class (PUNKTFUNK_DSCP=1); the guard keeps the
|
// Opt-in DSCP/QoS-tag this as the video class (PUNKTFUNK_DSCP=1); the guard keeps the
|
||||||
// Windows qWAVE flow alive for the whole stream (this function's scope IS the stream).
|
// Windows qWAVE flow alive for the whole stream (this function's scope IS the stream).
|
||||||
let _qos_flow =
|
let _qos_flow = punktfunk_core::transport::set_media_qos(
|
||||||
punktfunk_core::transport::set_media_qos(&sock, punktfunk_core::transport::MediaClass::Video);
|
&sock,
|
||||||
|
punktfunk_core::transport::MediaClass::Video,
|
||||||
|
);
|
||||||
tracing::info!(%client, "video: client endpoint learned");
|
tracing::info!(%client, "video: client endpoint learned");
|
||||||
// Short label for web-console stats captures: the client's peer IP.
|
// Short label for web-console stats captures: the client's peer IP.
|
||||||
let client_label = client.ip().to_string();
|
let client_label = client.ip().to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user