diff --git a/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs b/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs index 1a84e4d67bc3..01c86c625f5b 100644 --- a/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs +++ b/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs @@ -853,7 +853,7 @@ impl PingChecker { async fn check_request_tcp_chromium(&self) -> io::Result<()> { use std::io::{Error, ErrorKind}; - static GET_BODY: &[u8] = + const GET_BODY: &[u8] = b"GET /generate_204 HTTP/1.1\r\nHost: clients3.google.com\r\nConnection: close\r\nAccept: */*\r\n\r\n"; let addr = Address::DomainNameAddress("clients3.google.com".to_owned(), 80); @@ -892,7 +892,7 @@ impl PingChecker { async fn check_request_tcp_firefox(&self) -> io::Result<()> { use std::io::{Error, ErrorKind}; - static GET_BODY: &[u8] = + const GET_BODY: &[u8] = b"GET /success.txt HTTP/1.1\r\nHost: detectportal.firefox.com\r\nConnection: close\r\nAccept: */*\r\n\r\n"; let addr = Address::DomainNameAddress("detectportal.firefox.com".to_owned(), 80); @@ -938,7 +938,7 @@ impl PingChecker { // - QNAME: \x07 firefox \x03 com \x00 // - QTYPE: 0x0001 A // - QCLASS: 0x0001 IN - static DNS_QUERY: &[u8] = + const DNS_QUERY: &[u8] = b"\x12\x34\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07firefox\x03com\x00\x00\x01\x00\x01"; let addr = Address::SocketAddress(SocketAddr::new(Ipv4Addr::new(8, 8, 8, 8).into(), 53)); diff --git a/crates/shadowsocks-service/src/local/online_config/mod.rs b/crates/shadowsocks-service/src/local/online_config/mod.rs index 7dfa0b4a411e..2ada278ec1fa 100644 --- a/crates/shadowsocks-service/src/local/online_config/mod.rs +++ b/crates/shadowsocks-service/src/local/online_config/mod.rs @@ -84,7 +84,7 @@ impl OnlineConfigService { } async fn run_once_impl(&mut self) -> io::Result<()> { - static SHADOWSOCKS_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); + const SHADOWSOCKS_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); let start_time = Instant::now(); diff --git a/crates/shadowsocks/src/dns_resolver/resolver.rs b/crates/shadowsocks/src/dns_resolver/resolver.rs index e42e79c31b96..33c7c996c7ff 100644 --- a/crates/shadowsocks/src/dns_resolver/resolver.rs +++ b/crates/shadowsocks/src/dns_resolver/resolver.rs @@ -161,7 +161,7 @@ async fn hickory_dns_notify_update_dns(resolver: Arc) use super::hickory_dns_resolver::create_resolver; - static DNS_RESOLV_FILE_PATH: &str = "/etc/resolv.conf"; + const DNS_RESOLV_FILE_PATH: &str = "/etc/resolv.conf"; if !Path::new(DNS_RESOLV_FILE_PATH).exists() { trace!("resolv file {DNS_RESOLV_FILE_PATH} doesn't exist"); diff --git a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs index 7be2b3361316..10c8f88deecd 100644 --- a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs +++ b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs @@ -529,7 +529,7 @@ pub struct EncryptedWriter { impl EncryptedWriter { /// Creates a new EncryptedWriter pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8], nonce: &[u8]) -> EncryptedWriter { - static EMPTY_IDENTITY: [Bytes; 0] = []; + const EMPTY_IDENTITY: [Bytes; 0] = []; EncryptedWriter::with_identity(stream_ty, method, key, nonce, &EMPTY_IDENTITY) } diff --git a/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs b/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs index 1e8376f82781..1a13bf02c355 100644 --- a/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs +++ b/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs @@ -363,7 +363,7 @@ impl CryptoStream { method: CipherKind, key: &[u8], ) -> CryptoStream { - static EMPTY_IDENTITY: [Bytes; 0] = []; + const EMPTY_IDENTITY: [Bytes; 0] = []; CryptoStream::from_stream_with_identity(context, stream, stream_ty, method, key, &EMPTY_IDENTITY, None) } diff --git a/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs b/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs index 784f39e478dd..066e1218edea 100644 --- a/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs +++ b/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs @@ -69,7 +69,7 @@ impl ProxyServerStream { #[cfg(not(feature = "aead-cipher-2022"))] let writer_state = ProxyServerStreamWriteState::Established; - static EMPTY_IDENTITY: [Bytes; 0] = []; + const EMPTY_IDENTITY: [Bytes; 0] = []; ProxyServerStream { stream: CryptoStream::from_stream_with_identity( &context, diff --git a/crates/shadowsocks/tests/tcp.rs b/crates/shadowsocks/tests/tcp.rs index cc28c26e3075..0135daca75c6 100644 --- a/crates/shadowsocks/tests/tcp.rs +++ b/crates/shadowsocks/tests/tcp.rs @@ -135,7 +135,7 @@ async fn tcp_tunnel_example( let mut client = TcpStream::connect(local_addr).await?; - static HTTP_REQUEST: &[u8] = b"GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\nConnection: close\r\n\r\n"; + const HTTP_REQUEST: &[u8] = b"GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\nConnection: close\r\n\r\n"; client.write_all(HTTP_REQUEST).await?; let mut reader = BufReader::new(client); @@ -145,7 +145,7 @@ async fn tcp_tunnel_example( println!("{:?}", ByteStr::new(&buffer)); - static HTTP_RESPONSE_STATUS: &[u8] = b"HTTP/1.0 200 OK\r\n"; + const HTTP_RESPONSE_STATUS: &[u8] = b"HTTP/1.0 200 OK\r\n"; assert!(buffer.starts_with(HTTP_RESPONSE_STATUS)); Ok(()) diff --git a/crates/shadowsocks/tests/tcp_tfo.rs b/crates/shadowsocks/tests/tcp_tfo.rs index b14e8cfb9941..6058ebd135a7 100644 --- a/crates/shadowsocks/tests/tcp_tfo.rs +++ b/crates/shadowsocks/tests/tcp_tfo.rs @@ -97,6 +97,6 @@ async fn tcp_tunnel_tfo() { println!("{:?}", ByteStr::new(&buffer)); - static HTTP_RESPONSE_STATUS: &[u8] = b"HTTP/1.0 200 OK\r\n"; + const HTTP_RESPONSE_STATUS: &[u8] = b"HTTP/1.0 200 OK\r\n"; assert!(buffer.starts_with(HTTP_RESPONSE_STATUS)); } diff --git a/crates/shadowsocks/tests/udp.rs b/crates/shadowsocks/tests/udp.rs index de2110365839..8b257eec4f48 100644 --- a/crates/shadowsocks/tests/udp.rs +++ b/crates/shadowsocks/tests/udp.rs @@ -125,7 +125,7 @@ async fn udp_tunnel_echo( let socket = UdpSocket::bind("0.0.0.0:0").await?; socket.connect(local_addr).await?; - static SEND_PAYLOAD: &[u8] = b"HELLO WORLD. \x0012345"; + const SEND_PAYLOAD: &[u8] = b"HELLO WORLD. \x0012345"; socket.send(SEND_PAYLOAD).await?; let mut buffer = [0u8; 65536]; diff --git a/tests/dns.rs b/tests/dns.rs index 9f6854a30ebd..1d3609d32bbf 100644 --- a/tests/dns.rs +++ b/tests/dns.rs @@ -56,7 +56,7 @@ async fn dns_relay() { time::sleep(Duration::from_secs(1)).await; // Query firefox.com, TransactionID: 0x1234 - static DNS_QUERY: &[u8] = b"\x12\x34\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07firefox\x03com\x00\x00\x01\x00\x01"; + const DNS_QUERY: &[u8] = b"\x12\x34\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07firefox\x03com\x00\x00\x01\x00\x01"; // 1. DoT { diff --git a/tests/socks4.rs b/tests/socks4.rs index 1c1b70374571..96799829966a 100644 --- a/tests/socks4.rs +++ b/tests/socks4.rs @@ -86,7 +86,7 @@ async fn socks4_relay_connect() { let svr = Socks4TestServer::new(SERVER_ADDR, LOCAL_ADDR, PASSWORD, METHOD); svr.run().await; - static HTTP_REQUEST: &[u8] = b"GET /success.txt HTTP/1.0\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\n\r\n"; + const HTTP_REQUEST: &[u8] = b"GET /success.txt HTTP/1.0\r\nHost: detectportal.firefox.com\r\nAccept: */*\r\n\r\n"; let mut c = Socks4TcpClient::connect(("detectportal.firefox.com", 80), LOCAL_ADDR, Vec::new()) .await