Skip to content

Commit

Permalink
chore: imports_granularity set to default
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Aug 6, 2024
1 parent dcc628d commit 29fc232
Show file tree
Hide file tree
Showing 40 changed files with 54 additions and 192 deletions.
9 changes: 1 addition & 8 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions crates/shadowsocks-service/src/local/fake_dns/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions crates/shadowsocks-service/src/local/http/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions crates/shadowsocks-service/src/local/http/http_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks-service/src/local/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks-service/src/local/http/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks-service/src/local/net/udp/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks-service/src/local/socks/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
16 changes: 3 additions & 13 deletions crates/shadowsocks-service/src/manager/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 1 addition & 2 deletions crates/shadowsocks-service/src/server/tcprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
5 changes: 1 addition & 4 deletions crates/shadowsocks-service/src/server/udprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
3 changes: 1 addition & 2 deletions crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use hickory_resolver::{
udp::{DnsUdpSocket, QuicLocalAddr},
TokioTime,
},
AsyncResolver,
TokioHandle,
AsyncResolver, TokioHandle,
};
use log::trace;
use tokio::{io::ReadBuf, net::UdpSocket};
Expand Down
12 changes: 2 additions & 10 deletions crates/shadowsocks/src/manager/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand Down
7 changes: 2 additions & 5 deletions crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
io,
mem,
io, mem,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
os::unix::io::{AsRawFd, RawFd},
pin::Pin,
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks/src/net/sys/unix/bsd/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions crates/shadowsocks/src/net/sys/unix/linux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
io,
mem,
io, mem,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd},
pin::Pin,
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks/src/net/sys/unix/others.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
36 changes: 7 additions & 29 deletions crates/shadowsocks/src/net/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use std::{
io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket},
},
pin::Pin,
ptr,
slice,
ptr, slice,
task::{self, Poll},
time::{Duration, Instant},
};
Expand All @@ -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,
},
},
};
Expand All @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions crates/shadowsocks/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
5 changes: 1 addition & 4 deletions crates/shadowsocks/src/relay/socks5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions crates/shadowsocks/src/relay/tcprelay/aead_2022.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading

0 comments on commit 29fc232

Please sign in to comment.