Skip to content

Commit

Permalink
improve code by clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
e1732a364fed committed Jan 1, 2099
1 parent 6919248 commit f1e9684
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ o2node-.->collector
- [x] http_filter, websocket(including early data)
- [x] h2, grpc
- [x] quic
- [x] ip relay protocol test1
- [x] ip relay protocol (test1)
- [ ] tcp/ip netstack (smoltcp)
- [ ] ss?, vmess?

Expand Down
2 changes: 1 addition & 1 deletion rucimp/src/net/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn match_request_http_header<'a, T: 'a + std::fmt::Debug>(
//debug!("checking {r:?}");

if c.authority != given_host {
if given_host == "" {
if given_host.is_empty() {
let hh = r
.headers()
.get("host")
Expand Down
7 changes: 4 additions & 3 deletions src/map/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod accept;
pub mod echo;

use macro_map::*;
use parking_lot::Mutex;
use tokio::sync::mpsc::Receiver;
use tracing::debug;
use tracing::info;
Expand Down Expand Up @@ -105,6 +104,7 @@ impl Map for Direct {
}
}

#[cfg(feature = "tun")]
#[derive(Clone, Debug, Default)]
enum AutoRouteState {
#[default]
Expand All @@ -127,7 +127,8 @@ pub struct BindDialer {
#[cfg(feature = "tun")]
pub out_auto_route: Option<tun::route::OutAutoRouteParams>,

auto_route_state: Arc<Mutex<AutoRouteState>>,
#[cfg(feature = "tun")]
auto_route_state: Arc<parking_lot::Mutex<AutoRouteState>>,
}

impl Name for BindDialer {
Expand Down Expand Up @@ -190,8 +191,8 @@ impl BindDialer {

match r {
Ok(c) => {
#[cfg(feature = "tun")]
if let Some(a) = &bind_a {
#[cfg(feature = "tun")]
if let Network::IP = a.network {
if let Some(c) = &self.in_auto_route {
let mut mg = self.auto_route_state.lock();
Expand Down
2 changes: 1 addition & 1 deletion src/map/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl fmt::Display for HexSlice<'_> {
for byte in self.0 {
write!(f, "{:02X}", byte)?;
}
write!(f, "\n")?;
writeln!(f)?;
Ok(())
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/net/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ pub fn get_sys_dns() -> Vec<String> {
}
}

return vec![];
vec![]
}

#[allow(unused)]
pub fn set_sys_dns(list: Vec<&str>) -> std::io::Result<()> {
#[cfg(target_os = "linux")]
{
Expand Down
3 changes: 1 addition & 2 deletions src/net/tun/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(unused)]
pub mod route;

use anyhow::Context;
Expand Down Expand Up @@ -47,8 +48,6 @@ where
"tun: create_bind succeed"
);

// let dev = crate::net::helpers::PrintWrapper::from(Box::new(dev));

Ok(Box::new(dev))
}

Expand Down
2 changes: 2 additions & 0 deletions src/net/tun/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct OutAutoRouteParams {
const DEFAULT_ROUTER_IP: &str = "192.168.0.1";
const DEFAULT_ORIGINAL_DEV_NAME: &str = "enp0s1";

#[allow(unused)]
pub fn out_auto_route(params: &OutAutoRouteParams) -> anyhow::Result<()> {
#[cfg(target_os = "linux")]
{
Expand Down Expand Up @@ -60,6 +61,7 @@ iptables -t nat -I POSTROUTING -o {original_dev_name} -j MASQUERADE"#,
Ok(())
}

#[allow(unused)]
pub fn out_down_route(params: &OutAutoRouteParams) -> anyhow::Result<()> {
#[cfg(target_os = "linux")]
{
Expand Down

0 comments on commit f1e9684

Please sign in to comment.