Skip to content

Commit 2b30673

Browse files
committed
refactor: clean up unused code and improve type annotations
1 parent aa74794 commit 2b30673

File tree

9 files changed

+10
-36
lines changed

9 files changed

+10
-36
lines changed

protocol/raw/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub struct RawNetConfig {
100100
}
101101

102102
pub struct TunTapSetup {
103+
#[allow(dead_code)]
103104
pub name: Option<String>,
104105
pub addr: Ipv4Addr,
105106
pub destination_addr: IpCidr,

protocol/raw/src/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{net::Ipv4Addr, str::FromStr};
22

33
use crate::config::{DeviceConfig, RawNetConfig, TunTap, TunTapSetup};
44
use boxed::BoxedAsyncDevice;
5+
#[allow(unused_imports)]
56
pub use interface_info::get_interface_info;
67
use rd_interface::{Error, Result};
78
use tokio_smoltcp::smoltcp::wire::{EthernetAddress, IpCidr};

protocol/rpc/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum RpcValue {
1919
}
2020

2121
#[derive(Debug, Deserialize, Serialize)]
22+
#[allow(dead_code)]
2223
pub enum Error {
2324
ObjectNotFound,
2425
}

protocol/ss/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn test_ss_server_client() {
2929
udp: true,
3030
cipher: Cipher::AES_128_GCM,
3131
};
32-
let server = server::SSServer::new(server_cfg);
32+
let server = server::SSServer::new(server_cfg).unwrap();
3333
tokio::spawn(async move { server.start().await });
3434

3535
sleep(Duration::from_secs(1)).await;
@@ -41,7 +41,7 @@ async fn test_ss_server_client() {
4141
cipher: Cipher::AES_128_GCM,
4242
net: NetRef::new_with_value(Value::String("local".to_string()), local.clone()),
4343
};
44-
let client = client::SSNet::new(client_cfg).into_dyn();
44+
let client = client::SSNet::new(client_cfg).unwrap().into_dyn();
4545

4646
assert_echo(&client, "127.0.0.1:26666").await;
4747
assert_echo_udp(&client, "127.0.0.1:26666").await;

protocol/ss/src/wrapper.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rd_interface::{
77
};
88
use shadowsocks::{
99
context::SharedContext,
10-
crypto::{CipherCategory, CipherKind},
10+
crypto::CipherKind,
1111
relay::{socks5::Address as SSAddress, tcprelay::crypto_io},
1212
ProxyClientStream, ServerConfig,
1313
};
@@ -233,28 +233,6 @@ impl IUdpSocket for WrapSSUdp {
233233
pub struct CryptoStream<S>(crypto_io::CryptoStream<S>, SharedContext);
234234

235235
impl<S> CryptoStream<S> {
236-
pub fn from_stream(context: SharedContext, stream: S, method: CipherKind, key: &[u8]) -> Self {
237-
Self::from_client_stream(context, stream, method, key)
238-
}
239-
240-
pub fn from_client_stream(
241-
context: SharedContext,
242-
stream: S,
243-
method: CipherKind,
244-
key: &[u8],
245-
) -> Self {
246-
CryptoStream(
247-
crypto_io::CryptoStream::<S>::from_stream(
248-
&context,
249-
stream,
250-
crypto_io::StreamType::Client,
251-
method,
252-
key,
253-
),
254-
context,
255-
)
256-
}
257-
258236
pub fn from_server_stream(
259237
context: SharedContext,
260238
stream: S,

rd-interface/src/config/compact_vec_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl CompactVecString {
4848
self.underlying.shrink_to_fit();
4949
self.index.shrink_to_fit();
5050
}
51-
pub fn iter(&self) -> Iter {
51+
pub fn iter(&self) -> Iter<'_> {
5252
Iter {
5353
inner: self,
5454
index: 0,

rd-std/src/builtin/dns.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::net::SocketAddr;
22

33
use rd_derive::rd_config;
44
use rd_interface::{
5-
async_trait, config::NetRef, prelude::*, registry::Builder, Address, Error, INet, IntoDyn, Net,
6-
Result,
5+
async_trait, config::NetRef, prelude::*, registry::Builder, Address, INet, IntoDyn, Net, Result,
76
};
87
use trust_dns_resolver::{
98
config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts},
@@ -34,7 +33,6 @@ pub struct DnsConfig {
3433
}
3534

3635
pub struct DnsNet {
37-
net: Net,
3836
resolver: AsyncResolver<GenericConnector<RDRuntime>>,
3937
}
4038

@@ -95,7 +93,7 @@ impl Builder<Net> for DnsNet {
9593
GenericConnector::new(RDRuntime { net: net.clone() }),
9694
);
9795

98-
Ok(Self { resolver, net })
96+
Ok(Self { resolver })
9997
}
10098
}
10199

rd-std/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub fn is_reserved(addr: IpAddr) -> bool {
4343
IpAddr::V4(a) => {
4444
let [a0, a1, ..] = a.octets();
4545
a.is_unspecified()
46+
|| a0 == 0 // 0.0.0.0/8 ("this host on this network")
4647
|| a.is_loopback()
4748
|| a.is_private()
4849
|| (a0 == 169 && a1 == 254) // 169.254.0.0/16

src/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,6 @@ pub struct Import {
236236

237237
impl Import {}
238238

239-
#[derive(Debug, Serialize, Deserialize, Clone)]
240-
pub(crate) struct ConfigImport {
241-
#[serde(default)]
242-
import: Vec<Import>,
243-
}
244-
245239
#[derive(Debug, Serialize, Deserialize, Clone)]
246240
pub struct ConfigExt {
247241
#[serde(flatten)]

0 commit comments

Comments
 (0)