Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
VendettaReborn committed Mar 28, 2024
1 parent e065316 commit 1955376
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion clash_lib/src/app/inbound/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ impl InboundManager {
);
}


if let Some(tproxy_port) = ports.tproxy_port {
network_listeners.insert(
ListenerType::TProxy,
Expand Down
1 change: 1 addition & 0 deletions clash_lib/src/common/cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion clash_lib/src/proxy/converters/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
config::internal::proxy::OutboundShadowsocks,
proxy::{
shadowsocks::{Handler, HandlerOptions, OBFSOption},
AnyOutboundHandler
AnyOutboundHandler,
},
Error,
};
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/tun/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod inbound;
pub use netstack_lwip as netstack;
pub use inbound::get_runner as get_tun_runner;
pub use netstack_lwip as netstack;
5 changes: 2 additions & 3 deletions clash_lib/src/proxy/utils/socket_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ pub async fn new_udp_socket_inner(
None => socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::DGRAM, None)?,
};


// see: https://docs.kernel.org/networking/tproxy.html#making-non-local-sockets-work
// **All you have to do is enable the (SOL_IP, IP_TRANSPARENT) socket option before calling bind**
// for tcp and udp, situations are slightly different:
// 1. for tcp, all you need to do is to create a listener with IP_TRANSPARENT enabled, since the packet flow
// 1. for tcp, all you need to do is to create a listener with IP_TRANSPARENT enabled, since the packet flow
// is based on the stream, the ingress and egress of the stream will be handled by system stack properly
// 2, for udp, the socket that binds the tproxy-port shall have IP_TRANSPARENT enabled,
// and the response socket should also have IP_TRANSPARENT enabled, in order to sink a packet that
// and the response socket should also have IP_TRANSPARENT enabled, in order to sink a packet that
// have any (src, sport), which is the (dst, sport) of the inbound packet
if transparent {
socket.set_ip_transparent(true)?;
Expand Down

0 comments on commit 1955376

Please sign in to comment.