mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
Run rustfmt
This commit is contained in:
parent
523a21dac4
commit
3678e86654
7 changed files with 27 additions and 22 deletions
|
|
@ -210,7 +210,9 @@ pub fn handle_connection_read_event(
|
||||||
|
|
||||||
if let Some(established) = connection.get_established() {
|
if let Some(established) = connection.get_established() {
|
||||||
match established.read_request() {
|
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 {
|
let meta = ConnectionMeta {
|
||||||
worker_index: socket_worker_index,
|
worker_index: socket_worker_index,
|
||||||
poll_token,
|
poll_token,
|
||||||
|
|
@ -223,7 +225,7 @@ pub fn handle_connection_read_event(
|
||||||
local_responses.push((meta, Response::Failure(response)));
|
local_responses.push((meta, Response::Failure(response)));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
},
|
}
|
||||||
Ok(request) => {
|
Ok(request) => {
|
||||||
let meta = ConnectionMeta {
|
let meta = ConnectionMeta {
|
||||||
worker_index: socket_worker_index,
|
worker_index: socket_worker_index,
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,7 @@ use crate::{common::*, config::Config};
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::Require | AccessListMode::Forbid => {
|
||||||
if let Err(err) = state
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
.access_list
|
|
||||||
.update_from_path(&config.access_list.path)
|
|
||||||
{
|
|
||||||
::log::error!("Couldn't update access list: {:?}", err);
|
::log::error!("Couldn't update access list: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,17 +146,21 @@ fn read_requests(
|
||||||
}
|
}
|
||||||
|
|
||||||
match request {
|
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 {
|
let response = Response::Error(ErrorResponse {
|
||||||
transaction_id,
|
transaction_id,
|
||||||
message: "Info hash not allowed".into()
|
message: "Info hash not allowed".into(),
|
||||||
});
|
});
|
||||||
|
|
||||||
local_responses.push((response, src))
|
local_responses.push((response, src))
|
||||||
},
|
}
|
||||||
Ok(request) => {
|
Ok(request) => {
|
||||||
requests.push((request, src));
|
requests.push((request, src));
|
||||||
},
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
::log::debug!("request_from_bytes error: {:?}", err);
|
::log::debug!("request_from_bytes error: {:?}", err);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,7 @@ use crate::config::Config;
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::Require | AccessListMode::Forbid => {
|
||||||
if let Err(err) = state
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
.access_list
|
|
||||||
.update_from_path(&config.access_list.path)
|
|
||||||
{
|
|
||||||
::log::error!("Update access list from path: {:?}", err);
|
::log::error!("Update access list from path: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,11 @@ impl TorrentMaps {
|
||||||
Self::clean_torrent_map(config, access_list, &mut self.ipv6);
|
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();
|
let now = Instant::now();
|
||||||
|
|
||||||
torrent_map.retain(|info_hash, torrent_data| {
|
torrent_map.retain(|info_hash, torrent_data| {
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ pub fn run_poll_loop(
|
||||||
&mut poll,
|
&mut poll,
|
||||||
local_responses.drain(..),
|
local_responses.drain(..),
|
||||||
&out_message_receiver,
|
&out_message_receiver,
|
||||||
&mut connections
|
&mut connections,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,7 +219,11 @@ pub fn run_handshakes_and_read_messages(
|
||||||
debug!("read message");
|
debug!("read message");
|
||||||
|
|
||||||
match InMessage::from_ws_message(ws_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 {
|
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),
|
||||||
|
|
@ -227,7 +231,7 @@ pub fn run_handshakes_and_read_messages(
|
||||||
});
|
});
|
||||||
|
|
||||||
local_responses.push((meta, out_message));
|
local_responses.push((meta, out_message));
|
||||||
},
|
}
|
||||||
Ok(in_message) => {
|
Ok(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);
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,7 @@ use crate::config::Config;
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::Require | AccessListMode::Forbid => {
|
||||||
if let Err(err) = state
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
.access_list
|
|
||||||
.update_from_path(&config.access_list.path)
|
|
||||||
{
|
|
||||||
::log::error!("Couldn't update access list: {:?}", err);
|
::log::error!("Couldn't update access list: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue