Skip to content

Commit

Permalink
cargo fmt, clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thea Rossman authored and thearossman committed Oct 18, 2024
1 parent 39e6c6e commit 373bd5d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ members = [
"datatypes",
"examples/websites",
"examples/port_count",
"examples/filter_stats",
# Exclude from compilation; many subscriptions takes a long time to compile
# "examples/filter_stats",
"examples/protocols",
]
resolver = "2"
Expand Down
36 changes: 18 additions & 18 deletions core/src/filter/actions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bitmask_enum::bitmask;
/// For each connectionn, the Retina framework applies multiple filtering stages as
/// packets are received in order to determine (1) whether packets from that connection
/// should continue to be processed and (2) what to do with these packets.
Expand All @@ -11,7 +12,7 @@
/// Each filter stage returns a set of actions and a set of terminal actions.
/// The terminal actions are the subset of actions that are maintained through
/// the next filter stage.
use bitmask_enum::bitmask;
use std::fmt;

#[bitmask]
#[bitmask_config(vec_debug)]
Expand Down Expand Up @@ -280,7 +281,6 @@ use proc_macro2::{Ident, Span};
use quote::{quote, ToTokens};
use std::str::FromStr;

#[allow(clippy::to_string_trait_impl)]
impl FromStr for ActionData {
type Err = core::fmt::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand All @@ -301,23 +301,23 @@ impl FromStr for ActionData {
}
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for ActionData {
fn to_string(&self) -> String {
match *self {
ActionData::PacketContinue => "PacketContinue".into(),
ActionData::PacketDeliver => "PacketDeliver".into(),
ActionData::ProtoProbe => "ProtoProbe".into(),
ActionData::ProtoFilter => "ProtoFilter".into(),
ActionData::SessionFilter => "SessionFilter".into(),
ActionData::SessionDeliver => "SessionDeliver".into(),
ActionData::SessionTrack => "SessionTrack".into(),
ActionData::UpdatePDU => "UpdatePDU".into(),
ActionData::ReassembledUpdatePDU => "ReassembledUpdatePDU".into(),
ActionData::PacketTrack => "PacketTrack".into(),
ActionData::ConnDeliver => "ConnDeliver".into(),
impl fmt::Display for ActionData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match *self {
ActionData::PacketContinue => "PacketContinue",
ActionData::PacketDeliver => "PacketDeliver",
ActionData::ProtoProbe => "ProtoProbe",
ActionData::ProtoFilter => "ProtoFilter",
ActionData::SessionFilter => "SessionFilter",
ActionData::SessionDeliver => "SessionDeliver",
ActionData::SessionTrack => "SessionTrack",
ActionData::UpdatePDU => "UpdatePDU",
ActionData::ReassembledUpdatePDU => "ReassembledUpdatePDU",
ActionData::PacketTrack => "PacketTrack",
ActionData::ConnDeliver => "ConnDeliver",
_ => panic!("Unknown ActionData"),
}
};
write!(f, "{}", s)
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
//!
//! ```rust
//! use retina_core::config::default_config;
//! use retina_core::subscription::TlsHandshake;
//! use retina_core::Runtime;
//! use retina_filtergen::filter;
//! use retina_filtergen::{retina_main, filter};
//! use retina_datatypes::*;
//!
//! // Specify a subscription: filter, datatype(s), and callback. The filter determines what
//! // subset of traffic is delivered to the callback. The datatype(s) determine what data is
Expand All @@ -46,7 +46,7 @@
//! // A Retina application consists of one or more subscriptions.
//! // Define other subscriptions in the same file.
//! #[filter("dns")]
//! fn log_tls(dns: &DnsTransaction) {
//! fn log_dns(dns: &DnsTransaction) {
//! println!("{:?}", dns);
//! }
//!
Expand All @@ -58,7 +58,7 @@
//! let cfg = default_config();
//! // SubscribedWrapper is the type generated at compile-time to "wrap" all
//! // data tracking and delivering functionality, while `filter` wraps all filtering.
//! let mut runtime<SubscribedWrapper> = Runtime::new(cfg, filter, callback).unwrap();
//! let runtime::<SubscribedWrapper> = Runtime::new(cfg, filter).unwrap();
//! // Starts Retina
//! runtime.run();
//! }
Expand Down
3 changes: 3 additions & 0 deletions core/src/subscription/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use crate::lcore::CoreId;
use crate::memory::mbuf::Mbuf;
use crate::protocols::stream::{ConnData, ParserRegistry, Session};

#[cfg(feature = "timing")]
use crate::timing::timer::Timers;

pub trait Subscribable {
type Tracked: Trackable<Subscribed = Self>;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/timing/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Timers {
Timers(timers)
}

#[allow(dead_code)]
pub(crate) fn record(&self, which: &str, value: u64, sample: u64) {
if let Some(timer) = self.0.get(which) {
timer
Expand Down
7 changes: 3 additions & 4 deletions examples/protocols/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use retina_filtergen::{filter, retina_main};
use retina_core::{CoreId, Runtime, FiveTuple};
use retina_core::config::load_config;
use retina_core::{CoreId, FiveTuple, Runtime};
use retina_datatypes::*;
use retina_filtergen::{filter, retina_main};

use std::fs::File;
use std::io::{BufRead, BufReader, BufWriter, Write};
Expand Down Expand Up @@ -163,7 +163,6 @@ fn combine_results(outfile: &PathBuf) {
file.write_all(results.as_bytes()).unwrap();
}


#[retina_main(4)]
fn main() {
init();
Expand All @@ -186,4 +185,4 @@ fn main() {
let mut runtime: Runtime<SubscribedWrapper> = Runtime::new(config, filter).unwrap();
runtime.run();
combine_results(&args.outfile);
}
}

0 comments on commit 373bd5d

Please sign in to comment.