diff --git a/.gitignore b/.gitignore index ad67955..6b5f1d5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ target # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +*.rs +target +Cargo.lock +src diff --git a/Cargo.lock b/Cargo.lock index fb45f19..251f0b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2087,7 +2087,7 @@ dependencies = [ [[package]] name = "telemt" -version = "3.0.10" +version = "3.0.13" dependencies = [ "aes", "anyhow", diff --git a/proxy-secret b/proxy-secret new file mode 100644 index 0000000..ef77163 --- /dev/null +++ b/proxy-secret @@ -0,0 +1 @@ +ʖxHl~,D0d]UJUAM'!FnRZD>ϳF>yZfa*ߜڋ o8zM:dq>\3w}n\TĐy'VIil&] \ No newline at end of file diff --git a/src/config/load.rs b/src/config/load.rs index 4d59e60..dce5fbc 100644 --- a/src/config/load.rs +++ b/src/config/load.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use std::collections::HashMap; use std::net::IpAddr; use std::path::Path; diff --git a/src/crypto/aes.rs b/src/crypto/aes.rs index 9e123bf..674e4cb 100644 --- a/src/crypto/aes.rs +++ b/src/crypto/aes.rs @@ -11,6 +11,8 @@ //! `HandshakeSuccess`, `ObfuscationParams`) are responsible for //! zeroizing their own copies. +#![allow(dead_code)] + use aes::Aes256; use ctr::{Ctr128BE, cipher::{KeyIvInit, StreamCipher}}; use zeroize::Zeroize; diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 266a3cb..9108f34 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -6,7 +6,6 @@ pub mod random; pub use aes::{AesCtr, AesCbc}; pub use hash::{ - build_middleproxy_prekey, crc32, crc32c, derive_middleproxy_keys, md5, sha1, sha256, - sha256_hmac, + build_middleproxy_prekey, crc32, crc32c, derive_middleproxy_keys, sha256, sha256_hmac, }; pub use random::SecureRandom; diff --git a/src/crypto/random.rs b/src/crypto/random.rs index f3432e0..0dd5f1a 100644 --- a/src/crypto/random.rs +++ b/src/crypto/random.rs @@ -1,5 +1,8 @@ //! Pseudorandom +#![allow(deprecated)] +#![allow(dead_code)] + use rand::{Rng, RngCore, SeedableRng}; use rand::rngs::StdRng; use parking_lot::Mutex; diff --git a/src/error.rs b/src/error.rs index f934672..eaebd88 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,7 @@ //! Error Types +#![allow(dead_code)] + use std::fmt; use std::net::SocketAddr; use thiserror::Error; diff --git a/src/ip_tracker.rs b/src/ip_tracker.rs index 17cebc7..32fcbe3 100644 --- a/src/ip_tracker.rs +++ b/src/ip_tracker.rs @@ -1,5 +1,7 @@ // src/ip_tracker.rs -// Модуль для отслеживания и ограничения уникальных IP-адресов пользователей +// IP address tracking and limiting for users + +#![allow(dead_code)] use std::collections::{HashMap, HashSet}; use std::net::IpAddr; diff --git a/src/main.rs b/src/main.rs index 0601215..0d1eccc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ //! telemt — Telegram MTProto Proxy +#![allow(unused_assignments)] + use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; @@ -417,6 +419,7 @@ match crate::transport::middle_proxy::fetch_proxy_secret(proxy_secret_path).awai if me_pool.is_some() { info!("Transport: Middle-End Proxy - all DC-over-RPC"); } else { + let _ = use_middle_proxy; use_middle_proxy = false; // Make runtime config reflect direct-only mode for handlers. config.general.use_middle_proxy = false; diff --git a/src/metrics.rs b/src/metrics.rs index d11c302..620840d 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -2,7 +2,7 @@ use std::convert::Infallible; use std::net::SocketAddr; use std::sync::Arc; -use http_body_util::{Full, BodyExt}; +use http_body_util::Full; use hyper::body::Bytes; use hyper::server::conn::http1; use hyper::service::service_fn; diff --git a/src/network/probe.rs b/src/network/probe.rs index d290ac1..eda69b8 100644 --- a/src/network/probe.rs +++ b/src/network/probe.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}; use tracing::{info, warn}; diff --git a/src/network/stun.rs b/src/network/stun.rs index 6a93339..c47aa49 100644 --- a/src/network/stun.rs +++ b/src/network/stun.rs @@ -1,3 +1,6 @@ +#![allow(unreachable_code)] +#![allow(dead_code)] + use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use tokio::net::{lookup_host, UdpSocket}; diff --git a/src/protocol/constants.rs b/src/protocol/constants.rs index c930a1b..e6ddbaf 100644 --- a/src/protocol/constants.rs +++ b/src/protocol/constants.rs @@ -1,6 +1,8 @@ //! Protocol constants and datacenter addresses -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; +#![allow(dead_code)] + +use std::net::{IpAddr, Ipv4Addr}; use crate::crypto::SecureRandom; use std::sync::LazyLock; diff --git a/src/protocol/frame.rs b/src/protocol/frame.rs index f4517b4..a332be0 100644 --- a/src/protocol/frame.rs +++ b/src/protocol/frame.rs @@ -1,5 +1,7 @@ //! MTProto frame types and metadata +#![allow(dead_code)] + use std::collections::HashMap; /// Extra metadata associated with a frame diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 4081f1c..5518df2 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -5,7 +5,11 @@ pub mod frame; pub mod obfuscation; pub mod tls; +#[allow(unused_imports)] pub use constants::*; +#[allow(unused_imports)] pub use frame::*; +#[allow(unused_imports)] pub use obfuscation::*; +#[allow(unused_imports)] pub use tls::*; \ No newline at end of file diff --git a/src/protocol/obfuscation.rs b/src/protocol/obfuscation.rs index 4d2197d..d9d1c0a 100644 --- a/src/protocol/obfuscation.rs +++ b/src/protocol/obfuscation.rs @@ -1,8 +1,9 @@ //! MTProto Obfuscation +#![allow(dead_code)] + use zeroize::Zeroize; use crate::crypto::{sha256, AesCtr}; -use crate::error::Result; use super::constants::*; /// Obfuscation parameters from handshake diff --git a/src/protocol/tls.rs b/src/protocol/tls.rs index 93d111f..f124c46 100644 --- a/src/protocol/tls.rs +++ b/src/protocol/tls.rs @@ -4,8 +4,9 @@ //! for domain fronting. The handshake looks like valid TLS 1.3 but //! actually carries MTProto authentication data. +#![allow(dead_code)] + use crate::crypto::{sha256_hmac, SecureRandom}; -use crate::error::{ProxyError, Result}; use super::constants::*; use std::time::{SystemTime, UNIX_EPOCH}; use num_bigint::BigUint; diff --git a/src/proxy/client.rs b/src/proxy/client.rs index 14b45da..051ce9e 100644 --- a/src/proxy/client.rs +++ b/src/proxy/client.rs @@ -271,7 +271,7 @@ impl RunningClientHandler { self.peer = normalize_ip(self.peer); let peer = self.peer; - let ip_tracker = self.ip_tracker.clone(); + let _ip_tracker = self.ip_tracker.clone(); debug!(peer = %peer, "New connection"); if let Err(e) = configure_client_socket( @@ -331,7 +331,7 @@ impl RunningClientHandler { let is_tls = tls::is_tls_handshake(&first_bytes[..3]); let peer = self.peer; - let ip_tracker = self.ip_tracker.clone(); + let _ip_tracker = self.ip_tracker.clone(); debug!(peer = %peer, is_tls = is_tls, "Handshake type detected"); @@ -344,7 +344,7 @@ impl RunningClientHandler { async fn handle_tls_client(mut self, first_bytes: [u8; 5]) -> Result { let peer = self.peer; - let ip_tracker = self.ip_tracker.clone(); + let _ip_tracker = self.ip_tracker.clone(); let tls_len = u16::from_be_bytes([first_bytes[3], first_bytes[4]]) as usize; @@ -440,7 +440,7 @@ impl RunningClientHandler { async fn handle_direct_client(mut self, first_bytes: [u8; 5]) -> Result { let peer = self.peer; - let ip_tracker = self.ip_tracker.clone(); + let _ip_tracker = self.ip_tracker.clone(); if !self.config.general.modes.classic && !self.config.general.modes.secure { debug!(peer = %peer, "Non-TLS modes disabled"); diff --git a/src/proxy/handshake.rs b/src/proxy/handshake.rs index 750d839..5c63636 100644 --- a/src/proxy/handshake.rs +++ b/src/proxy/handshake.rs @@ -1,5 +1,7 @@ //! MTProto Handshake +#![allow(dead_code)] + use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; diff --git a/src/proxy/mod.rs b/src/proxy/mod.rs index d6243aa..bedae1a 100644 --- a/src/proxy/mod.rs +++ b/src/proxy/mod.rs @@ -8,6 +8,9 @@ pub mod middle_relay; pub mod relay; pub use client::ClientHandler; +#[allow(unused_imports)] pub use handshake::*; +#[allow(unused_imports)] pub use masking::*; +#[allow(unused_imports)] pub use relay::*; diff --git a/src/stats/mod.rs b/src/stats/mod.rs index 1994b36..3169f1d 100644 --- a/src/stats/mod.rs +++ b/src/stats/mod.rs @@ -1,7 +1,8 @@ //! Statistics and replay protection +#![allow(dead_code)] + use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::Arc; use std::time::{Instant, Duration}; use dashmap::DashMap; use parking_lot::Mutex; diff --git a/src/stream/buffer_pool.rs b/src/stream/buffer_pool.rs index 0de5532..9c46922 100644 --- a/src/stream/buffer_pool.rs +++ b/src/stream/buffer_pool.rs @@ -3,6 +3,8 @@ //! This module provides a thread-safe pool of BytesMut buffers //! that can be reused across connections to reduce allocation pressure. +#![allow(dead_code)] + use bytes::BytesMut; use crossbeam_queue::ArrayQueue; use std::ops::{Deref, DerefMut}; diff --git a/src/stream/crypto_stream.rs b/src/stream/crypto_stream.rs index ebb6f43..67d8c95 100644 --- a/src/stream/crypto_stream.rs +++ b/src/stream/crypto_stream.rs @@ -18,6 +18,8 @@ //! is either written to upstream or stored in our pending buffer //! - when upstream is pending -> ciphertext is buffered/bounded and backpressure is applied //! + +#![allow(dead_code)] //! ======================= //! Writer state machine //! ======================= @@ -55,7 +57,7 @@ use std::io::{self, ErrorKind, Result}; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use tracing::{debug, trace, warn}; +use tracing::{debug, trace}; use crate::crypto::AesCtr; use super::state::{StreamState, YieldBuffer}; diff --git a/src/stream/frame.rs b/src/stream/frame.rs index b97d4cf..5c93ea7 100644 --- a/src/stream/frame.rs +++ b/src/stream/frame.rs @@ -3,6 +3,8 @@ //! This module defines the common types and traits used by all //! frame encoding/decoding implementations. +#![allow(dead_code)] + use bytes::{Bytes, BytesMut}; use std::io::Result; use std::sync::Arc; diff --git a/src/stream/frame_codec.rs b/src/stream/frame_codec.rs index 6b90892..3de8257 100644 --- a/src/stream/frame_codec.rs +++ b/src/stream/frame_codec.rs @@ -3,6 +3,8 @@ //! This module provides Encoder/Decoder implementations compatible //! with tokio-util's Framed wrapper for easy async frame I/O. +#![allow(dead_code)] + use bytes::{Bytes, BytesMut, BufMut}; use std::io::{self, Error, ErrorKind}; use std::sync::Arc; diff --git a/src/stream/frame_stream.rs b/src/stream/frame_stream.rs index 1726a06..b66c2cd 100644 --- a/src/stream/frame_stream.rs +++ b/src/stream/frame_stream.rs @@ -1,6 +1,8 @@ //! MTProto frame stream wrappers -use bytes::{Bytes, BytesMut}; +#![allow(dead_code)] + +use bytes::Bytes; use std::io::{Error, ErrorKind, Result}; use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt}; use crate::protocol::constants::*; diff --git a/src/stream/mod.rs b/src/stream/mod.rs index ea30e5e..a1cff9a 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -12,28 +12,34 @@ pub mod frame_codec; pub mod frame_stream; // Re-export state machine types +#[allow(unused_imports)] pub use state::{ StreamState, Transition, PollResult, ReadBuffer, WriteBuffer, HeaderBuffer, YieldBuffer, }; // Re-export buffer pool +#[allow(unused_imports)] pub use buffer_pool::{BufferPool, PooledBuffer, PoolStats}; // Re-export stream implementations +#[allow(unused_imports)] pub use crypto_stream::{CryptoReader, CryptoWriter, PassthroughStream}; pub use tls_stream::{FakeTlsReader, FakeTlsWriter}; // Re-export frame types +#[allow(unused_imports)] pub use frame::{Frame, FrameMeta, FrameCodec as FrameCodecTrait, create_codec}; -// Re-export tokio-util compatible codecs +// Re-export tokio-util compatible codecs +#[allow(unused_imports)] pub use frame_codec::{ FrameCodec, AbridgedCodec, IntermediateCodec, SecureCodec, }; // Legacy re-exports for compatibility +#[allow(unused_imports)] pub use frame_stream::{ AbridgedFrameReader, AbridgedFrameWriter, IntermediateFrameReader, IntermediateFrameWriter, diff --git a/src/stream/state.rs b/src/stream/state.rs index c4f52e6..7c57792 100644 --- a/src/stream/state.rs +++ b/src/stream/state.rs @@ -3,6 +3,8 @@ //! This module provides core types and traits for implementing //! stateful async streams with proper partial read/write handling. +#![allow(dead_code)] + use bytes::{Bytes, BytesMut}; use std::io; diff --git a/src/stream/tls_stream.rs b/src/stream/tls_stream.rs index edf970d..fa165db 100644 --- a/src/stream/tls_stream.rs +++ b/src/stream/tls_stream.rs @@ -18,6 +18,8 @@ //! - Explicit state machines for all async operations //! - Never lose data on partial reads //! - Atomic TLS record formation for writes + +#![allow(dead_code)] //! - Proper handling of all TLS record types //! //! Important nuance (Telegram FakeTLS): diff --git a/src/stream/traits.rs b/src/stream/traits.rs index 6419824..f6d7c4f 100644 --- a/src/stream/traits.rs +++ b/src/stream/traits.rs @@ -1,5 +1,7 @@ //! Stream traits and common types +#![allow(dead_code)] + use bytes::Bytes; use std::io::Result; use std::pin::Pin; diff --git a/src/tls_front/cache.rs b/src/tls_front/cache.rs index 15a97af..a425a35 100644 --- a/src/tls_front/cache.rs +++ b/src/tls_front/cache.rs @@ -19,6 +19,7 @@ pub struct TlsFrontCache { disk_path: PathBuf, } +#[allow(dead_code)] impl TlsFrontCache { pub fn new(domains: &[String], default_len: usize, disk_path: impl AsRef) -> Self { let default_template = ParsedServerHello { @@ -173,7 +174,7 @@ impl TlsFrontCache { tokio::spawn(async move { loop { for domain in &domains { - fetcher(domain.clone()).await; + let _ = fetcher(domain.clone()).await; } sleep(interval).await; } diff --git a/src/tls_front/mod.rs b/src/tls_front/mod.rs index 89f3988..311920d 100644 --- a/src/tls_front/mod.rs +++ b/src/tls_front/mod.rs @@ -4,4 +4,5 @@ pub mod fetcher; pub mod emulator; pub use cache::TlsFrontCache; +#[allow(unused_imports)] pub use types::{CachedTlsData, TlsFetchResult}; diff --git a/src/transport/middle_proxy/health.rs b/src/transport/middle_proxy/health.rs index 18814cd..e73e5f1 100644 --- a/src/transport/middle_proxy/health.rs +++ b/src/transport/middle_proxy/health.rs @@ -14,6 +14,7 @@ use super::MePool; const HEALTH_INTERVAL_SECS: u64 = 1; const JITTER_FRAC_NUM: u64 = 2; // jitter up to 50% of backoff +#[allow(dead_code)] const MAX_CONCURRENT_PER_DC_DEFAULT: usize = 1; pub async fn me_health_monitor(pool: Arc, rng: Arc, _min_connections: usize) { diff --git a/src/transport/middle_proxy/mod.rs b/src/transport/middle_proxy/mod.rs index 1027221..f9f8c85 100644 --- a/src/transport/middle_proxy/mod.rs +++ b/src/transport/middle_proxy/mod.rs @@ -17,8 +17,10 @@ mod wire; use bytes::Bytes; pub use health::me_health_monitor; +#[allow(unused_imports)] pub use ping::{run_me_ping, format_sample_line, MePingReport, MePingSample, MePingFamily}; pub use pool::MePool; +#[allow(unused_imports)] pub use pool_nat::{stun_probe, detect_public_ip}; pub use registry::ConnRegistry; pub use secret::fetch_proxy_secret; diff --git a/src/transport/middle_proxy/ping.rs b/src/transport/middle_proxy/ping.rs index 36ef4e7..a1dd1e6 100644 --- a/src/transport/middle_proxy/ping.rs +++ b/src/transport/middle_proxy/ping.rs @@ -24,6 +24,7 @@ pub struct MePingSample { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct MePingReport { pub dc: i32, pub family: MePingFamily, diff --git a/src/transport/middle_proxy/pool.rs b/src/transport/middle_proxy/pool.rs index 8e159db..2047e80 100644 --- a/src/transport/middle_proxy/pool.rs +++ b/src/transport/middle_proxy/pool.rs @@ -36,6 +36,7 @@ pub struct MeWriter { pub allow_drain_fallback: Arc, } +#[allow(dead_code)] pub struct MePool { pub(super) registry: Arc, pub(super) writers: Arc>>, @@ -992,6 +993,7 @@ impl MePool { } +#[allow(dead_code)] fn hex_dump(data: &[u8]) -> String { const MAX: usize = 64; let mut out = String::with_capacity(data.len() * 2 + 3); diff --git a/src/transport/middle_proxy/pool_nat.rs b/src/transport/middle_proxy/pool_nat.rs index d3dec16..4d9e2a1 100644 --- a/src/transport/middle_proxy/pool_nat.rs +++ b/src/transport/middle_proxy/pool_nat.rs @@ -1,7 +1,7 @@ use std::net::{IpAddr, Ipv4Addr}; use std::time::Duration; -use tracing::{info, warn, debug}; +use tracing::{info, warn}; use crate::error::{ProxyError, Result}; use crate::network::probe::is_bogon; @@ -9,11 +9,14 @@ use crate::network::stun::{stun_probe_dual, IpFamily, StunProbeResult}; use super::MePool; use std::time::Instant; + +#[allow(dead_code)] pub async fn stun_probe(stun_addr: Option) -> Result { let stun_addr = stun_addr.unwrap_or_else(|| "stun.l.google.com:19302".to_string()); stun_probe_dual(&stun_addr).await } +#[allow(dead_code)] pub async fn detect_public_ip() -> Option { fetch_public_ipv4_with_retry().await.ok().flatten().map(IpAddr::V4) } diff --git a/src/transport/middle_proxy/registry.rs b/src/transport/middle_proxy/registry.rs index 6a9250d..2122ed8 100644 --- a/src/transport/middle_proxy/registry.rs +++ b/src/transport/middle_proxy/registry.rs @@ -21,6 +21,7 @@ pub enum RouteResult { } #[derive(Clone)] +#[allow(dead_code)] pub struct ConnMeta { pub target_dc: i16, pub client_addr: SocketAddr, @@ -29,6 +30,7 @@ pub struct ConnMeta { } #[derive(Clone)] +#[allow(dead_code)] pub struct BoundConn { pub conn_id: u64, pub meta: ConnMeta, @@ -167,6 +169,7 @@ impl ConnRegistry { out } + #[allow(dead_code)] pub async fn get_meta(&self, conn_id: u64) -> Option { let inner = self.inner.read().await; inner.meta.get(&conn_id).cloned() diff --git a/src/transport/middle_proxy/secret.rs b/src/transport/middle_proxy/secret.rs index a9e224d..9641143 100644 --- a/src/transport/middle_proxy/secret.rs +++ b/src/transport/middle_proxy/secret.rs @@ -1,5 +1,3 @@ -use std::time::Duration; - use tracing::{debug, info, warn}; use std::time::SystemTime; use httpdate; diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 51cffa4..ead0565 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -6,9 +6,13 @@ pub mod socket; pub mod socks; pub mod upstream; +#[allow(unused_imports)] pub use pool::ConnectionPool; +#[allow(unused_imports)] pub use proxy_protocol::{ProxyProtocolInfo, parse_proxy_protocol}; pub use socket::*; +#[allow(unused_imports)] pub use socks::*; +#[allow(unused_imports)] pub use upstream::{DcPingResult, StartupPingResult, UpstreamManager}; pub mod middle_proxy; diff --git a/src/transport/pool.rs b/src/transport/pool.rs index 8d83321..fa9dcad 100644 --- a/src/transport/pool.rs +++ b/src/transport/pool.rs @@ -1,5 +1,7 @@ //! Connection Pool +#![allow(dead_code)] + use std::collections::HashMap; use std::net::SocketAddr; use std::sync::Arc; @@ -8,7 +10,7 @@ use tokio::net::TcpStream; use tokio::sync::Mutex; use tokio::time::timeout; use parking_lot::RwLock; -use tracing::{debug, warn}; +use tracing::debug; use crate::error::{ProxyError, Result}; use super::socket::configure_tcp_socket; diff --git a/src/transport/proxy_protocol.rs b/src/transport/proxy_protocol.rs index 56746c4..770be7e 100644 --- a/src/transport/proxy_protocol.rs +++ b/src/transport/proxy_protocol.rs @@ -28,6 +28,7 @@ mod address_family { /// Information extracted from PROXY protocol header #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct ProxyProtocolInfo { /// Source (client) address pub src_addr: SocketAddr, @@ -37,6 +38,7 @@ pub struct ProxyProtocolInfo { pub version: u8, } +#[allow(dead_code)] impl ProxyProtocolInfo { /// Create info with just source address pub fn new(src_addr: SocketAddr) -> Self { @@ -231,12 +233,14 @@ async fn parse_v2( } /// Builder for PROXY protocol v1 header +#[allow(dead_code)] pub struct ProxyProtocolV1Builder { family: &'static str, src_addr: Option, dst_addr: Option, } +#[allow(dead_code)] impl ProxyProtocolV1Builder { pub fn new() -> Self { Self { @@ -284,11 +288,13 @@ impl Default for ProxyProtocolV1Builder { } /// Builder for PROXY protocol v2 header +#[allow(dead_code)] pub struct ProxyProtocolV2Builder { src: Option, dst: Option, } +#[allow(dead_code)] impl ProxyProtocolV2Builder { pub fn new() -> Self { Self { src: None, dst: None } diff --git a/src/transport/socket.rs b/src/transport/socket.rs index b41cfd1..0a20c3c 100644 --- a/src/transport/socket.rs +++ b/src/transport/socket.rs @@ -10,6 +10,7 @@ use socket2::{Socket, TcpKeepalive, Domain, Type, Protocol}; use tracing::debug; /// Configure TCP socket with recommended settings for proxy use +#[allow(dead_code)] pub fn configure_tcp_socket( stream: &TcpStream, keepalive: bool, @@ -82,6 +83,7 @@ pub fn configure_client_socket( } /// Set socket to send RST on close (for masking) +#[allow(dead_code)] pub fn set_linger_zero(stream: &TcpStream) -> Result<()> { let socket = socket2::SockRef::from(stream); socket.set_linger(Some(Duration::ZERO))?; @@ -89,6 +91,7 @@ pub fn set_linger_zero(stream: &TcpStream) -> Result<()> { } /// Create a new TCP socket for outgoing connections +#[allow(dead_code)] pub fn create_outgoing_socket(addr: SocketAddr) -> Result { create_outgoing_socket_bound(addr, None) } @@ -120,6 +123,7 @@ pub fn create_outgoing_socket_bound(addr: SocketAddr, bind_addr: Option) /// Get local address of a socket +#[allow(dead_code)] pub fn get_local_addr(stream: &TcpStream) -> Option { stream.local_addr().ok() } @@ -157,11 +161,13 @@ pub fn resolve_interface_ip(_name: &str, _want_ipv6: bool) -> Option { } /// Get peer address of a socket +#[allow(dead_code)] pub fn get_peer_addr(stream: &TcpStream) -> Option { stream.peer_addr().ok() } /// Check if address is IPv6 +#[allow(dead_code)] pub fn is_ipv6(addr: &SocketAddr) -> bool { addr.is_ipv6() } diff --git a/src/transport/socks.rs b/src/transport/socks.rs index 35268cb..188d369 100644 --- a/src/transport/socks.rs +++ b/src/transport/socks.rs @@ -1,7 +1,7 @@ //! SOCKS4/5 Client Implementation use std::net::{IpAddr, SocketAddr}; -use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; use crate::error::{ProxyError, Result}; diff --git a/src/transport/upstream.rs b/src/transport/upstream.rs index 6dcc36f..887fa99 100644 --- a/src/transport/upstream.rs +++ b/src/transport/upstream.rs @@ -1,7 +1,9 @@ //! Upstream Management with per-DC latency-weighted selection -//! +//! //! IPv6/IPv4 connectivity checks with configurable preference. +#![allow(deprecated)] + use std::collections::HashMap; use std::net::{SocketAddr, IpAddr}; use std::sync::Arc; @@ -549,7 +551,7 @@ impl UpstreamManager { /// Tests BOTH IPv6 and IPv4, returns separate results for each. pub async fn ping_all_dcs( &self, - prefer_ipv6: bool, + _prefer_ipv6: bool, dc_overrides: &HashMap>, ipv4_enabled: bool, ipv6_enabled: bool, @@ -907,6 +909,7 @@ impl UpstreamManager { } /// Get the preferred IP for a DC (for use by other components) + #[allow(dead_code)] pub async fn get_dc_ip_preference(&self, dc_idx: i16) -> Option { let guard = self.upstreams.read().await; if guard.is_empty() { @@ -918,6 +921,7 @@ impl UpstreamManager { } /// Get preferred DC address based on config preference + #[allow(dead_code)] pub async fn get_dc_addr(&self, dc_idx: i16, prefer_ipv6: bool) -> Option { let arr_idx = UpstreamState::dc_array_idx(dc_idx)?; diff --git a/src/util/ip.rs b/src/util/ip.rs index 9bde513..f3e774f 100644 --- a/src/util/ip.rs +++ b/src/util/ip.rs @@ -1,22 +1,24 @@ //! IP Addr Detect -use std::net::{IpAddr, SocketAddr, UdpSocket}; +use std::net::{IpAddr, UdpSocket}; use std::time::Duration; use tracing::{debug, warn}; /// Detected IP addresses #[derive(Debug, Clone, Default)] +#[allow(dead_code)] pub struct IpInfo { pub ipv4: Option, pub ipv6: Option, } +#[allow(dead_code)] impl IpInfo { /// Check if any IP is detected pub fn has_any(&self) -> bool { self.ipv4.is_some() || self.ipv6.is_some() } - + /// Get preferred IP (IPv6 if available and preferred) pub fn preferred(&self, prefer_ipv6: bool) -> Option { if prefer_ipv6 { @@ -28,12 +30,14 @@ impl IpInfo { } /// URLs for IP detection +#[allow(dead_code)] const IPV4_URLS: &[&str] = &[ "http://v4.ident.me/", "http://ipv4.icanhazip.com/", "http://api.ipify.org/", ]; +#[allow(dead_code)] const IPV6_URLS: &[&str] = &[ "http://v6.ident.me/", "http://ipv6.icanhazip.com/", @@ -42,12 +46,14 @@ const IPV6_URLS: &[&str] = &[ /// Detect local IP address by connecting to a public DNS /// This does not actually send any packets +#[allow(dead_code)] fn get_local_ip(target: &str) -> Option { let socket = UdpSocket::bind("0.0.0.0:0").ok()?; socket.connect(target).ok()?; socket.local_addr().ok().map(|addr| addr.ip()) } +#[allow(dead_code)] fn get_local_ipv6(target: &str) -> Option { let socket = UdpSocket::bind("[::]:0").ok()?; socket.connect(target).ok()?; @@ -55,6 +61,7 @@ fn get_local_ipv6(target: &str) -> Option { } /// Detect public IP addresses +#[allow(dead_code)] pub async fn detect_ip() -> IpInfo { let mut info = IpInfo::default(); @@ -119,6 +126,7 @@ pub async fn detect_ip() -> IpInfo { info } +#[allow(dead_code)] fn is_private_ip(ip: IpAddr) -> bool { match ip { IpAddr::V4(ipv4) => { @@ -131,19 +139,21 @@ fn is_private_ip(ip: IpAddr) -> bool { } /// Fetch IP from URL +#[allow(dead_code)] async fn fetch_ip(url: &str) -> Option { let client = reqwest::Client::builder() .timeout(Duration::from_secs(5)) .build() .ok()?; - + let response = client.get(url).send().await.ok()?; let text = response.text().await.ok()?; - + text.trim().parse().ok() } /// Synchronous IP detection (for startup) +#[allow(dead_code)] pub fn detect_ip_sync() -> IpInfo { tokio::runtime::Handle::current().block_on(detect_ip()) } diff --git a/src/util/mod.rs b/src/util/mod.rs index 5d293d2..8851f51 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -3,5 +3,7 @@ pub mod ip; pub mod time; +#[allow(unused_imports)] pub use ip::*; +#[allow(unused_imports)] pub use time::*; \ No newline at end of file diff --git a/src/util/time.rs b/src/util/time.rs index 7db1633..310b015 100644 --- a/src/util/time.rs +++ b/src/util/time.rs @@ -4,11 +4,14 @@ use std::time::Duration; use chrono::{DateTime, Utc}; use tracing::{debug, warn, error}; +#[allow(dead_code)] const TIME_SYNC_URL: &str = "https://core.telegram.org/getProxySecret"; +#[allow(dead_code)] const MAX_TIME_SKEW_SECS: i64 = 30; /// Time sync result #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct TimeSyncResult { pub server_time: DateTime, pub local_time: DateTime, @@ -17,6 +20,7 @@ pub struct TimeSyncResult { } /// Check time synchronization with Telegram servers +#[allow(dead_code)] pub async fn check_time_sync() -> Option { let client = reqwest::Client::builder() .timeout(Duration::from_secs(10)) @@ -60,6 +64,7 @@ pub async fn check_time_sync() -> Option { } /// Background time sync task +#[allow(dead_code)] pub async fn time_sync_task(check_interval: Duration) -> ! { loop { if let Some(result) = check_time_sync().await {