Skip to content

Commit

Permalink
fix(raw): skip udp to self
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Feb 7, 2022
1 parent 4f6c546 commit 56096f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions protocol/raw/src/forward/source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
io,
net::{SocketAddr, SocketAddrV4},
net::{IpAddr, SocketAddr, SocketAddrV4},
pin::Pin,
task,
};
Expand Down Expand Up @@ -55,14 +55,15 @@ impl Stream for Source {
match parse_udp(&recv_buf[..size]) {
Ok(v) => {
let broadcast = match ip_cidr {
IpCidr::Ipv4(v4) => {
v4.broadcast().map(Into::into).map(std::net::IpAddr::V4)
}
IpCidr::Ipv4(v4) => v4.broadcast().map(Into::into).map(IpAddr::V4),
_ => None,
};

let to = v.1;
if broadcast == Some(to.ip()) || to.ip().is_multicast() {
if broadcast == Some(to.ip())
|| to.ip().is_multicast()
|| to.ip() == IpAddr::from(ip_cidr.address())
{
continue;
}

Expand Down

0 comments on commit 56096f0

Please sign in to comment.