Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude multicast and broadcast on WinDivert's filter #146

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mitmproxy-windows/redirector/src/main2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ async fn main() -> Result<()> {
// only needed for forward mode
// let _icmp_handle = WinDivert::new("icmp", WinDivertLayer::Network, 1042, WinDivertFlags::new().set_drop()).context("Error opening WinDivert handle")?;

// WinDivert's syntax supports IP ranges (https://github.com/basil00/Divert/issues/250#issuecomment-723515347)
let wd_filter = "((remoteAddr < 224.0.0.0 || remoteAddr > 239.255.255.255) && remoteAddr != 255.255.255.255 && !loopback) && (tcp || udp)";
let socket_handle = WinDivert::socket(
"tcp || udp",
wd_filter,
1041,
WinDivertFlags::new().set_recv_only().set_sniff(),
)?;
let network_handle = WinDivert::network("tcp || udp", 1040, WinDivertFlags::new())?;
let network_handle = WinDivert::network(wd_filter, 1040, WinDivertFlags::new())?;
let inject_handle = WinDivert::network("false", 1039, WinDivertFlags::new().set_send_only())?;

let tx_clone = event_tx.clone();
Expand Down