From 079416b3eb0fc6bd7c8879f580023dfd7db108c1 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 3 Aug 2023 12:21:59 -0400 Subject: [PATCH] Apply rustfmt fixes --- libs/easy-tun/src/lib.rs | 2 +- libs/fast-nat/src/bimap.rs | 2 +- libs/fast-nat/src/nat.rs | 2 +- libs/fast-nat/src/timeout.rs | 2 +- libs/interproto/src/lib.rs | 2 +- libs/interproto/src/protocols/ip.rs | 9 +++++++-- libs/interproto/src/protocols/mod.rs | 2 +- libs/rfc6052/src/error.rs | 2 +- libs/rtnl/src/lib.rs | 4 ++-- src/common/mod.rs | 2 +- src/protomask.rs | 5 +---- 11 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libs/easy-tun/src/lib.rs b/libs/easy-tun/src/lib.rs index 87bad45..23d3614 100644 --- a/libs/easy-tun/src/lib.rs +++ b/libs/easy-tun/src/lib.rs @@ -5,4 +5,4 @@ #![allow(clippy::missing_panics_doc)] mod tun; -pub use tun::Tun; \ No newline at end of file +pub use tun::Tun; diff --git a/libs/fast-nat/src/bimap.rs b/libs/fast-nat/src/bimap.rs index 367f5c7..4f1688e 100644 --- a/libs/fast-nat/src/bimap.rs +++ b/libs/fast-nat/src/bimap.rs @@ -108,4 +108,4 @@ mod tests { assert_eq!(bimap.get_right(&3), None); assert_eq!(bimap.get_left(&"three"), None); } -} \ No newline at end of file +} diff --git a/libs/fast-nat/src/nat.rs b/libs/fast-nat/src/nat.rs index e29263a..1fc6d3b 100644 --- a/libs/fast-nat/src/nat.rs +++ b/libs/fast-nat/src/nat.rs @@ -91,4 +91,4 @@ impl Default for NetworkAddressTable { timeouts: FxHashMap::default(), } } -} \ No newline at end of file +} diff --git a/libs/fast-nat/src/timeout.rs b/libs/fast-nat/src/timeout.rs index 9691f6f..cad3989 100644 --- a/libs/fast-nat/src/timeout.rs +++ b/libs/fast-nat/src/timeout.rs @@ -10,4 +10,4 @@ pub enum MaybeTimeout { duration: Duration, start: std::time::Instant, }, -} \ No newline at end of file +} diff --git a/libs/interproto/src/lib.rs b/libs/interproto/src/lib.rs index f5e4aa0..c7894fb 100644 --- a/libs/interproto/src/lib.rs +++ b/libs/interproto/src/lib.rs @@ -5,5 +5,5 @@ #![allow(clippy::missing_panics_doc)] #![allow(clippy::doc_markdown)] +pub mod error; pub mod protocols; -pub mod error; \ No newline at end of file diff --git a/libs/interproto/src/protocols/ip.rs b/libs/interproto/src/protocols/ip.rs index b7c84e6..2ad9b16 100644 --- a/libs/interproto/src/protocols/ip.rs +++ b/libs/interproto/src/protocols/ip.rs @@ -2,7 +2,8 @@ use super::{ icmp::{translate_icmp_to_icmpv6, translate_icmpv6_to_icmp}, - tcp::{recalculate_tcp_checksum_ipv4, recalculate_tcp_checksum_ipv6}, udp::{recalculate_udp_checksum_ipv6, recalculate_udp_checksum_ipv4}, + tcp::{recalculate_tcp_checksum_ipv4, recalculate_tcp_checksum_ipv6}, + udp::{recalculate_udp_checksum_ipv4, recalculate_udp_checksum_ipv6}, }; use crate::error::{Error, Result}; use pnet::packet::{ @@ -127,7 +128,11 @@ pub fn translate_ipv6_to_ipv4( }); ipv4_packet.set_source(new_source); ipv4_packet.set_destination(new_destination); - ipv4_packet.set_total_length((Ipv4Packet::minimum_packet_size() + new_payload.len()).try_into().unwrap()); + ipv4_packet.set_total_length( + (Ipv4Packet::minimum_packet_size() + new_payload.len()) + .try_into() + .unwrap(), + ); // Copy the payload to the buffer ipv4_packet.set_payload(&new_payload); diff --git a/libs/interproto/src/protocols/mod.rs b/libs/interproto/src/protocols/mod.rs index 5dff8bd..50baf68 100644 --- a/libs/interproto/src/protocols/mod.rs +++ b/libs/interproto/src/protocols/mod.rs @@ -1,4 +1,4 @@ +pub mod icmp; pub mod ip; pub mod tcp; pub mod udp; -pub mod icmp; \ No newline at end of file diff --git a/libs/rfc6052/src/error.rs b/libs/rfc6052/src/error.rs index c616737..85fb837 100644 --- a/libs/rfc6052/src/error.rs +++ b/libs/rfc6052/src/error.rs @@ -4,4 +4,4 @@ pub enum Error { #[error("Invalid IPv6 prefix length: {0}. Must be one of 32, 40, 48, 56, 64, or 96")] InvalidPrefixLength(u8), -} \ No newline at end of file +} diff --git a/libs/rtnl/src/lib.rs b/libs/rtnl/src/lib.rs index dbd29da..6d8647c 100644 --- a/libs/rtnl/src/lib.rs +++ b/libs/rtnl/src/lib.rs @@ -5,12 +5,12 @@ #![allow(clippy::missing_panics_doc)] #![allow(clippy::missing_safety_doc)] -pub mod link; pub mod ip; +pub mod link; pub mod route; /// Get a handle on a new rtnetlink connection -#[cfg(feature="tokio")] +#[cfg(feature = "tokio")] pub fn new_handle() -> Result { let (rt_connection, rt_handle, _) = rtnetlink::new_connection().map_err(|err| { log::error!("Failed to open rtnetlink connection"); diff --git a/src/common/mod.rs b/src/common/mod.rs index 33fdbba..bdc0db4 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -1,5 +1,5 @@ //! Common code used across all protomask binaries pub mod logging; +pub mod packet_handler; pub mod rfc6052; -pub mod packet_handler; \ No newline at end of file diff --git a/src/protomask.rs b/src/protomask.rs index 9d38cbe..b8c879c 100644 --- a/src/protomask.rs +++ b/src/protomask.rs @@ -1,5 +1,2 @@ - #[tokio::main] -pub async fn main(){ - -} \ No newline at end of file +pub async fn main() {}