mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
aquatic_ws: use cleaner logic for filtering by access list
This commit is contained in:
parent
7ccd5fcbf7
commit
8c3db1b9b9
1 changed files with 6 additions and 17 deletions
|
|
@ -3,7 +3,6 @@ use std::time::Duration;
|
||||||
use std::vec::Drain;
|
use std::vec::Drain;
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use either::Either;
|
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use mio::net::TcpListener;
|
use mio::net::TcpListener;
|
||||||
|
|
@ -220,32 +219,22 @@ pub fn run_handshakes_and_read_messages(
|
||||||
|
|
||||||
debug!("read message");
|
debug!("read message");
|
||||||
|
|
||||||
let message = if let InMessage::AnnounceRequest(ref request) = in_message {
|
match in_message {
|
||||||
if state.access_list.allows(access_list_mode, &request.info_hash.0){
|
InMessage::AnnounceRequest(ref request) if !state.access_list.allows(access_list_mode, &request.info_hash.0) => {
|
||||||
Either::Left(in_message)
|
|
||||||
} else {
|
|
||||||
let out_message = OutMessage::ErrorResponse(ErrorResponse {
|
let out_message = OutMessage::ErrorResponse(ErrorResponse {
|
||||||
failure_reason: "Info hash not allowed".into(),
|
failure_reason: "Info hash not allowed".into(),
|
||||||
action: Some(ErrorResponseAction::Announce),
|
action: Some(ErrorResponseAction::Announce),
|
||||||
info_hash: Some(request.info_hash),
|
info_hash: Some(request.info_hash),
|
||||||
});
|
});
|
||||||
|
|
||||||
Either::Right(out_message)
|
local_responses.push((meta, out_message));
|
||||||
}
|
},
|
||||||
} else {
|
_ => {
|
||||||
Either::Left(in_message)
|
|
||||||
};
|
|
||||||
|
|
||||||
match message {
|
|
||||||
Either::Left(in_message) => {
|
|
||||||
if let Err(err) = in_message_sender.send((meta, in_message)) {
|
if let Err(err) = in_message_sender.send((meta, in_message)) {
|
||||||
error!("InMessageSender: couldn't send message: {:?}", err);
|
error!("InMessageSender: couldn't send message: {:?}", err);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Either::Right(out_message) => {
|
|
||||||
local_responses.push((meta, out_message));
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => {
|
Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue