aquatic_ws: don't send peer its own offer

This commit is contained in:
Joakim Frostegård 2020-05-25 18:59:43 +02:00
parent 689a874cbe
commit abc0034a45
2 changed files with 13 additions and 0 deletions

View file

@ -31,6 +31,8 @@
out and everything will start working
* stack-allocated vectors for announce request offers and scrape request info
hashes?
* write new version of extract_response_peers which checks for equality with
peer sending request?
## aquatic_udp

View file

@ -168,6 +168,17 @@ pub fn handle_announce_requests(
);
for (offer, peer) in offers.into_iter().zip(peers){
// Avoid sending offer back to requesting peer. This could be
// done in extract_announce_peers, but it would likely hurt
// performance to check all peers there for their socket addr,
// especially if there are thousands of peers. It might be
// possible to write a new version of that function which isn't
// shared with aquatic_udp and goes about it differently
// though.
if sender_meta.peer_addr == peer.connection_meta.peer_addr {
continue;
}
let middleman_offer = MiddlemanOfferToPeer {
info_hash,
peer_id,