Skip to content

Commit

Permalink
chore: clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Jun 12, 2024
1 parent e2d4826 commit aa0e401
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
9 changes: 8 additions & 1 deletion crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ use serde::{Deserialize, Serialize};
use shadowsocks::relay::socks5::Address;
use shadowsocks::{
config::{
ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerSource, ServerUser, ServerUserManager,
ManagerAddr,
Mode,
ReplayAttackPolicy,
ServerAddr,
ServerConfig,
ServerSource,
ServerUser,
ServerUserManager,
ServerWeight,
},
crypto::CipherKind,
Expand Down
13 changes: 12 additions & 1 deletion crates/shadowsocks-service/src/local/http/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Timer for TokioTimer {

fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<TokioSleep>() {
sleep.reset(new_deadline.into())
sleep.reset(new_deadline)
}
}
}
Expand Down Expand Up @@ -105,6 +105,17 @@ impl<B> Clone for HttpClient<B> {
}
}

impl<B> Default for HttpClient<B>
where
B: Body + Send + Unpin + Debug + 'static,
B::Data: Send,
B::Error: Into<Box<dyn ::std::error::Error + Send + Sync>>,
{
fn default() -> Self {
HttpClient::new()
}
}

impl<B> HttpClient<B>
where
B: Body + Send + Unpin + Debug + 'static,
Expand Down
6 changes: 3 additions & 3 deletions crates/shadowsocks-service/src/local/online_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl OnlineConfigService {

let parsed_body = match String::from_utf8(collected_body) {
Ok(b) => b,
Err(..) => return Err(io::Error::new(io::ErrorKind::Other, "body contains non-utf8 bytes").into()),
Err(..) => return Err(io::Error::new(io::ErrorKind::Other, "body contains non-utf8 bytes")),
};

let online_config = match Config::load_from_str(&parsed_body, ConfigType::OnlineConfig) {
Expand All @@ -174,7 +174,7 @@ impl OnlineConfigService {
"server-loader task failed to load from url: {}, error: {}",
self.config_url, err
);
return Err(io::Error::new(io::ErrorKind::Other, err).into());
return Err(io::Error::new(io::ErrorKind::Other, err));
}
};

Expand All @@ -183,7 +183,7 @@ impl OnlineConfigService {
"server-loader task failed to load from url: {}, error: {}",
self.config_url, err
);
return Err(io::Error::new(io::ErrorKind::Other, err).into());
return Err(io::Error::new(io::ErrorKind::Other, err));
}

let after_read_time = Instant::now();
Expand Down
10 changes: 8 additions & 2 deletions src/service/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ use shadowsocks_service::shadowsocks::relay::socks5::Address;
use shadowsocks_service::{
acl::AccessControl,
config::{
read_variable_field_value, Config, ConfigType, LocalConfig, LocalInstanceConfig, ProtocolType,
read_variable_field_value,
Config,
ConfigType,
LocalConfig,
LocalInstanceConfig,
ProtocolType,
ServerInstanceConfig,
},
local::{loadbalancing::PingBalancer, Server},
Expand All @@ -39,7 +44,8 @@ use shadowsocks_service::{
use crate::logging;
use crate::{
config::{Config as ServiceConfig, RuntimeMode},
monitor, vparser,
monitor,
vparser,
};

#[cfg(feature = "local-dns")]
Expand Down

0 comments on commit aa0e401

Please sign in to comment.