mirror of
https://github.com/joaoviictorti/shadow-rs.git
synced 2026-01-29 04:04:30 +01:00
refactor: improve code readability
This commit is contained in:
@@ -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) };
|
||||
|
||||
Reference in New Issue
Block a user