Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
xmh0511 committed Aug 30, 2024
1 parent 0bf7648 commit 721a632
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion examples/ping-tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{fmt, io};
use packet::{builder::Builder, icmp, ip, Packet};
use packet::{ether, PacketMut};
use tokio::sync::mpsc::Receiver;
use tun2::Layer;

#[allow(unused_imports)]
use tun2::{self, AbstractDevice, BoxError, Configuration};

Expand Down
18 changes: 0 additions & 18 deletions examples/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,13 @@ fn main_entry(_quit: Receiver<()>) -> Result<(), BoxError> {
target_os = "freebsd",
))]
fn main_entry(quit: Receiver<()>) -> Result<(), BoxError> {
use tun2::AbstractDevice;

let mut config = tun2::Configuration::default();

config
.address_with_prefix((10, 0, 0, 9), 24)
// .destination((10, 0, 0, 1))
.name("tap3")
.up();

#[cfg(any(target_os = "freebsd", target_os = "linux"))]
{
use tun2::Layer;
config.layer(Layer::L2);
}
#[cfg(target_os = "macos")]
config.platform_config(|config| {
config.packet_information(false);
Expand All @@ -73,16 +65,6 @@ fn main_entry(quit: Receiver<()>) -> Result<(), BoxError> {
dev2.shutdown().unwrap();
});

let device_name = dev.name().unwrap();
println!("device name = {}", device_name);
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
{
dev.enabled(false).unwrap();
dev.set_mac_address([0x0, 0x0, 0x0, 0x0, 0x1, 0x1]).unwrap();
let r = dev.get_mac_address().unwrap();
println!("mac addr = {:x?}", r);
dev.enabled(true).unwrap();
}
std::thread::spawn(move || {
loop {
let amount = dev.recv(&mut buf);
Expand Down

0 comments on commit 721a632

Please sign in to comment.