Skip to content

Commit 1ee85a8

Browse files
committed
fix: misusing tproxy as redirect type
1 parent 5ac6584 commit 1ee85a8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

clash-lib/src/proxy/redir/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
},
77
session::{Network, Session, Type},
88
};
9+
use crate::common::errors::new_io_error;
910

1011
use async_trait::async_trait;
1112
use std::{io, net::SocketAddr, os::fd::AsRawFd, sync::Arc};
@@ -72,7 +73,7 @@ impl InboundHandlerTrait for RedirInbound {
7273

7374
let sess = Session {
7475
network: Network::Tcp,
75-
typ: Type::Tproxy,
76+
typ: Type::Redir,
7677
source: src_addr,
7778
destination: orig_dst.into(),
7879
so_mark: self.fw_mark,
@@ -89,7 +90,7 @@ impl InboundHandlerTrait for RedirInbound {
8990
}
9091

9192
async fn listen_udp(&self) -> std::io::Result<()> {
92-
panic!("redir doesn't support udp")
93+
Err(new_io_error("unsupported UDP protocol for Redir inbound"))
9394
}
9495
}
9596

clash-lib/src/session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ pub enum Type {
401401
Tun,
402402
#[cfg(all(target_os = "linux", feature = "tproxy"))]
403403
Tproxy,
404+
#[cfg(all(target_os = "linux", feature = "redir"))]
405+
Redir,
404406
Tunnel,
405407
Shadowsocks,
406408
Ignore,

0 commit comments

Comments
 (0)