HttpPortFilter

Struct HttpPortFilter 

Source
pub struct HttpPortFilter {
    pub source_ports: Vec<u16>,
    pub destination_ports: Vec<u16>,
    pub source_ranges: Vec<(u16, u16)>,
    pub destination_ranges: Vec<(u16, u16)>,
    pub match_any: bool,
}
Expand description

Port filter configuration

Filters packets based on TCP source and/or destination ports. Supports individual ports, ranges, and lists.

§Examples

use huginn_net_http::PortFilter;

// Single port
let filter = PortFilter::new().destination(443);

// Multiple ports
let filter = PortFilter::new().destination_list(vec![80, 443, 8080]);

// Port range
let filter = PortFilter::new().destination_range(8000..9000);

Fields§

§source_ports: Vec<u16>

Source ports to match

§destination_ports: Vec<u16>

Destination ports to match

§source_ranges: Vec<(u16, u16)>

Source port ranges (inclusive)

§destination_ranges: Vec<(u16, u16)>

Destination port ranges (inclusive)

§match_any: bool

Match ANY port (source OR destination)?

Implementations§

Source§

impl PortFilter

Source

pub fn new() -> PortFilter

Create a new empty port filter

Source

pub fn destination(self, port: u16) -> PortFilter

Add a destination port

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().destination(443);
Source

pub fn source(self, port: u16) -> PortFilter

Add a source port

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().source(12345);
Source

pub fn destination_range(self, range: Range<u16>) -> PortFilter

Add a destination port range (inclusive)

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().destination_range(8000..9000);
// Matches ports 8000 through 8999
Source

pub fn source_range(self, range: Range<u16>) -> PortFilter

Add a source port range (inclusive)

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().source_range(10000..20000);
// Matches ports 10000 through 19999
Source

pub fn destination_list(self, ports: Vec<u16>) -> PortFilter

Add multiple destination ports

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().destination_list(vec![80, 443, 8080, 8443]);
Source

pub fn source_list(self, ports: Vec<u16>) -> PortFilter

Add multiple source ports

§Examples
use huginn_net_http::PortFilter;

let filter = PortFilter::new().source_list(vec![12345, 54321, 9999]);
Source

pub fn any_port(self) -> PortFilter

Match if ANY port matches (source OR destination)

By default, all specified filters must match. With match_any(), the packet passes if either source OR destination matches.

Source

pub fn matches(&self, src_port: u16, dst_port: u16) -> bool

Check if packet matches port filter

§Returns

true if the packet matches the filter criteria

Trait Implementations§

Source§

impl Clone for PortFilter

Source§

fn clone(&self) -> PortFilter

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PortFilter

Source§

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

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

impl Default for PortFilter

Source§

fn default() -> PortFilter

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

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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