Run rustfmt

This commit is contained in:
Joakim Frostegård 2021-10-16 17:49:00 +02:00
parent 523a21dac4
commit 3678e86654
7 changed files with 27 additions and 22 deletions

View file

@ -210,7 +210,9 @@ pub fn handle_connection_read_event(
if let Some(established) = connection.get_established() {
match established.read_request() {
Ok(Request::Announce(ref r)) if !state.access_list.allows(access_list_mode, &r.info_hash.0) => {
Ok(Request::Announce(ref r))
if !state.access_list.allows(access_list_mode, &r.info_hash.0) =>
{
let meta = ConnectionMeta {
worker_index: socket_worker_index,
poll_token,
@ -223,7 +225,7 @@ pub fn handle_connection_read_event(
local_responses.push((meta, Response::Failure(response)));
break;
},
}
Ok(request) => {
let meta = ConnectionMeta {
worker_index: socket_worker_index,

View file

@ -7,10 +7,7 @@ use crate::{common::*, config::Config};
pub fn update_access_list(config: &Config, state: &State) {
match config.access_list.mode {
AccessListMode::Require | AccessListMode::Forbid => {
if let Err(err) = state
.access_list
.update_from_path(&config.access_list.path)
{
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
::log::error!("Couldn't update access list: {:?}", err);
}
}

View file

@ -146,17 +146,21 @@ fn read_requests(
}
match request {
Ok(Request::Announce(AnnounceRequest { info_hash, transaction_id, ..})) if !state.access_list.allows(access_list_mode, &info_hash.0) => {
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()
message: "Info hash not allowed".into(),
});
local_responses.push((response, src))
},
}
Ok(request) => {
requests.push((request, src));
},
}
Err(err) => {
::log::debug!("request_from_bytes error: {:?}", err);

View file

@ -11,10 +11,7 @@ use crate::config::Config;
pub fn update_access_list(config: &Config, state: &State) {
match config.access_list.mode {
AccessListMode::Require | AccessListMode::Forbid => {
if let Err(err) = state
.access_list
.update_from_path(&config.access_list.path)
{
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
::log::error!("Update access list from path: {:?}", err);
}
}

View file

@ -94,7 +94,11 @@ impl TorrentMaps {
Self::clean_torrent_map(config, access_list, &mut self.ipv6);
}
fn clean_torrent_map(config: &Config, access_list: &Arc<AccessList>, torrent_map: &mut TorrentMap) {
fn clean_torrent_map(
config: &Config,
access_list: &Arc<AccessList>,
torrent_map: &mut TorrentMap,
) {
let now = Instant::now();
torrent_map.retain(|info_hash, torrent_data| {

View file

@ -122,7 +122,7 @@ pub fn run_poll_loop(
&mut poll,
local_responses.drain(..),
&out_message_receiver,
&mut connections
&mut connections,
);
}
@ -219,7 +219,11 @@ pub fn run_handshakes_and_read_messages(
debug!("read message");
match InMessage::from_ws_message(ws_message) {
Ok(InMessage::AnnounceRequest(ref request)) if !state.access_list.allows(access_list_mode, &request.info_hash.0) => {
Ok(InMessage::AnnounceRequest(ref request))
if !state
.access_list
.allows(access_list_mode, &request.info_hash.0) =>
{
let out_message = OutMessage::ErrorResponse(ErrorResponse {
failure_reason: "Info hash not allowed".into(),
action: Some(ErrorResponseAction::Announce),
@ -227,7 +231,7 @@ pub fn run_handshakes_and_read_messages(
});
local_responses.push((meta, out_message));
},
}
Ok(in_message) => {
if let Err(err) = in_message_sender.send((meta, in_message)) {
error!("InMessageSender: couldn't send message: {:?}", err);

View file

@ -7,10 +7,7 @@ use crate::config::Config;
pub fn update_access_list(config: &Config, state: &State) {
match config.access_list.mode {
AccessListMode::Require | AccessListMode::Forbid => {
if let Err(err) = state
.access_list
.update_from_path(&config.access_list.path)
{
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
::log::error!("Couldn't update access list: {:?}", err);
}
}