Skip to content

Commit d5e6dca

Browse files
committed
fix clippy lints
1 parent 4efe70c commit d5e6dca

5 files changed

Lines changed: 18 additions & 21 deletions

File tree

src/fields/fields.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ impl Fields {
2626
let net_header = headers.net;
2727
let transport_header = headers.transport;
2828
Fields {
29-
source: get_source(&net_header),
30-
dest: get_dest(&net_header),
31-
sport: get_sport(&transport_header),
32-
dport: get_dport(&transport_header),
33-
proto: get_proto(&net_header),
34-
icmp_type: get_icmp_type(&transport_header),
29+
source: get_source(net_header.as_ref()),
30+
dest: get_dest(net_header.as_ref()),
31+
sport: get_sport(transport_header.as_ref()),
32+
dport: get_dport(transport_header.as_ref()),
33+
proto: get_proto(net_header.as_ref()),
34+
icmp_type: get_icmp_type(transport_header.as_ref()),
3535
size: packet.len(),
3636
}
3737
} else {

src/fields/net_header.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::net::IpAddr;
22

33
use etherparse::NetHeaders;
44

5-
pub(crate) fn get_source(net_header: &Option<NetHeaders>) -> Option<IpAddr> {
5+
pub(crate) fn get_source(net_header: Option<&NetHeaders>) -> Option<IpAddr> {
66
if let Some(ip) = net_header {
77
match ip {
88
NetHeaders::Ipv4(h, _) => Some(IpAddr::from(h.source)),
@@ -14,7 +14,7 @@ pub(crate) fn get_source(net_header: &Option<NetHeaders>) -> Option<IpAddr> {
1414
}
1515
}
1616

17-
pub(crate) fn get_dest(net_header: &Option<NetHeaders>) -> Option<IpAddr> {
17+
pub(crate) fn get_dest(net_header: Option<&NetHeaders>) -> Option<IpAddr> {
1818
if let Some(ip) = net_header {
1919
match ip {
2020
NetHeaders::Ipv4(h, _) => Some(IpAddr::from(h.destination)),
@@ -26,7 +26,7 @@ pub(crate) fn get_dest(net_header: &Option<NetHeaders>) -> Option<IpAddr> {
2626
}
2727
}
2828

29-
pub(crate) fn get_proto(net_header: &Option<NetHeaders>) -> Option<u8> {
29+
pub(crate) fn get_proto(net_header: Option<&NetHeaders>) -> Option<u8> {
3030
if let Some(ip) = net_header {
3131
match ip {
3232
NetHeaders::Ipv4(h, _) => Some(h.protocol.0),

src/fields/transport_header.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use etherparse::TransportHeader;
22

3-
pub(crate) fn get_sport(transport_header: &Option<TransportHeader>) -> Option<u16> {
3+
pub(crate) fn get_sport(transport_header: Option<&TransportHeader>) -> Option<u16> {
44
if let Some(transport) = transport_header {
55
match transport {
66
TransportHeader::Tcp(h) => Some(h.source_port),
@@ -12,7 +12,7 @@ pub(crate) fn get_sport(transport_header: &Option<TransportHeader>) -> Option<u1
1212
}
1313
}
1414

15-
pub(crate) fn get_dport(transport_header: &Option<TransportHeader>) -> Option<u16> {
15+
pub(crate) fn get_dport(transport_header: Option<&TransportHeader>) -> Option<u16> {
1616
if let Some(transport) = transport_header {
1717
match transport {
1818
TransportHeader::Tcp(h) => Some(h.destination_port),
@@ -24,7 +24,7 @@ pub(crate) fn get_dport(transport_header: &Option<TransportHeader>) -> Option<u1
2424
}
2525
}
2626

27-
pub(crate) fn get_icmp_type(transport_header: &Option<TransportHeader>) -> Option<u8> {
27+
pub(crate) fn get_icmp_type(transport_header: Option<&TransportHeader>) -> Option<u8> {
2828
if let Some(transport) = transport_header {
2929
match transport {
3030
TransportHeader::Icmpv4(h) => Some(*h.to_bytes().first().unwrap()),

src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@
2828
//! [+] DIRECTION ACTION [OPTIONS]
2929
//! ```
3030
//!
31-
//! * Each rule can optionally be introduced by a `+` character; this will make the rule
32-
//! have higher priority (quick rule).
31+
//! * Each rule can optionally be introduced by a `+` character; this will make the rule have higher priority (quick rule).
3332
//!
34-
//! * `DIRECTION` can be either `IN` or `OUT` and represents the traffic directionality
35-
//! (see [`FirewallDirection`]).
33+
//! * `DIRECTION` can be either `IN` or `OUT` and represents the traffic directionality (see [`FirewallDirection`]).
3634
//!
37-
//! * `ACTION` can be either `ACCEPT`, `DENY`, or `REJECT` and represents the action
38-
//! associated with the rule (see [`FirewallAction`]).
35+
//! * `ACTION` can be either `ACCEPT`, `DENY`, or `REJECT` and represents the action associated with the rule (see [`FirewallAction`]).
3936
//!
4037
//! * For each rule, a list of **options** can be specified to match the desired traffic:
4138
//! * `--dest`: destination IP addresses; the value is expressed in the form of a comma-separated

src/logs/log_entry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ impl Display for LogEntry {
5454
self.direction,
5555
self.action,
5656
format_proto(self.proto),
57-
format_addr(&self.source),
58-
format_addr(&self.dest),
57+
format_addr(self.source.as_ref()),
58+
format_addr(self.dest.as_ref()),
5959
format_port(self.sport),
6060
format_port(self.dport),
6161
format_icmp_type(self.icmp_type),
@@ -64,7 +64,7 @@ impl Display for LogEntry {
6464
}
6565
}
6666

67-
fn format_addr(addr: &Option<LogIp>) -> String {
67+
fn format_addr(addr: Option<&LogIp>) -> String {
6868
if let Some(ip) = addr {
6969
ip.to_string()
7070
} else {

0 commit comments

Comments
 (0)