From 29fc232e1f9c801cc924c2480747d8415b3d046e Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Wed, 7 Aug 2024 00:17:00 +0800 Subject: [PATCH] chore: imports_granularity set to default - imports_granularity is still unstable since 2021: https://rust-lang.github.io/rustfmt/?version=v1.6.0&search=#imports_granularity --- crates/shadowsocks-service/src/config.rs | 9 +---- .../src/local/fake_dns/processor.rs | 5 +-- .../src/local/http/http_client.rs | 3 +- .../src/local/http/http_service.rs | 8 +---- .../src/local/http/server.rs | 4 +-- .../src/local/http/utils.rs | 4 +-- .../src/local/net/udp/association.rs | 4 +-- .../local/socks/client/socks5/tcp_client.rs | 10 +----- .../src/local/socks/server/server.rs | 4 +-- .../src/local/socks/server/socks4/tcprelay.rs | 7 +--- .../src/local/socks/server/socks5/tcprelay.rs | 13 ++----- .../shadowsocks-service/src/manager/server.rs | 16 ++------- .../src/server/tcprelay.rs | 3 +- .../src/server/udprelay.rs | 5 +-- .../src/dns_resolver/hickory_dns_resolver.rs | 3 +- crates/shadowsocks/src/manager/client.rs | 12 ++----- .../src/net/sys/unix/bsd/freebsd.rs | 7 ++-- .../shadowsocks/src/net/sys/unix/bsd/macos.rs | 4 +-- .../shadowsocks/src/net/sys/unix/linux/mod.rs | 7 ++-- crates/shadowsocks/src/net/sys/unix/others.rs | 4 +-- crates/shadowsocks/src/net/sys/windows/mod.rs | 36 ++++--------------- crates/shadowsocks/src/net/tcp.rs | 8 ++--- crates/shadowsocks/src/net/udp.rs | 4 +-- crates/shadowsocks/src/relay/socks5.rs | 5 +-- .../src/relay/tcprelay/aead_2022.rs | 4 +-- .../src/relay/udprelay/aead_2022.rs | 4 +-- .../src/relay/udprelay/crypto_io.rs | 4 +-- .../src/relay/udprelay/proxy_socket.rs | 6 +--- crates/shadowsocks/tests/tcp.rs | 3 +- crates/shadowsocks/tests/tcp_tfo.rs | 4 +-- rustfmt.toml | 2 +- src/service/local.rs | 10 ++---- src/service/manager.rs | 3 +- src/service/server.rs | 3 +- tests/dns.rs | 3 +- tests/http.rs | 3 +- tests/socks4.rs | 3 +- tests/socks5.rs | 3 +- tests/tunnel.rs | 3 +- tests/udp.rs | 3 +- 40 files changed, 54 insertions(+), 192 deletions(-) diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index 9f37ad3c62fd..d44406477b76 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -70,14 +70,7 @@ 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, diff --git a/crates/shadowsocks-service/src/local/fake_dns/processor.rs b/crates/shadowsocks-service/src/local/fake_dns/processor.rs index 1727ed9ad94d..d6252f5d86cf 100644 --- a/crates/shadowsocks-service/src/local/fake_dns/processor.rs +++ b/crates/shadowsocks-service/src/local/fake_dns/processor.rs @@ -6,10 +6,7 @@ use hickory_resolver::proto::{ op::{header::MessageType, response_code::ResponseCode, Header, Message, OpCode}, rr::{ rdata::{A, AAAA}, - DNSClass, - RData, - Record, - RecordType, + DNSClass, RData, Record, RecordType, }, }; use log::{debug, trace}; diff --git a/crates/shadowsocks-service/src/local/http/http_client.rs b/crates/shadowsocks-service/src/local/http/http_client.rs index 07fab66ece6c..f304f48c0426 100644 --- a/crates/shadowsocks-service/src/local/http/http_client.rs +++ b/crates/shadowsocks-service/src/local/http/http_client.rs @@ -16,8 +16,7 @@ use hyper::{ client::conn::{http1, http2}, http::uri::Scheme, rt::{Sleep, Timer}, - Request, - Response, + Request, Response, }; use log::{error, trace}; use lru_time_cache::LruCache; diff --git a/crates/shadowsocks-service/src/local/http/http_service.rs b/crates/shadowsocks-service/src/local/http/http_service.rs index 92dd198b660f..d45b23631f7a 100644 --- a/crates/shadowsocks-service/src/local/http/http_service.rs +++ b/crates/shadowsocks-service/src/local/http/http_service.rs @@ -8,13 +8,7 @@ use hyper::{ body, header::{self, HeaderValue}, http::uri::{Authority, Scheme}, - HeaderMap, - Method, - Request, - Response, - StatusCode, - Uri, - Version, + HeaderMap, Method, Request, Response, StatusCode, Uri, Version, }; use log::{debug, error, trace}; use shadowsocks::relay::Address; diff --git a/crates/shadowsocks-service/src/local/http/server.rs b/crates/shadowsocks-service/src/local/http/server.rs index 2e0750a270d8..96839061c882 100644 --- a/crates/shadowsocks-service/src/local/http/server.rs +++ b/crates/shadowsocks-service/src/local/http/server.rs @@ -13,9 +13,7 @@ use tokio::{ }; use crate::local::{ - context::ServiceContext, - loadbalancing::PingBalancer, - net::tcp::listener::create_standard_tcp_listener, + context::ServiceContext, loadbalancing::PingBalancer, net::tcp::listener::create_standard_tcp_listener, }; use super::{http_client::HttpClient, http_service::HttpService, tokio_rt::TokioIo}; diff --git a/crates/shadowsocks-service/src/local/http/utils.rs b/crates/shadowsocks-service/src/local/http/utils.rs index aed34acafe55..4abbd163c24a 100644 --- a/crates/shadowsocks-service/src/local/http/utils.rs +++ b/crates/shadowsocks-service/src/local/http/utils.rs @@ -9,9 +9,7 @@ use std::{ use hyper::{ header::{self, HeaderValue}, http::uri::Authority, - HeaderMap, - Uri, - Version, + HeaderMap, Uri, Version, }; use log::error; use shadowsocks::relay::socks5::Address; diff --git a/crates/shadowsocks-service/src/local/net/udp/association.rs b/crates/shadowsocks-service/src/local/net/udp/association.rs index 91061faa4298..210d23213126 100644 --- a/crates/shadowsocks-service/src/local/net/udp/association.rs +++ b/crates/shadowsocks-service/src/local/net/udp/association.rs @@ -29,9 +29,7 @@ use shadowsocks::{ use crate::{ local::{context::ServiceContext, loadbalancing::PingBalancer}, net::{ - packet_window::PacketWindowFilter, - MonProxySocket, - UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE, + packet_window::PacketWindowFilter, MonProxySocket, UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE, UDP_ASSOCIATION_SEND_CHANNEL_SIZE, }, }; diff --git a/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs b/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs index fb1ae6070a88..4d7a86862fda 100644 --- a/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs +++ b/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs @@ -9,15 +9,7 @@ use std::{ use log::trace; use pin_project::pin_project; use shadowsocks::relay::socks5::{ - self, - Address, - Command, - Error, - HandshakeRequest, - HandshakeResponse, - Reply, - TcpRequestHeader, - TcpResponseHeader, + self, Address, Command, Error, HandshakeRequest, HandshakeResponse, Reply, TcpRequestHeader, TcpResponseHeader, }; use tokio::{ io::{AsyncRead, AsyncWrite, ReadBuf}, diff --git a/crates/shadowsocks-service/src/local/socks/server/server.rs b/crates/shadowsocks-service/src/local/socks/server/server.rs index 79f6557fce22..c34f5d049ae8 100644 --- a/crates/shadowsocks-service/src/local/socks/server/server.rs +++ b/crates/shadowsocks-service/src/local/socks/server/server.rs @@ -7,9 +7,7 @@ use tokio::{net::TcpStream, time}; #[cfg(feature = "local-http")] use crate::local::http::HttpConnectionHandler; use crate::local::{ - context::ServiceContext, - loadbalancing::PingBalancer, - net::tcp::listener::create_standard_tcp_listener, + context::ServiceContext, loadbalancing::PingBalancer, net::tcp::listener::create_standard_tcp_listener, socks::config::Socks5AuthConfig, }; diff --git a/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs b/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs index ad15a703c757..34dc2900c7b2 100644 --- a/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs +++ b/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs @@ -21,12 +21,7 @@ use crate::local::{ }; use crate::local::socks::socks4::{ - Address, - Command, - Error as Socks4Error, - HandshakeRequest, - HandshakeResponse, - ResultCode, + Address, Command, Error as Socks4Error, HandshakeRequest, HandshakeResponse, ResultCode, }; pub struct Socks4TcpHandler { diff --git a/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs b/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs index 95659411fb40..77d03d790ab5 100644 --- a/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs +++ b/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs @@ -11,17 +11,8 @@ use log::{debug, error, trace, warn}; use shadowsocks::{ config::Mode, relay::socks5::{ - self, - Address, - Command, - Error as Socks5Error, - HandshakeRequest, - HandshakeResponse, - PasswdAuthRequest, - PasswdAuthResponse, - Reply, - TcpRequestHeader, - TcpResponseHeader, + self, Address, Command, Error as Socks5Error, HandshakeRequest, HandshakeResponse, PasswdAuthRequest, + PasswdAuthResponse, Reply, TcpRequestHeader, TcpResponseHeader, }, ServerAddr, }; diff --git a/crates/shadowsocks-service/src/manager/server.rs b/crates/shadowsocks-service/src/manager/server.rs index ae27acee602c..1e5244cb2bff 100644 --- a/crates/shadowsocks-service/src/manager/server.rs +++ b/crates/shadowsocks-service/src/manager/server.rs @@ -13,23 +13,13 @@ use shadowsocks::{ manager::{ datagram::ManagerSocketAddr, 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}; diff --git a/crates/shadowsocks-service/src/server/tcprelay.rs b/crates/shadowsocks-service/src/server/tcprelay.rs index d4490cb716d5..544ba94a9825 100644 --- a/crates/shadowsocks-service/src/server/tcprelay.rs +++ b/crates/shadowsocks-service/src/server/tcprelay.rs @@ -13,8 +13,7 @@ use shadowsocks::{ crypto::CipherKind, net::{AcceptOpts, TcpStream as OutboundTcpStream}, relay::tcprelay::{utils::copy_encrypted_bidirectional, ProxyServerStream}, - ProxyListener, - ServerConfig, + ProxyListener, ServerConfig, }; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, diff --git a/crates/shadowsocks-service/src/server/udprelay.rs b/crates/shadowsocks-service/src/server/udprelay.rs index 60a0a1cd0974..32ec296468a4 100644 --- a/crates/shadowsocks-service/src/server/udprelay.rs +++ b/crates/shadowsocks-service/src/server/udprelay.rs @@ -29,10 +29,7 @@ use tokio::{runtime::Handle, sync::mpsc, task::JoinHandle, time}; use windows_sys::Win32::Networking::WinSock::WSAEAFNOSUPPORT; use crate::net::{ - packet_window::PacketWindowFilter, - utils::to_ipv4_mapped, - MonProxySocket, - UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE, + packet_window::PacketWindowFilter, utils::to_ipv4_mapped, MonProxySocket, UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE, UDP_ASSOCIATION_SEND_CHANNEL_SIZE, }; diff --git a/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs b/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs index 2d7e4fdab831..9e378bca4fbf 100644 --- a/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs +++ b/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs @@ -20,8 +20,7 @@ use hickory_resolver::{ udp::{DnsUdpSocket, QuicLocalAddr}, TokioTime, }, - AsyncResolver, - TokioHandle, + AsyncResolver, TokioHandle, }; use log::trace; use tokio::{io::ReadBuf, net::UdpSocket}; diff --git a/crates/shadowsocks/src/manager/client.rs b/crates/shadowsocks/src/manager/client.rs index 67d1b904d4cb..f3fc96955b36 100644 --- a/crates/shadowsocks/src/manager/client.rs +++ b/crates/shadowsocks/src/manager/client.rs @@ -8,16 +8,8 @@ use super::{ datagram::ManagerDatagram, error::Error, protocol::{ - AddRequest, - AddResponse, - ListRequest, - ListResponse, - ManagerProtocol, - PingRequest, - PingResponse, - RemoveRequest, - RemoveResponse, - StatRequest, + AddRequest, AddResponse, ListRequest, ListResponse, ManagerProtocol, PingRequest, PingResponse, RemoveRequest, + RemoveResponse, StatRequest, }, }; diff --git a/crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs b/crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs index 180154cdb564..812e29c3792b 100644 --- a/crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs +++ b/crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs @@ -1,6 +1,5 @@ use std::{ - io, - mem, + io, mem, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, os::unix::io::{AsRawFd, RawFd}, pin::Pin, @@ -21,9 +20,7 @@ use tokio_tfo::TfoStream; use crate::net::{ sys::{set_common_sockopt_after_connect, set_common_sockopt_for_connect, socket_bind_dual_stack}, udp::{BatchRecvMessage, BatchSendMessage}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// A `TcpStream` that supports TFO (TCP Fast Open) diff --git a/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs b/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs index dbc6e41a92db..2c27417afc95 100644 --- a/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs +++ b/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs @@ -24,9 +24,7 @@ use tokio_tfo::TfoStream; use crate::net::{ sys::{set_common_sockopt_after_connect, set_common_sockopt_for_connect, socket_bind_dual_stack}, udp::{BatchRecvMessage, BatchSendMessage}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// A `TcpStream` that supports TFO (TCP Fast Open) diff --git a/crates/shadowsocks/src/net/sys/unix/linux/mod.rs b/crates/shadowsocks/src/net/sys/unix/linux/mod.rs index 07acde426613..1122f041d128 100644 --- a/crates/shadowsocks/src/net/sys/unix/linux/mod.rs +++ b/crates/shadowsocks/src/net/sys/unix/linux/mod.rs @@ -1,6 +1,5 @@ use std::{ - io, - mem, + io, mem, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}, pin::Pin, @@ -22,9 +21,7 @@ use tokio_tfo::TfoStream; use crate::net::{ sys::{set_common_sockopt_after_connect, set_common_sockopt_for_connect, socket_bind_dual_stack}, udp::{BatchRecvMessage, BatchSendMessage}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// A `TcpStream` that supports TFO (TCP Fast Open) diff --git a/crates/shadowsocks/src/net/sys/unix/others.rs b/crates/shadowsocks/src/net/sys/unix/others.rs index a8cf4c897b61..ad0b32d3304d 100644 --- a/crates/shadowsocks/src/net/sys/unix/others.rs +++ b/crates/shadowsocks/src/net/sys/unix/others.rs @@ -15,9 +15,7 @@ use tokio::{ use crate::net::{ sys::{set_common_sockopt_after_connect, set_common_sockopt_for_connect, ErrorKind}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// A wrapper of `TcpStream` diff --git a/crates/shadowsocks/src/net/sys/windows/mod.rs b/crates/shadowsocks/src/net/sys/windows/mod.rs index fdb50e883618..ca5f70f5dbb9 100644 --- a/crates/shadowsocks/src/net/sys/windows/mod.rs +++ b/crates/shadowsocks/src/net/sys/windows/mod.rs @@ -10,8 +10,7 @@ use std::{ io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}, }, pin::Pin, - ptr, - slice, + ptr, slice, task::{self, Poll}, time::{Duration, Instant}, }; @@ -30,32 +29,13 @@ use windows_sys::{ Win32::{ Foundation::{BOOL, ERROR_BUFFER_OVERFLOW, ERROR_NO_DATA, ERROR_SUCCESS}, NetworkManagement::IpHelper::{ - if_nametoindex, - GetAdaptersAddresses, - GAA_FLAG_SKIP_ANYCAST, - GAA_FLAG_SKIP_DNS_SERVER, - GAA_FLAG_SKIP_MULTICAST, - GAA_FLAG_SKIP_UNICAST, - IP_ADAPTER_ADDRESSES_LH, + if_nametoindex, GetAdaptersAddresses, GAA_FLAG_SKIP_ANYCAST, GAA_FLAG_SKIP_DNS_SERVER, + GAA_FLAG_SKIP_MULTICAST, GAA_FLAG_SKIP_UNICAST, IP_ADAPTER_ADDRESSES_LH, }, Networking::WinSock::{ - htonl, - setsockopt, - WSAGetLastError, - WSAIoctl, - AF_UNSPEC, - IPPROTO_IP, - IPPROTO_IPV6, - IPPROTO_TCP, - IPV6_MTU_DISCOVER, - IPV6_UNICAST_IF, - IP_MTU_DISCOVER, - IP_PMTUDISC_DO, - IP_UNICAST_IF, - SIO_UDP_CONNRESET, - SOCKET, - SOCKET_ERROR, - TCP_FASTOPEN, + htonl, setsockopt, WSAGetLastError, WSAIoctl, AF_UNSPEC, IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, + IPV6_MTU_DISCOVER, IPV6_UNICAST_IF, IP_MTU_DISCOVER, IP_PMTUDISC_DO, IP_UNICAST_IF, SIO_UDP_CONNRESET, + SOCKET, SOCKET_ERROR, TCP_FASTOPEN, }, }, }; @@ -66,9 +46,7 @@ const FALSE: BOOL = 0; use crate::net::{ is_dual_stack_addr, sys::{set_common_sockopt_for_connect, socket_bind_dual_stack}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// A `TcpStream` that supports TFO (TCP Fast Open) diff --git a/crates/shadowsocks/src/net/tcp.rs b/crates/shadowsocks/src/net/tcp.rs index ba1bbdd68e3d..97708ae7ebfc 100644 --- a/crates/shadowsocks/src/net/tcp.rs +++ b/crates/shadowsocks/src/net/tcp.rs @@ -24,14 +24,10 @@ use crate::{context::Context, relay::socks5::Address, ServerAddr}; use super::{ is_dual_stack_addr, sys::{ - create_inbound_tcp_socket, - set_common_sockopt_after_accept, - set_tcp_fastopen, - socket_bind_dual_stack, + create_inbound_tcp_socket, set_common_sockopt_after_accept, set_tcp_fastopen, socket_bind_dual_stack, TcpStream as SysTcpStream, }, - AcceptOpts, - ConnectOpts, + AcceptOpts, ConnectOpts, }; /// TcpStream for outbound connections diff --git a/crates/shadowsocks/src/net/udp.rs b/crates/shadowsocks/src/net/udp.rs index 7803a162ef12..2512be801ee3 100644 --- a/crates/shadowsocks/src/net/udp.rs +++ b/crates/shadowsocks/src/net/udp.rs @@ -39,9 +39,7 @@ use crate::{context::Context, relay::socks5::Address, ServerAddr}; use super::{ sys::{bind_outbound_udp_socket, create_inbound_udp_socket, create_outbound_udp_socket}, - AcceptOpts, - AddrFamily, - ConnectOpts, + AcceptOpts, AddrFamily, ConnectOpts, }; /// Message struct for `batch_send` diff --git a/crates/shadowsocks/src/relay/socks5.rs b/crates/shadowsocks/src/relay/socks5.rs index 7477f2fe6468..000cc797395a 100644 --- a/crates/shadowsocks/src/relay/socks5.rs +++ b/crates/shadowsocks/src/relay/socks5.rs @@ -16,10 +16,7 @@ use bytes::{Buf, BufMut, BytesMut}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; pub use self::consts::{ - SOCKS5_AUTH_METHOD_GSSAPI, - SOCKS5_AUTH_METHOD_NONE, - SOCKS5_AUTH_METHOD_NOT_ACCEPTABLE, - SOCKS5_AUTH_METHOD_PASSWORD, + SOCKS5_AUTH_METHOD_GSSAPI, SOCKS5_AUTH_METHOD_NONE, SOCKS5_AUTH_METHOD_NOT_ACCEPTABLE, SOCKS5_AUTH_METHOD_PASSWORD, }; #[rustfmt::skip] diff --git a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs index c1cd52a7b55e..21622b926cb7 100644 --- a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs +++ b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs @@ -55,9 +55,7 @@ use std::{ use aes::{ cipher::{BlockDecrypt, BlockEncrypt, KeyInit}, - Aes128, - Aes256, - Block, + Aes128, Aes256, Block, }; use byte_string::ByteStr; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/crates/shadowsocks/src/relay/udprelay/aead_2022.rs b/crates/shadowsocks/src/relay/udprelay/aead_2022.rs index 7057cc0d6519..c8d85742aee3 100644 --- a/crates/shadowsocks/src/relay/udprelay/aead_2022.rs +++ b/crates/shadowsocks/src/relay/udprelay/aead_2022.rs @@ -58,9 +58,7 @@ use std::{ use aes::{ cipher::{BlockDecrypt, BlockEncrypt, KeyInit}, - Aes128, - Aes256, - Block, + Aes128, Aes256, Block, }; use byte_string::ByteStr; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/crates/shadowsocks/src/relay/udprelay/crypto_io.rs b/crates/shadowsocks/src/relay/udprelay/crypto_io.rs index e0c082565c31..cc1c28f8fdee 100644 --- a/crates/shadowsocks/src/relay/udprelay/crypto_io.rs +++ b/crates/shadowsocks/src/relay/udprelay/crypto_io.rs @@ -32,9 +32,7 @@ use crate::{ #[cfg(feature = "aead-cipher-2022")] use super::aead_2022::{ - decrypt_client_payload_aead_2022, - decrypt_server_payload_aead_2022, - encrypt_client_payload_aead_2022, + decrypt_client_payload_aead_2022, decrypt_server_payload_aead_2022, encrypt_client_payload_aead_2022, encrypt_server_payload_aead_2022, }; #[cfg(feature = "stream-cipher")] diff --git a/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs b/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs index 50a0522894a8..356bdd7393ef 100644 --- a/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs +++ b/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs @@ -23,11 +23,7 @@ use crate::{ }; use super::crypto_io::{ - decrypt_client_payload, - decrypt_server_payload, - encrypt_client_payload, - encrypt_server_payload, - ProtocolError, + decrypt_client_payload, decrypt_server_payload, encrypt_client_payload, encrypt_server_payload, ProtocolError, ProtocolResult, }; diff --git a/crates/shadowsocks/tests/tcp.rs b/crates/shadowsocks/tests/tcp.rs index 8153ce8ff104..f624c5755712 100644 --- a/crates/shadowsocks/tests/tcp.rs +++ b/crates/shadowsocks/tests/tcp.rs @@ -24,8 +24,7 @@ use shadowsocks::{ utils::{copy_from_encrypted, copy_to_encrypted}, }, }, - ProxyClientStream, - ProxyListener, + ProxyClientStream, ProxyListener, }; async fn handle_tcp_tunnel_server_client( diff --git a/crates/shadowsocks/tests/tcp_tfo.rs b/crates/shadowsocks/tests/tcp_tfo.rs index 1894ee5f1bd4..2b2872627960 100644 --- a/crates/shadowsocks/tests/tcp_tfo.rs +++ b/crates/shadowsocks/tests/tcp_tfo.rs @@ -21,9 +21,7 @@ use shadowsocks::{ socks5::Address, tcprelay::utils::{copy_from_encrypted, copy_to_encrypted}, }, - ProxyClientStream, - ProxyListener, - ServerConfig, + ProxyClientStream, ProxyListener, ServerConfig, }; use tokio::{ io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, diff --git a/rustfmt.toml b/rustfmt.toml index 4ee82b9ad500..0407a9d21603 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -15,4 +15,4 @@ use_try_shorthand = true reorder_impl_items = true #use_small_heuristics = "Max" imports_layout = "HorizontalVertical" -imports_granularity = "Crate" +#imports_granularity = "Crate" diff --git a/src/service/local.rs b/src/service/local.rs index 1eca5668c5ce..e5e82c614d36 100644 --- a/src/service/local.rs +++ b/src/service/local.rs @@ -24,12 +24,7 @@ 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}, @@ -44,8 +39,7 @@ use shadowsocks_service::{ use crate::logging; use crate::{ config::{Config as ServiceConfig, RuntimeMode}, - monitor, - vparser, + monitor, vparser, }; #[cfg(feature = "local-dns")] diff --git a/src/service/manager.rs b/src/service/manager.rs index aac9d86d8d81..2cd5a861fc0e 100644 --- a/src/service/manager.rs +++ b/src/service/manager.rs @@ -27,8 +27,7 @@ use shadowsocks_service::{ use crate::logging; use crate::{ config::{Config as ServiceConfig, RuntimeMode}, - monitor, - vparser, + monitor, vparser, }; /// Defines command line options diff --git a/src/service/server.rs b/src/service/server.rs index 1585c6446f1a..d5b49fe05afb 100644 --- a/src/service/server.rs +++ b/src/service/server.rs @@ -25,8 +25,7 @@ use shadowsocks_service::{ use crate::logging; use crate::{ config::{Config as ServiceConfig, RuntimeMode}, - monitor, - vparser, + monitor, vparser, }; /// Defines command line options diff --git a/tests/dns.rs b/tests/dns.rs index 33c037421aba..9f6854a30ebd 100644 --- a/tests/dns.rs +++ b/tests/dns.rs @@ -11,8 +11,7 @@ use tokio::{ use shadowsocks_service::{ config::{Config, ConfigType}, - run_local, - run_server, + run_local, run_server, }; #[tokio::test] diff --git a/tests/http.rs b/tests/http.rs index 70ae7fdb5ff8..4dd541fcb378 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -10,8 +10,7 @@ use tokio::{ use shadowsocks_service::{ config::{Config, ConfigType}, - run_local, - run_server, + run_local, run_server, }; #[tokio::test] diff --git a/tests/socks4.rs b/tests/socks4.rs index 66cf6f50435d..cdce51f5dca5 100644 --- a/tests/socks4.rs +++ b/tests/socks4.rs @@ -13,8 +13,7 @@ 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, diff --git a/tests/socks5.rs b/tests/socks5.rs index c09299dc6f36..74e6034ef3ff 100644 --- a/tests/socks5.rs +++ b/tests/socks5.rs @@ -13,8 +13,7 @@ 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, diff --git a/tests/tunnel.rs b/tests/tunnel.rs index 0330dfabb2a0..7d24304ac7af 100644 --- a/tests/tunnel.rs +++ b/tests/tunnel.rs @@ -11,8 +11,7 @@ use tokio::{ use shadowsocks_service::{ config::{Config, ConfigType}, - run_local, - run_server, + run_local, run_server, }; fn random_local_tcp_port() -> u16 { diff --git a/tests/udp.rs b/tests/udp.rs index 1e71622ca6db..dba2bcabea77 100644 --- a/tests/udp.rs +++ b/tests/udp.rs @@ -9,8 +9,7 @@ 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}, };