pub struct NetworkPolicyChecker { /* private fields */ }Expand description
Checks incoming requests against network access policies.
When a request arrives, the checker:
- Finds all networks whose CIDRs contain the source IP.
- If no networks match, access is allowed (default open).
- If any matching network has a deny rule for the target, access is denied.
- If any matching network has an allow rule for the target, access is allowed.
- If the source belongs to a network but no rules match, access is denied (having a network policy implies explicit access control).
Implementations§
Source§impl NetworkPolicyChecker
impl NetworkPolicyChecker
Sourcepub fn new(policies: Arc<RwLock<Vec<NetworkPolicySpec>>>) -> Self
pub fn new(policies: Arc<RwLock<Vec<NetworkPolicySpec>>>) -> Self
Create a new checker backed by the given shared policy list.
Sourcepub async fn check_access(
&self,
source_ip: IpAddr,
service: &str,
deployment: &str,
port: u16,
) -> bool
pub async fn check_access( &self, source_ip: IpAddr, service: &str, deployment: &str, port: u16, ) -> bool
Check if source_ip is allowed to access a target service on the given port.
Returns true if access is allowed, false if denied.
The deployment parameter exists for forward compatibility with
per-deployment rules; pass "*" when the deployment is unknown.
Trait Implementations§
Source§impl Clone for NetworkPolicyChecker
impl Clone for NetworkPolicyChecker
Source§fn clone(&self) -> NetworkPolicyChecker
fn clone(&self) -> NetworkPolicyChecker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkPolicyChecker
impl !RefUnwindSafe for NetworkPolicyChecker
impl Send for NetworkPolicyChecker
impl Sync for NetworkPolicyChecker
impl Unpin for NetworkPolicyChecker
impl UnsafeUnpin for NetworkPolicyChecker
impl !UnwindSafe for NetworkPolicyChecker
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more