From 429ffc830120529c596a4d545eb4c4ec3221fa11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 16 Oct 2021 17:32:38 +0200 Subject: [PATCH] aquatic_udp: use cleaner request filtering by access list --- aquatic_udp/src/lib/network.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/aquatic_udp/src/lib/network.rs b/aquatic_udp/src/lib/network.rs index 306f167..6de42cb 100644 --- a/aquatic_udp/src/lib/network.rs +++ b/aquatic_udp/src/lib/network.rs @@ -146,22 +146,17 @@ fn read_requests( } match request { - Ok(request) => { - if let Request::Announce(AnnounceRequest { info_hash, transaction_id, ..}) = request { - if state.access_list.allows(access_list_mode, &info_hash.0) { - requests.push((request, src)); - } else { - let response = Response::Error(ErrorResponse { - transaction_id, - message: "Info hash not allowed".into() - }); + Ok(Request::Announce(AnnounceRequest { info_hash, transaction_id, ..})) if !state.access_list.allows(access_list_mode, &info_hash.0) => { + let response = Response::Error(ErrorResponse { + transaction_id, + message: "Info hash not allowed".into() + }); - local_responses.push((response, src)) - } - } else { - requests.push((request, src)); - } - } + local_responses.push((response, src)) + }, + Ok(request) => { + requests.push((request, src)); + }, Err(err) => { ::log::debug!("request_from_bytes error: {:?}", err);