Disable promiscuous mode

main
shellrow 3 years ago
parent 59e16da360
commit 1790140abe
  1. 4
      Cargo.toml
  2. 12
      src/gateway.rs

@ -1,6 +1,6 @@
[package]
name = "default-net"
version = "0.3.0"
version = "0.4.0"
authors = ["shellrow <81893184+shellrow@users.noreply.github.com>"]
edition = "2018"
description = "Get default network information"
@ -14,4 +14,4 @@ license = "MIT"
pnet = "0.28"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = [ "std" ] }
winapi = { version = "0.3.9", features = [ "std" ] }

@ -85,7 +85,17 @@ fn receive_icmp_packets(icmp_type: pnet::packet::icmp::IcmpType, timeout: &Durat
};
let interfaces = pnet::datalink::interfaces();
let interface = interfaces.into_iter().filter(|interface: &pnet::datalink::NetworkInterface| interface.index == default_idx).next().expect("Failed to get Interface");
let (mut _tx, mut rx) = match pnet::datalink::channel(&interface, Default::default()) {
let config = pnet::datalink::Config {
write_buffer_size: 4096,
read_buffer_size: 4096,
read_timeout: None,
write_timeout: None,
channel_type: pnet::datalink::ChannelType::Layer2,
bpf_fd_attempts: 1000,
linux_fanout: None,
promiscuous: false,
};
let (mut _tx, mut rx) = match pnet::datalink::channel(&interface, config) {
Ok(pnet::datalink::Channel::Ethernet(tx, rx)) => (tx, rx),
Ok(_) => panic!("Unknown channel type"),
Err(e) => panic!("Error happened {}", e),

Loading…
Cancel
Save