mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
refactor: clippy fixs
This commit is contained in:
parent
bedd277027
commit
b1e42f9023
4 changed files with 13 additions and 13 deletions
|
|
@ -304,7 +304,7 @@ fn output_result_bson_base64<T: serde::Serialize>(result: T) {
|
||||||
if let bson::Bson::Document(document) = bson {
|
if let bson::Bson::Document(document) = bson {
|
||||||
let bytes = bson::to_vec(&document).unwrap();
|
let bytes = bson::to_vec(&document).unwrap();
|
||||||
|
|
||||||
println!("{}", base64::prelude::BASE64_STANDARD.encode(&bytes));
|
println!("{}", base64::prelude::BASE64_STANDARD.encode(bytes));
|
||||||
} else {
|
} else {
|
||||||
panic!("Failed to convert result to BSON Base64");
|
panic!("Failed to convert result to BSON Base64");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ pub(crate) enum Direction {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub(crate) enum Protocol {
|
pub(crate) enum Protocol {
|
||||||
/// Transmission Control Protocol.
|
/// Transmission Control Protocol.
|
||||||
TCP,
|
Tcp,
|
||||||
/// User Datagram Protocol.
|
/// User Datagram Protocol.
|
||||||
UDP,
|
Udp,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait for handling different types of IP addresses (IPv4, IPv6).
|
/// Trait for handling different types of IP addresses (IPv4, IPv6).
|
||||||
|
|
@ -41,7 +41,7 @@ pub(crate) trait IpAddress: Sized {
|
||||||
pub(crate) struct CapturePacket<'a> {
|
pub(crate) struct CapturePacket<'a> {
|
||||||
/// Direction of the packet (Send/Receive).
|
/// Direction of the packet (Send/Receive).
|
||||||
pub(crate) direction: Direction,
|
pub(crate) direction: Direction,
|
||||||
/// Protocol of the packet (TCP/UDP).
|
/// Protocol of the packet (Tcp/UDP).
|
||||||
pub(crate) protocol: Protocol,
|
pub(crate) protocol: Protocol,
|
||||||
/// Remote socket address.
|
/// Remote socket address.
|
||||||
pub(crate) remote_address: &'a SocketAddr,
|
pub(crate) remote_address: &'a SocketAddr,
|
||||||
|
|
@ -135,14 +135,14 @@ mod tests {
|
||||||
fn test_ports_by_direction() {
|
fn test_ports_by_direction() {
|
||||||
let packet_send = CapturePacket {
|
let packet_send = CapturePacket {
|
||||||
direction: Direction::Send,
|
direction: Direction::Send,
|
||||||
protocol: Protocol::TCP,
|
protocol: Protocol::Tcp,
|
||||||
local_address: &socket_addr("127.0.0.1:8080"),
|
local_address: &socket_addr("127.0.0.1:8080"),
|
||||||
remote_address: &socket_addr("192.168.1.1:80"),
|
remote_address: &socket_addr("192.168.1.1:80"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let packet_receive = CapturePacket {
|
let packet_receive = CapturePacket {
|
||||||
direction: Direction::Receive,
|
direction: Direction::Receive,
|
||||||
protocol: Protocol::TCP,
|
protocol: Protocol::Tcp,
|
||||||
local_address: &socket_addr("127.0.0.1:8080"),
|
local_address: &socket_addr("127.0.0.1:8080"),
|
||||||
remote_address: &socket_addr("192.168.1.1:80"),
|
remote_address: &socket_addr("192.168.1.1:80"),
|
||||||
};
|
};
|
||||||
|
|
@ -155,14 +155,14 @@ mod tests {
|
||||||
fn test_ip_addr() {
|
fn test_ip_addr() {
|
||||||
let packet_send = CapturePacket {
|
let packet_send = CapturePacket {
|
||||||
direction: Direction::Send,
|
direction: Direction::Send,
|
||||||
protocol: Protocol::TCP,
|
protocol: Protocol::Tcp,
|
||||||
local_address: &socket_addr("127.0.0.1:8080"),
|
local_address: &socket_addr("127.0.0.1:8080"),
|
||||||
remote_address: &socket_addr("192.168.1.1:80"),
|
remote_address: &socket_addr("192.168.1.1:80"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let packet_receive = CapturePacket {
|
let packet_receive = CapturePacket {
|
||||||
direction: Direction::Receive,
|
direction: Direction::Receive,
|
||||||
protocol: Protocol::TCP,
|
protocol: Protocol::Tcp,
|
||||||
local_address: &socket_addr("127.0.0.1:8080"),
|
local_address: &socket_addr("127.0.0.1:8080"),
|
||||||
remote_address: &socket_addr("192.168.1.1:80"),
|
remote_address: &socket_addr("192.168.1.1:80"),
|
||||||
};
|
};
|
||||||
|
|
@ -187,7 +187,7 @@ mod tests {
|
||||||
fn test_ip_by_direction_type_specific() {
|
fn test_ip_by_direction_type_specific() {
|
||||||
let packet = CapturePacket {
|
let packet = CapturePacket {
|
||||||
direction: Direction::Send,
|
direction: Direction::Send,
|
||||||
protocol: Protocol::TCP,
|
protocol: Protocol::Tcp,
|
||||||
local_address: &socket_addr("127.0.0.1:8080"),
|
local_address: &socket_addr("127.0.0.1:8080"),
|
||||||
remote_address: &socket_addr("192.168.1.1:80"),
|
remote_address: &socket_addr("192.168.1.1:80"),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ impl<W: Write> Pcap<W> {
|
||||||
let (source_port, dest_port) = info.ports_by_direction();
|
let (source_port, dest_port) = info.ports_by_direction();
|
||||||
|
|
||||||
match info.protocol {
|
match info.protocol {
|
||||||
Protocol::TCP => {
|
Protocol::Tcp => {
|
||||||
let buf_size = {
|
let buf_size = {
|
||||||
let mut tcp = MutableTcpPacket::new(&mut buf).unwrap();
|
let mut tcp = MutableTcpPacket::new(&mut buf).unwrap();
|
||||||
tcp.set_source(source_port);
|
tcp.set_source(source_port);
|
||||||
|
|
@ -123,7 +123,7 @@ impl<W: Write> Pcap<W> {
|
||||||
vec![EnhancedPacketOption::Comment("Generated TCP ACK".into())],
|
vec![EnhancedPacketOption::Comment("Generated TCP ACK".into())],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Protocol::UDP => {
|
Protocol::Udp => {
|
||||||
let buf_size = {
|
let buf_size = {
|
||||||
let mut udp = MutableUdpPacket::new(&mut buf).unwrap();
|
let mut udp = MutableUdpPacket::new(&mut buf).unwrap();
|
||||||
udp.set_source(source_port);
|
udp.set_source(source_port);
|
||||||
|
|
|
||||||
|
|
@ -210,13 +210,13 @@ pub mod capture {
|
||||||
/// Represents the TCP protocol provider.
|
/// Represents the TCP protocol provider.
|
||||||
pub(crate) struct ProtocolTCP;
|
pub(crate) struct ProtocolTCP;
|
||||||
impl ProtocolProvider for ProtocolTCP {
|
impl ProtocolProvider for ProtocolTCP {
|
||||||
fn protocol() -> Protocol { Protocol::TCP }
|
fn protocol() -> Protocol { Protocol::Tcp }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the UDP protocol provider.
|
/// Represents the UDP protocol provider.
|
||||||
pub(crate) struct ProtocolUDP;
|
pub(crate) struct ProtocolUDP;
|
||||||
impl ProtocolProvider for ProtocolUDP {
|
impl ProtocolProvider for ProtocolUDP {
|
||||||
fn protocol() -> Protocol { Protocol::UDP }
|
fn protocol() -> Protocol { Protocol::Udp }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A socket wrapper that allows capturing packets.
|
/// A socket wrapper that allows capturing packets.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue