From 8b79cdc6fc471efea79714e329bc00097635c021 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Wed, 8 Apr 2026 15:18:52 +0400 Subject: [PATCH] fix: dedup filter collision between different senders + build scripts default --pull - Dedup key now includes source peer fingerprint hash, preventing packets from different senders with same room+seq from being dropped as duplicates (was silently killing all multi-hop audio) - Build scripts default to --pull (use --no-pull to skip) Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-relay/src/federation.rs | 16 +++++++++++++--- scripts/build-and-notify.sh | 3 ++- scripts/build-linux-docker.sh | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/wzp-relay/src/federation.rs b/crates/wzp-relay/src/federation.rs index 49d65bb..fdfe052 100644 --- a/crates/wzp-relay/src/federation.rs +++ b/crates/wzp-relay/src/federation.rs @@ -55,8 +55,10 @@ impl Deduplicator { } /// Returns true if this packet is a duplicate (already seen). - fn is_dup(&mut self, room_hash: &[u8; 8], seq: u16) -> bool { - let key = u64::from_be_bytes(*room_hash) ^ (seq as u64); + /// The source_fp_hash distinguishes packets from different senders + /// that share the same room and seq number. + fn is_dup(&mut self, room_hash: &[u8; 8], seq: u16, source_fp_hash: u64) -> bool { + let key = u64::from_be_bytes(*room_hash) ^ (seq as u64) ^ source_fp_hash; if self.seen.contains(&key) { return true; } @@ -850,9 +852,17 @@ async fn handle_datagram( } // Dedup: drop packets we've already seen (multi-path duplicates) + // Include source peer fingerprint so different senders with same seq aren't confused + let source_fp_hash = { + let mut h = 0u64; + for (i, b) in source_peer_fp.bytes().enumerate().take(8) { + h ^= (b as u64) << ((i % 8) * 8); + } + h + }; { let mut dedup = fm.dedup.lock().await; - if dedup.is_dup(&rh, pkt.header.seq) { + if dedup.is_dup(&rh, pkt.header.seq, source_fp_hash) { return; } } diff --git a/scripts/build-and-notify.sh b/scripts/build-and-notify.sh index 699b1a7..0f990d7 100755 --- a/scripts/build-and-notify.sh +++ b/scripts/build-and-notify.sh @@ -17,12 +17,13 @@ LOCAL_OUTPUT="target/android-apk" SSH_OPTS="-o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax=4 -o LogLevel=ERROR" REBUILD_RUST=0 -DO_PULL=0 +DO_PULL=1 DO_INSTALL=0 for arg in "$@"; do case "$arg" in --rust) REBUILD_RUST=1 ;; --pull) DO_PULL=1 ;; + --no-pull) DO_PULL=0 ;; --install) DO_INSTALL=1 ;; esac done diff --git a/scripts/build-linux-docker.sh b/scripts/build-linux-docker.sh index b2e6b12..d2fc9ad 100755 --- a/scripts/build-linux-docker.sh +++ b/scripts/build-linux-docker.sh @@ -17,12 +17,13 @@ NTFY_TOPIC="https://ntfy.sh/wzp" LOCAL_OUTPUT="target/linux-x86_64" SSH_OPTS="-o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax=4 -o LogLevel=ERROR" -DO_PULL=0 +DO_PULL=1 DO_CLEAN=0 DO_INSTALL=0 for arg in "$@"; do case "$arg" in --pull) DO_PULL=1 ;; + --no-pull) DO_PULL=0 ;; --clean) DO_CLEAN=1 ;; --install) DO_INSTALL=1 ;; esac