Skip to content

Commit

Permalink
chore: apply clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
pitkley committed Dec 19, 2023
1 parent 4a78172 commit 7397e64
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bin/dfw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ fn main() {
// Signals should be set up as early as possible, to set proper signal masks to all threads
let (s_signal, r_signal) = crossbeam_channel::bounded(10);
let mut signals =
signal_hook::iterator::Signals::new(&[libc::SIGINT, libc::SIGTERM, libc::SIGHUP])
signal_hook::iterator::Signals::new([libc::SIGINT, libc::SIGTERM, libc::SIGHUP])
.expect("Failed to bind to process signals");
thread::spawn(move || {
for signal in signals.forever() {
Expand Down
4 changes: 2 additions & 2 deletions src/iptables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Iptables {
} => {
rule_map
.entry(table.to_owned())
.or_insert_with(BTreeMap::new)
.or_default()
.entry(chain.to_owned())
.or_insert_with(|| (None, Vec::new()))
.0 = Some(policy.to_owned());
Expand All @@ -151,7 +151,7 @@ impl Iptables {
} => {
rule_map
.entry(table.to_owned())
.or_insert_with(BTreeMap::new)
.or_default()
.entry(chain.to_owned())
.or_insert_with(|| (None, Vec::new()))
.1
Expand Down
2 changes: 1 addition & 1 deletion src/iptables/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,5 +1042,5 @@ fn append_built_rule(
rule_discriminant: IptablesRuleDiscriminants,
rule: &BuiltRule,
) -> IptablesRule {
append_rule(rule_discriminant, &*rule.table, &*rule.chain, &*rule.rule)
append_rule(rule_discriminant, &rule.table, &rule.chain, &rule.rule)
}
2 changes: 1 addition & 1 deletion src/nftables/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Process<Nftables> for <Nftables as FirewallBackend>::Defaults {
if let Some(custom_tables) = custom_tables {
// Retrieve current ruleset to avoid duplication of already existing rules.
let current_ruleset = Command::new("nft")
.args(&["list", "ruleset"])
.args(["list", "ruleset"])
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
.ok();
Expand Down
18 changes: 4 additions & 14 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,14 @@ fn default_expose_port_family() -> String {
///
/// Parts of the documentation have been taken from
/// <https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains>.
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString)]
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Display, EnumString)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "snake_case")]
pub enum ChainPolicy {
/// The accept verdict means that the packet will keep traversing the network stack.
#[strum(to_string = "accept", serialize = "ACCEPT")]
#[serde(alias = "ACCEPT")]
#[default]
Accept,
/// The drop verdict means that the packet is discarded if the packet reaches the end of the
/// base chain.
Expand All @@ -823,12 +824,6 @@ pub enum ChainPolicy {
Drop,
}

impl Default for ChainPolicy {
fn default() -> ChainPolicy {
ChainPolicy::Accept
}
}

impl slog::Value for ChainPolicy {
fn serialize(
&self,
Expand All @@ -846,13 +841,14 @@ impl slog::Value for ChainPolicy {
///
/// Parts of the documentation have been taken from
/// <https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains>.
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString)]
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Display, EnumString)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "snake_case")]
pub enum RuleVerdict {
/// The accept verdict means that the packet will keep traversing the network stack.
#[serde(alias = "ACCEPT")]
#[strum(to_string = "accept", serialize = "ACCEPT")]
#[default]
Accept,
/// The drop verdict means that the packet is discarded if the packet reaches the end of the
/// base chain.
Expand All @@ -866,12 +862,6 @@ pub enum RuleVerdict {
Reject,
}

impl Default for RuleVerdict {
fn default() -> RuleVerdict {
RuleVerdict::Accept
}
}

impl slog::Value for RuleVerdict {
fn serialize(
&self,
Expand Down

0 comments on commit 7397e64

Please sign in to comment.