Skip to main content

Ops

Struct Ops 

Source
pub struct Ops { /* private fields */ }
Expand description

High-level operations used by CLI/TUI/GUI/MCP to keep behavior consistent.

Implementations§

Source§

impl Ops

Source

pub fn new(cfg: OpsConfig) -> Self

Source

pub fn config(&self) -> &OpsConfig

Source§

impl Ops

Source

pub async fn resolve_host_ip(&self, host: &str) -> Result<IpAddr>

Source

pub async fn ping_host_summary( &self, host: &str, count: u32, ) -> Result<PingSummary>

Source

pub async fn trace_route( &self, host: &str, max_hops: u32, resolve: bool, ) -> Result<TraceResult>

Source

pub async fn trace_route_with_progress( &self, host: &str, max_hops: u32, resolve: bool, progress: Option<Sender<String>>, ) -> Result<TraceResult>

Source

pub async fn reverse_lookup(&self, ip: &str) -> Result<Option<String>>

Source

pub async fn dns_lookup( &self, host: &str, record: Option<String>, ) -> Result<Vec<DnsRecord>>

Source§

impl Ops

Source

pub fn list_interfaces(&self) -> Vec<InterfaceInfo>

Source

pub async fn get_arp_table(&self) -> Result<Vec<ArpEntry>>

Read the local ARP/neighbour table.

Async, and it moves the read to a blocking thread, because on Windows and macOS this shells out to arp and waits on the child process. Every other method on Ops is async, so a sync one here invited exactly the bug it produced: three separate callers — the MCP tool dispatcher, the Tauri command, and DiscoverEngine — all invoked it straight from an async context and parked a runtime worker on waitpid for the life of the subprocess.

The MCP case was the sharp one. Its handlers are capped at 16 concurrent, and the read loop is itself a task on the same pool, so sixteen get_arp_table calls could stall every worker — including the one reading stdin. No further request would even be parsed, and a cancellation could not get through.

Source§

impl Ops

Source

pub fn pcap_check_support(&self) -> Result<Vec<String>>

Source

pub fn capture_pcap( &self, interface: String, filter: Option<String>, duration: Option<u64>, output_file: Option<String>, max_packets: Option<usize>, ) -> Result<PcapResult>

Source

pub fn parse_pcap_file( &self, input_file: String, max_packets: Option<usize>, ) -> Result<PcapParseResult>

Source

pub async fn capture_pcap_async( &self, interface: String, filter: Option<String>, duration: Option<u64>, output_file: Option<String>, max_packets: Option<usize>, ) -> Result<PcapResult>

Async-friendly PCAP capture wrapper.

PCAP capture is inherently blocking (libpcap read loop + file I/O). This runs it in a dedicated blocking thread so async runtimes (CLI/Tauri/MCP) remain responsive.

Source

pub async fn capture_pcap_async_with_cancel( &self, interface: String, filter: Option<String>, duration: Option<u64>, output_file: Option<String>, max_packets: Option<usize>, cancel: Option<PcapCancelToken>, ) -> Result<PcapResult>

Source§

impl Ops

Source

pub async fn discover_ipv4( &self, subnet: Option<String>, resolve: bool, ) -> Result<(String, Vec<Host>)>

Source

pub async fn discover_ipv4_with_progress( &self, subnet: Option<String>, resolve: bool, progress: Option<Arc<dyn Fn(DiscoverProgress) + Send + Sync>>, ) -> Result<(String, Vec<Host>)>

Source

pub async fn scan_ports( &self, host: &str, ports: Option<Vec<u16>>, ) -> Result<(IpAddr, Vec<PortResult>)>

Source

pub async fn scan_ports_with_progress( &self, host: &str, ports: Option<Vec<u16>>, progress: Option<Arc<dyn Fn(PortScanProgress) + Send + Sync>>, ) -> Result<(IpAddr, Vec<PortResult>)>

Source

pub async fn scan_udp_ports_with_progress( &self, host: &str, ports: Option<Vec<u16>>, progress: Option<Arc<dyn Fn(PortScanProgress) + Send + Sync>>, ) -> Result<(IpAddr, Vec<PortResult>)>

Probe ports on host over UDP, or crate::DEFAULT_UDP_PORTS when none are given. See scan/udp.rs for what each status means.

Source

pub async fn scan_udp_ports( &self, host: &str, ports: Option<Vec<u16>>, ) -> Result<(IpAddr, Vec<PortResult>)>

Source

pub async fn inspect_host( &self, host: String, ports: Option<Vec<u16>>, ) -> Result<InspectResult>

Source

pub async fn sweep_ipv4( &self, subnet: Option<String>, ports: Option<Vec<u16>>, resolve_hostnames: bool, ) -> Result<(String, Vec<SweepEntry>)>

Source

pub async fn sweep_ipv4_with_progress( &self, subnet: Option<String>, ports: Option<Vec<u16>>, resolve_hostnames: bool, progress: Option<Arc<dyn Fn(SweepProgress) + Send + Sync>>, ) -> Result<(String, Vec<SweepEntry>)>

Trait Implementations§

Source§

impl Clone for Ops

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ops

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ops

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Ops

§

impl RefUnwindSafe for Ops

§

impl Send for Ops

§

impl Sync for Ops

§

impl Unpin for Ops

§

impl UnsafeUnpin for Ops

§

impl UnwindSafe for Ops

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more