Skip to content

Commit

Permalink
style: rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
SkuldNorniern committed Jan 8, 2024
1 parent ebe9f41 commit 83c5942
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ async fn main() {
println!("Found {} devices", interfaces.len());
for (i, interface) in interfaces.iter().enumerate() {
println!("[{}]: {}", i, interface.name);
}
}
exit(0);
}
let use_mac = args.get_flag("useMACaddress");
Expand Down
10 changes: 6 additions & 4 deletions src/net/capture.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pcap::{Capture, Active, Device,Error as PcapError,Address};
use pcap::{Active, Address, Capture, Device, Error as PcapError};
use std::time::Instant;

#[derive(Debug)]
Expand All @@ -22,14 +22,14 @@ impl From<String> for CaptureError {
}
}

pub struct CaptureDevice{
pub struct CaptureDevice {
pub name: String,
pub desc: String,
pub address: Vec<Address>,
pub capture: Capture<Active>,
}

impl CaptureDevice{
impl CaptureDevice {
pub fn new(device: Device) -> Result<CaptureDevice, CaptureError> {
let capture = initialize_capture(device.clone())?;

Expand All @@ -41,9 +41,11 @@ impl CaptureDevice{
})
}
}

pub fn list_devices() -> Result<Vec<Device>, CaptureError> {
Ok(Device::list().map_err(CaptureError::Cap)?)
Device::list().map_err(CaptureError::Cap)
}

pub fn find_device(identifier: &str) -> Result<Device, CaptureError> {
let start = Instant::now();
println!("Requested Device: {}", identifier);
Expand Down
4 changes: 2 additions & 2 deletions src/net/live_fluereflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ use tokio::time::sleep;

use crate::{
net::{
find_device,
flows::update_flow,
parser::{microseconds_to_timestamp, parse_fluereflow, parse_keys, parse_microseconds},
types::TcpFlags,
CaptureDevice,
find_device,
},
types::{Args, UDFlowKey},
utils::{cur_time_file, fluere_exporter},
Expand Down Expand Up @@ -83,7 +83,7 @@ pub async fn online_packet_capture(arg: Args) {
.load_plugins(&config)
.await
.expect("Failed to load plugins");

let interface = find_device(interface_name.as_str()).unwrap();
let cap_device = CaptureDevice::new(interface.clone()).unwrap();
let mut cap = cap_device.capture;
Expand Down
10 changes: 5 additions & 5 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod errors;
//mod fluereflow;
mod capture;
mod flows;
mod interface;
mod capture;
pub mod live_fluereflow;
mod offline_fluereflows;
pub mod online_fluereflow;
Expand All @@ -11,12 +11,12 @@ pub mod parser;
pub mod types;

//pub use flows::packet_capture;
pub use capture::find_device;
pub use capture::list_devices;
pub use capture::CaptureDevice;
pub use capture::CaptureError;
pub use interface::list_interface_names;
pub use interface::list_interfaces;
pub use offline_fluereflows::fluereflow_fileparse;
pub use packet_pcap::pcap_capture;
pub use capture::CaptureDevice;
pub use capture::CaptureError;
pub use capture::find_device;
pub use capture::list_devices;
//pub use types::FluereRecord;
2 changes: 1 addition & 1 deletion src/net/online_fluereflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use tokio::time::sleep;

use crate::{
net::{
find_device,
flows::update_flow,
parser::{parse_fluereflow, parse_keys, parse_microseconds},
types::{Key, TcpFlags},
CaptureDevice,
find_device,
},
types::{Args, UDFlowKey},
utils::{cur_time_file, fluere_exporter},
Expand Down

0 comments on commit 83c5942

Please sign in to comment.