mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 08:14:07 +00:00
make clippy happy
This commit is contained in:
@@ -50,7 +50,7 @@ impl DnsClientCache {
|
||||
ns: SocketAddr,
|
||||
msg: Message,
|
||||
connect_opts: &ConnectOpts,
|
||||
is_udp: bool
|
||||
is_udp: bool,
|
||||
) -> Result<Message, ProtoError> {
|
||||
let key = match is_udp {
|
||||
true => DnsClientKey::UdpLocal(ns),
|
||||
@@ -65,7 +65,7 @@ impl DnsClientCache {
|
||||
svr_cfg: &ServerConfig,
|
||||
ns: &Address,
|
||||
msg: Message,
|
||||
is_udp: bool
|
||||
is_udp: bool,
|
||||
) -> Result<Message, ProtoError> {
|
||||
let key = match is_udp {
|
||||
true => DnsClientKey::UdpRemote(ns.clone()),
|
||||
@@ -145,14 +145,14 @@ impl DnsClientCache {
|
||||
.await;
|
||||
}
|
||||
}
|
||||
match self.get_client_or_create(&dck, async { dns_res }).await {
|
||||
match self.get_client_or_create(dck, async { dns_res }).await {
|
||||
Ok(mut client) => match client.lookup_timeout(msg.clone(), self.timeout).await {
|
||||
Ok(msg) => {
|
||||
self.save_client(dck.clone(), client).await;
|
||||
return Ok(msg);
|
||||
}
|
||||
Err(err) => {
|
||||
last_err = Some(From::from(err));
|
||||
last_err = Some(err);
|
||||
continue;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -153,17 +153,16 @@ impl HttpDispatcher {
|
||||
|
||||
// Set keep-alive for connection with remote
|
||||
set_conn_keep_alive(version, self.req.headers_mut(), conn_keep_alive);
|
||||
let client: HttpClientEnum;
|
||||
if self.context.check_target_bypassed(&host).await {
|
||||
let client = if self.context.check_target_bypassed(&host).await {
|
||||
trace!("bypassed {} -> {} {:?}", self.client_addr, host, self.req);
|
||||
client = HttpClientEnum::Bypass(self.bypass_client);
|
||||
HttpClientEnum::Bypass(self.bypass_client)
|
||||
} else {
|
||||
trace!("proxied {} -> {} {:?}", self.client_addr, host, self.req);
|
||||
|
||||
// Keep connections for clients in ServerScore::client
|
||||
// client instance is kept for Keep-Alive connections
|
||||
let server = self.balancer.best_tcp_server();
|
||||
client = HttpClientEnum::Proxy(self.proxy_client_cache.get_connected(&server).await);
|
||||
HttpClientEnum::Proxy(self.proxy_client_cache.get_connected(&server).await)
|
||||
};
|
||||
|
||||
let mut res = match client.send(self.req).await {
|
||||
|
||||
@@ -14,9 +14,9 @@ pub enum HttpClientEnum {
|
||||
|
||||
impl HttpClientEnum {
|
||||
pub fn send(&self, req: Request<Body>) -> ResponseFuture {
|
||||
return match self {
|
||||
match self {
|
||||
HttpClientEnum::Proxy(c) => c.request(req),
|
||||
HttpClientEnum::Bypass(b) => b.request(req),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-20
@@ -193,7 +193,7 @@ impl Config {
|
||||
|
||||
/// Logger configuration
|
||||
#[cfg(feature = "logging")]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct LogConfig {
|
||||
/// Default logger log level, [0, 3]
|
||||
pub level: u32,
|
||||
@@ -203,31 +203,13 @@ pub struct LogConfig {
|
||||
pub config_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "logging")]
|
||||
impl Default for LogConfig {
|
||||
fn default() -> LogConfig {
|
||||
LogConfig {
|
||||
level: 0,
|
||||
format: LogFormatConfig::default(),
|
||||
config_path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Logger format configuration
|
||||
#[cfg(feature = "logging")]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct LogFormatConfig {
|
||||
pub without_time: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "logging")]
|
||||
impl Default for LogFormatConfig {
|
||||
fn default() -> LogFormatConfig {
|
||||
LogFormatConfig { without_time: false }
|
||||
}
|
||||
}
|
||||
|
||||
/// Runtime mode (Tokio)
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum RuntimeMode {
|
||||
|
||||
@@ -32,7 +32,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options<'a, 'b>(mut app: App<'a>) -> App<'a> {
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
app = app.arg(
|
||||
Arg::new("CONFIG")
|
||||
.short('c')
|
||||
@@ -379,7 +379,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
},
|
||||
None => ServiceConfig::default(),
|
||||
};
|
||||
service_config.set_options(&matches);
|
||||
service_config.set_options(matches);
|
||||
|
||||
#[cfg(feature = "logging")]
|
||||
match service_config.log.config_path {
|
||||
|
||||
@@ -29,7 +29,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options<'a>(mut app: App<'a>) -> App<'a> {
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
app = app
|
||||
.arg(
|
||||
Arg::new("CONFIG")
|
||||
@@ -222,7 +222,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
},
|
||||
None => ServiceConfig::default(),
|
||||
};
|
||||
service_config.set_options(&matches);
|
||||
service_config.set_options(matches);
|
||||
|
||||
#[cfg(feature = "logging")]
|
||||
match service_config.log.config_path {
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options<'a>(mut app: App<'a>) -> App<'a> {
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
app = app
|
||||
.arg(
|
||||
Arg::new("CONFIG")
|
||||
@@ -233,7 +233,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
},
|
||||
None => ServiceConfig::default(),
|
||||
};
|
||||
service_config.set_options(&matches);
|
||||
service_config.set_options(matches);
|
||||
|
||||
#[cfg(feature = "logging")]
|
||||
match service_config.log.config_path {
|
||||
|
||||
@@ -45,7 +45,7 @@ validate_type!(validate_u32, u32, "should be unsigned integer");
|
||||
validate_type!(validate_usize, usize, "should be unsigned integer");
|
||||
|
||||
pub fn validate_server_url(v: &str) -> Result<(), String> {
|
||||
match ServerConfig::from_url(&v) {
|
||||
match ServerConfig::from_url(v) {
|
||||
Ok(..) => Ok(()),
|
||||
Err(..) => Err("should be SIP002 (https://shadowsocks.org/en/wiki/SIP002-URI-Scheme.html) format".to_owned()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user