filtering packet source
This commit is contained in:
parent
9806c62fe7
commit
2eeaec66d4
@ -284,7 +284,8 @@ impl Connection {
|
||||
async fn handle_uni_stream(self, recv: RecvStream, _reg: Register) {
|
||||
let res = match self.model.accept_uni_stream(recv).await {
|
||||
Err(err) => Err(Error::from(err)),
|
||||
Ok(Task::Packet(pkt)) => match pkt.accept().await {
|
||||
Ok(Task::Packet(pkt)) => match self.udp_relay_mode {
|
||||
UdpRelayMode::Quic => match pkt.accept().await {
|
||||
Ok(Some((pkt, addr, assoc_id))) => {
|
||||
let addr = match addr {
|
||||
Address::None => unreachable!(),
|
||||
@ -298,6 +299,8 @@ impl Connection {
|
||||
Ok(None) => Ok(()),
|
||||
Err(err) => Err(Error::from(err)),
|
||||
},
|
||||
UdpRelayMode::Native => Err(Error::WrongPacketSource),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@ -322,7 +325,8 @@ impl Connection {
|
||||
async fn handle_datagram(self, dg: Bytes) {
|
||||
let res = match self.model.accept_datagram(dg) {
|
||||
Err(err) => Err(Error::from(err)),
|
||||
Ok(Task::Packet(pkt)) => match pkt.accept().await {
|
||||
Ok(Task::Packet(pkt)) => match self.udp_relay_mode {
|
||||
UdpRelayMode::Native => match pkt.accept().await {
|
||||
Ok(Some((pkt, addr, assoc_id))) => {
|
||||
let addr = match addr {
|
||||
Address::None => unreachable!(),
|
||||
@ -336,6 +340,8 @@ impl Connection {
|
||||
Ok(None) => Ok(()),
|
||||
Err(err) => Err(Error::from(err)),
|
||||
},
|
||||
UdpRelayMode::Quic => Err(Error::WrongPacketSource),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub enum Error {
|
||||
Timeout,
|
||||
#[error("cannot resolve the server name")]
|
||||
DnsResolve,
|
||||
#[error("received packet from an unexpected source")]
|
||||
WrongPacketSource,
|
||||
#[error("invalid socks5 authentication")]
|
||||
InvalidSocks5Auth,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user