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:
@@ -127,7 +127,8 @@ impl ClockResync {
|
||||
if self.pending_t1 != Some(echo.t1_ns) {
|
||||
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 {
|
||||
self.pending_t1 = Some(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;
|
||||
let cert =
|
||||
rustls::pki_types::CertificateDer::from_pem_slice(cert_pem.as_bytes())
|
||||
.map_err(|e| {
|
||||
anyhow_result::Error::msg(format!("client cert pem: {e}"))
|
||||
})?;
|
||||
.map_err(|e| anyhow_result::Error::msg(format!("client cert pem: {e}")))?;
|
||||
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}")))?;
|
||||
builder
|
||||
@@ -258,8 +256,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
||||
_end_entity: &rustls::pki_types::CertificateDer<'_>,
|
||||
_intermediates: &[rustls::pki_types::CertificateDer<'_>],
|
||||
_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())
|
||||
}
|
||||
|
||||
@@ -268,8 +265,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
||||
message: &[u8],
|
||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
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(
|
||||
message,
|
||||
cert,
|
||||
@@ -283,8 +279,7 @@ impl rustls::server::danger::ClientCertVerifier for AcceptAnyClientCert {
|
||||
message: &[u8],
|
||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
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(
|
||||
message,
|
||||
cert,
|
||||
@@ -314,8 +309,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
||||
_server_name: &rustls::pki_types::ServerName<'_>,
|
||||
_ocsp: &[u8],
|
||||
_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());
|
||||
*self.observed.lock().unwrap() = Some(fp);
|
||||
if let Some(expected) = self.pin {
|
||||
@@ -337,8 +331,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
||||
message: &[u8],
|
||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
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(
|
||||
message,
|
||||
cert,
|
||||
@@ -352,8 +345,7 @@ impl rustls::client::danger::ServerCertVerifier for PinVerify {
|
||||
message: &[u8],
|
||||
cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
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(
|
||||
message,
|
||||
cert,
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
//! (`CTL_MAGIC` + type byte), including the pairing-ceremony messages. Wire codecs only
|
||||
//! — no transport state.
|
||||
|
||||
use super::{CTL_MAGIC, MAGIC};
|
||||
use crate::config::{
|
||||
CompositorPref, Config, FecConfig, FecScheme, GamepadPref, Mode, ProtocolPhase, Role,
|
||||
};
|
||||
use crate::error::{PunktfunkError, Result};
|
||||
use super::{CTL_MAGIC, MAGIC};
|
||||
|
||||
/// `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).
|
||||
|
||||
@@ -42,7 +42,7 @@ fn welcome_roundtrip() {
|
||||
assert_eq!(w.session_config(Role::Host).max_frame_bytes, 64 << 20);
|
||||
let old_host = Welcome {
|
||||
bitrate_kbps: 0,
|
||||
..w.clone()
|
||||
..w
|
||||
};
|
||||
assert_eq!(
|
||||
old_host.session_config(Role::Client).max_frame_bytes,
|
||||
@@ -56,7 +56,7 @@ fn welcome_roundtrip() {
|
||||
height: 1440,
|
||||
refresh_hz: 60,
|
||||
},
|
||||
..w.clone()
|
||||
..w
|
||||
};
|
||||
let derived = fat.session_config(Role::Client).max_frame_bytes;
|
||||
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).
|
||||
assert!(LossReport::decode(&RequestKeyframe.encode()).is_err());
|
||||
assert!(RequestKeyframe::decode(&LossReport { loss_ppm: 0 }.encode()).is_err());
|
||||
assert!(LossReport::decode(
|
||||
&[LossReport { loss_ppm: 0 }.encode().as_slice(), &[0]].concat()
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
LossReport::decode(&[LossReport { loss_ppm: 0 }.encode().as_slice(), &[0]].concat())
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[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 n3 = n2 + 50_000;
|
||||
let n4 = (n3 as i64 - OFF + 5_000_000) as u64; // 5 ms return → big RTT
|
||||
let (offset, rtt) =
|
||||
clock_offset_ns(&[(n1, n2, n3, n4), (t1, t2, t3, t4)]).expect("non-empty");
|
||||
let (offset, rtt) = 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
|
||||
// (asymmetric, 5 ms return) sample is ignored by the min-RTT selection.
|
||||
assert_eq!(offset, OFF);
|
||||
@@ -701,11 +700,17 @@ fn clock_resync_collects_rounds_and_ignores_stale_echoes() {
|
||||
|
||||
let mut rs = ClockResync::new();
|
||||
// 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);
|
||||
// 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 {
|
||||
// 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 };
|
||||
|
||||
@@ -594,11 +594,11 @@ mod wire_equivalence_tests {
|
||||
|
||||
// shard_payload 64 × max_data_per_block 8: >512 bytes spans FEC blocks.
|
||||
let frames: Vec<Vec<u8>> = vec![
|
||||
pattern(3000), // multi-block + partial tail shard
|
||||
pattern(1024), // exact multiple (2 full blocks)
|
||||
pattern(100), // single block, partial tail
|
||||
Vec::new(), // empty frame → 1 zeroed shard
|
||||
pattern(64), // exactly one full shard
|
||||
pattern(3000), // multi-block + partial tail shard
|
||||
pattern(1024), // exact multiple (2 full blocks)
|
||||
pattern(100), // single block, partial tail
|
||||
Vec::new(), // empty frame → 1 zeroed shard
|
||||
pattern(64), // exactly one full shard
|
||||
];
|
||||
for (i, frame) in frames.iter().enumerate() {
|
||||
let got = opt.seal_frame(frame, 1000 * i as u64, i as u32).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user