mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 08:14:07 +00:00
clippy --fix
This commit is contained in:
+7
-7
@@ -21,25 +21,25 @@ fn print_qrcode(encoded: &str) {
|
||||
let qrcode = QrCode::new(encoded.as_bytes()).unwrap();
|
||||
|
||||
for _ in 0..qrcode.width() + 2 {
|
||||
print!("{}", WHITE);
|
||||
print!("{WHITE}");
|
||||
}
|
||||
println!();
|
||||
|
||||
for y in 0..qrcode.width() {
|
||||
print!("{}", WHITE);
|
||||
print!("{WHITE}");
|
||||
for x in 0..qrcode.width() {
|
||||
let color = match qrcode[(x, y)] {
|
||||
Color::Light => WHITE,
|
||||
Color::Dark => BLACK,
|
||||
};
|
||||
|
||||
print!("{}", color);
|
||||
print!("{color}");
|
||||
}
|
||||
println!("{}", WHITE);
|
||||
println!("{WHITE}");
|
||||
}
|
||||
|
||||
for _ in 0..qrcode.width() + 2 {
|
||||
print!("{}", WHITE);
|
||||
print!("{WHITE}");
|
||||
}
|
||||
println!();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ fn encode(filename: &str, need_qrcode: bool) {
|
||||
for svr in config.server {
|
||||
let encoded = svr.config.to_url();
|
||||
|
||||
println!("{}", encoded);
|
||||
println!("{encoded}");
|
||||
|
||||
if need_qrcode {
|
||||
let encoded = svr.config.to_qrcode_url();
|
||||
@@ -65,7 +65,7 @@ fn decode(encoded: &str, need_qrcode: bool) {
|
||||
let mut config = Config::new(ConfigType::Server);
|
||||
config.server.push(ServerInstanceConfig::with_server_config(svrconfig));
|
||||
|
||||
println!("{}", config);
|
||||
println!("{config}");
|
||||
|
||||
if need_qrcode {
|
||||
print_qrcode(encoded);
|
||||
|
||||
@@ -66,7 +66,14 @@ use serde::{Deserialize, Serialize};
|
||||
use shadowsocks::relay::socks5::Address;
|
||||
use shadowsocks::{
|
||||
config::{
|
||||
ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerUser, ServerUserManager, ServerWeight,
|
||||
ManagerAddr,
|
||||
Mode,
|
||||
ReplayAttackPolicy,
|
||||
ServerAddr,
|
||||
ServerConfig,
|
||||
ServerUser,
|
||||
ServerUserManager,
|
||||
ServerWeight,
|
||||
},
|
||||
crypto::CipherKind,
|
||||
plugin::PluginConfig,
|
||||
|
||||
@@ -11,12 +11,22 @@ use shadowsocks::{
|
||||
crypto::CipherKind,
|
||||
dns_resolver::DnsResolver,
|
||||
manager::protocol::{
|
||||
self, AddRequest, AddResponse, ErrorResponse, ListResponse, ManagerRequest, PingResponse, RemoveRequest,
|
||||
RemoveResponse, ServerUserConfig, StatRequest,
|
||||
self,
|
||||
AddRequest,
|
||||
AddResponse,
|
||||
ErrorResponse,
|
||||
ListResponse,
|
||||
ManagerRequest,
|
||||
PingResponse,
|
||||
RemoveRequest,
|
||||
RemoveResponse,
|
||||
ServerUserConfig,
|
||||
StatRequest,
|
||||
},
|
||||
net::{AcceptOpts, ConnectOpts},
|
||||
plugin::PluginConfig,
|
||||
ManagerListener, ServerAddr,
|
||||
ManagerListener,
|
||||
ServerAddr,
|
||||
};
|
||||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ use log::error;
|
||||
/// and follow the exact behavior in shadowsocks-libev
|
||||
pub fn daemonize<F: AsRef<Path>>(pid_path: Option<F>) {
|
||||
let pwd = current_dir()
|
||||
.unwrap_or_else(|err| panic!("cannot get current working directory, {:?}", err))
|
||||
.unwrap_or_else(|err| panic!("cannot get current working directory, {err:?}"))
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|err| panic!("cannot get absolute path to working directory, {:?}", err));
|
||||
.unwrap_or_else(|err| panic!("cannot get absolute path to working directory, {err:?}"));
|
||||
let mut d = Daemonize::new().umask(0).working_directory(pwd);
|
||||
|
||||
if let Some(p) = pid_path {
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ pub fn read_server_password(server_name: &str) -> io::Result<String> {
|
||||
}
|
||||
|
||||
// read from TTY
|
||||
let tty_prompt = format!("({}) Password: ", server_name);
|
||||
if let Ok(pwd) = rpassword::prompt_password(&tty_prompt) {
|
||||
let tty_prompt = format!("({server_name}) Password: ");
|
||||
if let Ok(pwd) = rpassword::prompt_password(tty_prompt) {
|
||||
debug!("got server {} password from tty prompt", server_name);
|
||||
return Ok(pwd);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
rng.fill_bytes(&mut key);
|
||||
|
||||
let encoded_key = base64::encode(&key);
|
||||
println!("{}", encoded_key);
|
||||
println!("{encoded_key}");
|
||||
}
|
||||
|
||||
ExitCode::SUCCESS
|
||||
|
||||
+16
-10
@@ -14,7 +14,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,
|
||||
},
|
||||
create_local,
|
||||
@@ -30,7 +35,8 @@ use shadowsocks_service::{
|
||||
use crate::logging;
|
||||
use crate::{
|
||||
config::{Config as ServiceConfig, RuntimeMode},
|
||||
monitor, vparser,
|
||||
monitor,
|
||||
vparser,
|
||||
};
|
||||
|
||||
#[cfg(feature = "local-dns")]
|
||||
@@ -489,7 +495,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
match crate::config::get_default_config_path() {
|
||||
None => None,
|
||||
Some(p) => {
|
||||
println!("loading default config {:?}", p);
|
||||
println!("loading default config {p:?}");
|
||||
Some(p)
|
||||
}
|
||||
}
|
||||
@@ -502,7 +508,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(ref config_path) => match ServiceConfig::load_from_file(config_path) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", config_path, err);
|
||||
eprintln!("loading config {config_path:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -526,7 +532,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(cpath) => match Config::load_from_file(&cpath, ConfigType::Local) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", cpath, err);
|
||||
eprintln!("loading config {cpath:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -549,7 +555,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
} else {
|
||||
match crate::password::read_server_password(svr_addr) {
|
||||
Ok(pwd) => pwd,
|
||||
Err(..) => panic!("`password` is required for server {}", svr_addr),
|
||||
Err(..) => panic!("`password` is required for server {svr_addr}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -615,7 +621,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some("dns") => ProtocolType::Dns,
|
||||
#[cfg(feature = "local-tun")]
|
||||
Some("tun") => ProtocolType::Tun,
|
||||
Some(p) => panic!("not supported `protocol` \"{}\"", p),
|
||||
Some(p) => panic!("not supported `protocol` \"{p}\""),
|
||||
None => ProtocolType::Socks,
|
||||
};
|
||||
|
||||
@@ -757,7 +763,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
let acl = match AccessControl::load_from_file(acl_file) {
|
||||
Ok(acl) => acl,
|
||||
Err(err) => {
|
||||
eprintln!("loading ACL \"{}\", {}", acl_file, err);
|
||||
eprintln!("loading ACL \"{acl_file}\", {err}");
|
||||
return crate::EXIT_CODE_LOAD_ACL_FAILURE.into();
|
||||
}
|
||||
};
|
||||
@@ -808,7 +814,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
|
||||
if let Err(err) = config.check_integrity() {
|
||||
eprintln!("config integrity check failed, {}", err);
|
||||
eprintln!("config integrity check failed, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
|
||||
@@ -866,7 +872,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
// Server future resolved with error, which are listener errors in most cases
|
||||
Either::Left((Err(err), ..)) => {
|
||||
eprintln!("server aborted with {}", err);
|
||||
eprintln!("server aborted with {err}");
|
||||
crate::EXIT_CODE_SERVER_ABORTED.into()
|
||||
}
|
||||
// The abort signal future resolved. Means we should just exit.
|
||||
|
||||
@@ -262,7 +262,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
match crate::config::get_default_config_path() {
|
||||
None => None,
|
||||
Some(p) => {
|
||||
println!("loading default config {:?}", p);
|
||||
println!("loading default config {p:?}");
|
||||
Some(p)
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(ref config_path) => match ServiceConfig::load_from_file(config_path) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", config_path, err);
|
||||
eprintln!("loading config {config_path:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -299,7 +299,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(cpath) => match Config::load_from_file(&cpath, ConfigType::Manager) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", cpath, err);
|
||||
eprintln!("loading config {cpath:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -401,7 +401,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
let acl = match AccessControl::load_from_file(acl_file) {
|
||||
Ok(acl) => acl,
|
||||
Err(err) => {
|
||||
eprintln!("loading ACL \"{}\", {}", acl_file, err);
|
||||
eprintln!("loading ACL \"{acl_file}\", {err}");
|
||||
return crate::EXIT_CODE_LOAD_ACL_FAILURE.into();
|
||||
}
|
||||
};
|
||||
@@ -452,7 +452,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
|
||||
if let Err(err) = config.check_integrity() {
|
||||
eprintln!("config integrity check failed, {}", err);
|
||||
eprintln!("config integrity check failed, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
// Server future resolved with error, which are listener errors in most cases
|
||||
Either::Left((Err(err), ..)) => {
|
||||
eprintln!("server aborted with {}", err);
|
||||
eprintln!("server aborted with {err}");
|
||||
crate::EXIT_CODE_SERVER_ABORTED.into()
|
||||
}
|
||||
// The abort signal future resolved. Means we should just exit.
|
||||
|
||||
@@ -22,7 +22,8 @@ use shadowsocks_service::{
|
||||
use crate::logging;
|
||||
use crate::{
|
||||
config::{Config as ServiceConfig, RuntimeMode},
|
||||
monitor, vparser,
|
||||
monitor,
|
||||
vparser,
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
@@ -273,7 +274,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
match crate::config::get_default_config_path() {
|
||||
None => None,
|
||||
Some(p) => {
|
||||
println!("loading default config {:?}", p);
|
||||
println!("loading default config {p:?}");
|
||||
Some(p)
|
||||
}
|
||||
}
|
||||
@@ -286,7 +287,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(ref config_path) => match ServiceConfig::load_from_file(config_path) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", config_path, err);
|
||||
eprintln!("loading config {config_path:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -310,7 +311,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
Some(cpath) => match Config::load_from_file(&cpath, ConfigType::Server) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
eprintln!("loading config {:?}, {}", cpath, err);
|
||||
eprintln!("loading config {cpath:?}, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
},
|
||||
@@ -333,7 +334,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
} else {
|
||||
match crate::password::read_server_password(svr_addr) {
|
||||
Ok(pwd) => pwd,
|
||||
Err(..) => panic!("`password` is required for server {}", svr_addr),
|
||||
Err(..) => panic!("`password` is required for server {svr_addr}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +420,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
let acl = match AccessControl::load_from_file(acl_file) {
|
||||
Ok(acl) => acl,
|
||||
Err(err) => {
|
||||
eprintln!("loading ACL \"{}\", {}", acl_file, err);
|
||||
eprintln!("loading ACL \"{acl_file}\", {err}");
|
||||
return crate::EXIT_CODE_LOAD_ACL_FAILURE.into();
|
||||
}
|
||||
};
|
||||
@@ -471,7 +472,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
|
||||
if let Err(err) = config.check_integrity() {
|
||||
eprintln!("config integrity check failed, {}", err);
|
||||
eprintln!("config integrity check failed, {err}");
|
||||
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
|
||||
}
|
||||
|
||||
@@ -526,7 +527,7 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
|
||||
}
|
||||
// Server future resolved with error, which are listener errors in most cases
|
||||
Either::Left((Err(err), ..)) => {
|
||||
eprintln!("server aborted with {}", err);
|
||||
eprintln!("server aborted with {err}");
|
||||
crate::EXIT_CODE_SERVER_ABORTED.into()
|
||||
}
|
||||
// The abort signal future resolved. Means we should just exit.
|
||||
|
||||
@@ -142,7 +142,6 @@ pub fn run_as_user(uname: &str) {
|
||||
pwd.pw_uid,
|
||||
err
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ use tokio::{
|
||||
use shadowsocks_service::{
|
||||
config::{Config, ConfigType, LocalConfig, LocalInstanceConfig, ProtocolType, ServerInstanceConfig},
|
||||
local::socks::client::Socks4TcpClient,
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
shadowsocks::{
|
||||
config::{ServerAddr, ServerConfig},
|
||||
crypto::CipherKind,
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ use tokio::{
|
||||
use shadowsocks_service::{
|
||||
config::{Config, ConfigType, LocalConfig, LocalInstanceConfig, ProtocolType, ServerInstanceConfig},
|
||||
local::socks::client::socks5::Socks5TcpClient,
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
shadowsocks::{
|
||||
config::{Mode, ServerAddr, ServerConfig},
|
||||
crypto::CipherKind,
|
||||
|
||||
+3
-2
@@ -11,7 +11,8 @@ use tokio::{
|
||||
|
||||
use shadowsocks_service::{
|
||||
config::{Config, ConfigType},
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
@@ -137,7 +138,7 @@ async fn udp_tunnel() {
|
||||
let n = socket.recv(&mut buf).await.unwrap();
|
||||
|
||||
let recv_payload = &buf[..n];
|
||||
println!("Got reply from server: {:?}", ByteStr::new(&recv_payload));
|
||||
println!("Got reply from server: {:?}", ByteStr::new(recv_payload));
|
||||
|
||||
assert_eq!(MESSAGE, recv_payload);
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ use tokio::time::{self, Duration};
|
||||
use shadowsocks_service::{
|
||||
config::{Config, ConfigType, LocalConfig, LocalInstanceConfig, ProtocolType, ServerInstanceConfig},
|
||||
local::socks::client::socks5::Socks5UdpClient,
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
shadowsocks::{config::Mode, crypto::CipherKind, relay::socks5::Address, ServerConfig},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user