pub struct PortScanner { /* private fields */ }Expand description
Concurrent TCP port scanner.
The Arc<Semaphore> caps TCP connects across all concurrent scan_host
calls on the same scanner instance. buffer_unordered alone would only
bound a single call. SweepEngine reuses one scanner across hundreds of
hosts in parallel, so without the shared permit pool a /24 sweep could
attempt hosts × ports simultaneous connects (easily 64k sockets).
Implementations§
Source§impl PortScanner
impl PortScanner
pub fn new(concurrency: usize) -> Self
pub async fn scan_host( &self, target: IpAddr, ports: Vec<u16>, timeout_ms: u64, ) -> Result<Vec<PortResult>>
Sourcepub async fn scan_host_with_progress(
&self,
target: IpAddr,
ports: Vec<u16>,
timeout_ms: u64,
progress: Option<Arc<dyn Fn(PortScanProgress) + Send + Sync>>,
) -> Result<Vec<PortResult>>
pub async fn scan_host_with_progress( &self, target: IpAddr, ports: Vec<u16>, timeout_ms: u64, progress: Option<Arc<dyn Fn(PortScanProgress) + Send + Sync>>, ) -> Result<Vec<PortResult>>
Scan ports on target.
Validates the port list rather than trusting the caller. Ops does
the same check before calling in, but this is public API on a
published crate: a consumer building a Vec<u16> by hand reached the
scanner directly and neither the 4,096-port cap nor the port-0
rejection applied. The doc comment on Ops::resolve_ports claimed
“every scanning entry point funnels through here”, and this was one
of two that did not.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PortScanner
impl !UnwindSafe for PortScanner
impl Freeze for PortScanner
impl Send for PortScanner
impl Sync for PortScanner
impl Unpin for PortScanner
impl UnsafeUnpin for PortScanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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