Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
e1732a364fed committed Jan 1, 2099
1 parent cd9627f commit b216c3b
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 228 deletions.
6 changes: 0 additions & 6 deletions crates/ruci-tls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl Display for Client {
}
}

// impl<IO> ruci::Name for tokio_rustls::client::TlsStream<IO> {
// fn name(&self) -> &str {
// "tokio_rustls_client_stream"
// }
// }

fn default_cc() -> ClientConfig {
ClientConfig::builder()
.with_root_certificates(default_rcs())
Expand Down
1 change: 0 additions & 1 deletion crates/ruci-tls/src/mitm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use macro_map::{map_ext_fields, MapExt};
use ruci::map::*;
use ruci::net::helpers::EarlyDataWrapper;
use ruci::net::CID;
// use ruci::Name;
use ruci::{map, net::MTU};
use std::fmt::Display;
use std::sync::Arc;
Expand Down
6 changes: 0 additions & 6 deletions crates/ruci-tls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ impl std::fmt::Debug for Server {
}
}

// impl<IO> ruci::Name for tokio_rustls::server::TlsStream<IO> {
// fn name(&self) -> &str {
// "tokio_rustls_server_stream"
// }
// }

impl Server {
pub fn new(c: ServerPEMOptions) -> Self {
let config = load::load_ser_config_from_pem(&c, None).expect("tls server config valid");
Expand Down
12 changes: 6 additions & 6 deletions rucimp/src/map/quic/client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::fmt::{Display, Formatter};
use std::net::SocketAddr;
use std::sync::Arc;

use async_trait::async_trait;
use bytes::BytesMut;
use ruci::map::*;
use ruci::net::CID;
// use ruci::Name;
use ruci::{map, net::Stream};

use macro_map::*;
Expand All @@ -25,11 +25,11 @@ pub struct Client {
server_name: String,
}

// impl Name for Client {
// fn name(&self) -> &'static str {
// "quic_client"
// }
// }
impl Display for Client {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "quic_client")
}
}

impl Client {
pub fn new(c: crate::map::quic_common::ClientConfig) -> anyhow::Result<Self> {
Expand Down
12 changes: 6 additions & 6 deletions rucimp/src/map/quic/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::{Display, Formatter};
use std::path::Path;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
Expand All @@ -6,7 +7,6 @@ use anyhow::Context;
use async_trait::async_trait;
use ruci::map::*;
use ruci::net::CID;
// use ruci::Name;
use ruci::{map, net::Stream};

use macro_map::*;
Expand All @@ -26,11 +26,11 @@ pub struct Server {
a_next_cid: Arc<AtomicU32>,
}

// impl Name for Server {
// fn name(&self) -> &'static str {
// "quic_server"
// }
// }
impl Display for Server {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "quic_server")
}
}

impl Server {
pub fn new(c: ServerConfig) -> Self {
Expand Down
1 change: 0 additions & 1 deletion rucimp/src/map/quinn/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use async_trait::async_trait;
use bytes::BytesMut;
use ruci::map::*;
use ruci::net::{helpers, CID};
// use ruci::Name;
use ruci::{map, net::Stream};

use macro_map::*;
Expand Down
1 change: 0 additions & 1 deletion rucimp/src/map/quinn/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::sync::Arc;
use async_trait::async_trait;
use ruci::map::*;
use ruci::net::{helpers, CID};
// use ruci::Name;
use ruci::{map, net::Stream};

use macro_map::*;
Expand Down
7 changes: 0 additions & 7 deletions rucimp/src/map/recorder/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{io, pin::Pin, task::Poll};

// use ruci::Name;
use tokio::io::{AsyncRead, AsyncWrite};

use tracing::info;
Expand All @@ -13,12 +12,6 @@ pub(super) struct RecorderConn {
pub(super) record: Recorder,
}

// impl Name for RecorderConn {
// fn name(&self) -> &str {
// "recorder"
// }
// }

impl AsyncRead for RecorderConn {
fn poll_read(
mut self: Pin<&mut Self>,
Expand Down
7 changes: 0 additions & 7 deletions rucimp/src/map/steganography/ai_generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use base64::{engine::general_purpose::STANDARD as BASE64, Engine as _};
use rainbow::NetworkSteganographyProcessor;
use reqwest;

// use ruci::Name;
use serde::{Deserialize, Serialize};
use serde_json::json;

Expand Down Expand Up @@ -114,12 +113,6 @@ impl AIGeneratedProcessor {
}
}

// impl Name for AIGeneratedProcessor {
// fn name(&self) -> &str {
// "AIGeneratedProcessor"
// }
// }

#[async_trait]
impl NetworkSteganographyProcessor for AIGeneratedProcessor {
/// 调用OpenAI API处理数据
Expand Down
8 changes: 4 additions & 4 deletions rucimp/src/map/steganography/general/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use bytes::BytesMut;
use rainbow::NetworkSteganographyProcessor;
use ruci::{map::*, net::CID, Name};
use ruci::{map::*, net::CID};

pub mod conn;

Expand Down Expand Up @@ -65,9 +65,9 @@ impl GeneralMap {
}
}

impl Name for GeneralMap {
fn name(&self) -> &str {
self.cached_name.as_str()
impl Display for GeneralMap {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.cached_name)
}
}

Expand Down
11 changes: 6 additions & 5 deletions rucimp/src/map/tcp_ip_stack_lwip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mod udp;

use std::{
fmt::Display,
net::SocketAddr,
sync::{
atomic::{AtomicBool, AtomicU32},
Expand Down Expand Up @@ -37,11 +38,11 @@ use udp::loop_accept_udp;
#[derive(Debug, Clone, Default, MapExt)]
pub struct Stack {}

// impl Name for Stack {
// fn name(&self) -> &'static str {
// "lwip_stack"
// }
// }
impl Display for Stack {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "lwip_stack")
}
}

#[async_trait]
impl Map for Stack {
Expand Down
21 changes: 11 additions & 10 deletions rucimp/src/map/tcp_ip_stack_lwip/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
代码修改自 tproxy 包中的对应 udp 代码
*/

use std::fmt::{Display, Formatter};
use std::{
cmp::min,
io,
Expand Down Expand Up @@ -268,11 +269,11 @@ pub struct Writer {
dst: std::net::SocketAddr,
conn_map: ConnMap,
}
// impl Name for Writer {
// fn name(&self) -> &str {
// "tproxy_udp_w"
// }
// }
impl Display for Writer {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "tproxy_udp_w")
}
}

impl AsyncWriteAddr for Writer {
fn poll_write_addr(
Expand Down Expand Up @@ -307,11 +308,11 @@ pub struct Reader {
last_buf: Option<Vec<u8>>,
state: ReadState,
}
// impl ruci::Name for Reader {
// fn name(&self) -> &str {
// "tproxy_udp_r"
// }
// }
impl Display for Reader {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "tproxy_udp_r")
}
}

enum ReadState {
Buf,
Expand Down
1 change: 0 additions & 1 deletion rucimp/src/map/tcp_ip_stack_smoltcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::time::Duration;
use async_trait::async_trait;
use ruci::map::{self, *};
use ruci::net::*;
// use ruci::Name;

use macro_map::*;
use smoltcp::iface::PollIngressSingleResult;
Expand Down
21 changes: 11 additions & 10 deletions rucimp/src/map/tcp_ip_stack_smoltcp/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Defines a [`new`] function to create an AddrConn that consists of channel based

use std::{
cmp::min,
fmt::{Display, Formatter},
io,
net::{SocketAddr, SocketAddrV4, SocketAddrV6},
pin::Pin,
Expand Down Expand Up @@ -32,17 +33,17 @@ pub struct R {
rx: Receiver<(IpEndpoint, BytesMut)>,
}

// impl ruci::Name for R {
// fn name(&self) -> &str {
// "smoltcp_udp(r)"
// }
// }
impl Display for R {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "smoltcp_udp(r)")
}
}

// impl ruci::Name for W {
// fn name(&self) -> &str {
// "smoltcp_udp(w)"
// }
// }
impl Display for W {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "smoltcp_udp(w)")
}
}

/// used by [`super::SmoltcpDevice`]
pub fn new(
Expand Down
21 changes: 11 additions & 10 deletions rucimp/src/map/tproxy/udp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
cmp::min,
fmt::{Display, Formatter},
io,
os::fd::AsRawFd,
pin::Pin,
Expand Down Expand Up @@ -340,11 +341,11 @@ pub struct Writer {
dst: Addr,
conn_map: ConnMap,
}
// impl Name for Writer {
// fn name(&self) -> &str {
// "tproxy_udp_w"
// }
// }
impl Display for Writer {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "tproxy_udp_w")
}
}

impl AsyncWriteAddr for Writer {
fn poll_write_addr(
Expand Down Expand Up @@ -378,11 +379,11 @@ pub struct Reader {
last_buf: Option<DataIndex>,
state: ReadState,
}
// impl ruci::Name for Reader {
// fn name(&self) -> &str {
// "tproxy_udp_w"
// }
// }
impl Display for Reader {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "tproxy_udp_r")
}
}

enum ReadState {
Buf,
Expand Down
6 changes: 0 additions & 6 deletions rucimp/src/map/ws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ struct EarlyConn {
left_first_w_data: Option<BytesMut>,
}

// impl ruci::Name for EarlyConn {
// fn name(&self) -> &str {
// "websocket_ed_conn"
// }
// }

impl AsyncRead for EarlyConn {
fn poll_read(
mut self: Pin<&mut Self>,
Expand Down
6 changes: 0 additions & 6 deletions rucimp/src/map/ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ pub struct WsStreamToConnWrapper<T: AsyncConn> {
w_buf: Option<BytesMut>,
}

// impl<T: AsyncConn> ruci::Name for WsStreamToConnWrapper<T> {
// fn name(&self) -> &str {
// "websocket_conn"
// }
// }

impl<T: AsyncConn> AsyncRead for WsStreamToConnWrapper<T> {
fn poll_read(
mut self: Pin<&mut Self>,
Expand Down
18 changes: 0 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,3 @@ pub mod user;
pub mod utils;

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

// many types in ruci have a name.
// /// use lower case letters + underline
// pub trait Name {
// fn name(&self) -> &str;
// }

// impl<T: Name + ?Sized> Name for Box<T> {
// fn name(&self) -> &str {
// (**self).name()
// }
// }

// impl<T: Name + ?Sized> Name for &mut T {
// fn name(&self) -> &str {
// (**self).name()
// }
// }
Loading

0 comments on commit b216c3b

Please sign in to comment.