pub struct NetworkPolicy {
pub default_action: Action,
pub rules: Vec<Rule>,
}Expand description
Network policy with ordered rules.
Rules are evaluated in first-match-wins order. If no rule matches, the default action is applied.
Fields§
§default_action: ActionDefault action for traffic not matching any rule.
rules: Vec<Rule>Ordered list of rules (first match wins).
Implementations§
Source§impl NetworkPolicy
impl NetworkPolicy
Sourcepub fn public_only() -> Self
pub fn public_only() -> Self
Public internet only — deny loopback, private, link-local, and cloud metadata addresses.
Sourcepub fn non_local() -> Self
pub fn non_local() -> Self
Non-local network access — allow public internet and private/LAN addresses, but deny loopback, link-local, and cloud metadata addresses.
Sourcepub fn evaluate_egress(&self, dst: SocketAddr, protocol: Protocol) -> Action
pub fn evaluate_egress(&self, dst: SocketAddr, protocol: Protocol) -> Action
Evaluate an outbound connection against the policy.
Returns the action from the first matching rule, or the default action if no rule matches.
Sourcepub fn evaluate_egress_ip(&self, dst: IpAddr, protocol: Protocol) -> Action
pub fn evaluate_egress_ip(&self, dst: IpAddr, protocol: Protocol) -> Action
Evaluate an outbound ICMP packet against the policy.
Same first-match-wins logic as Self::evaluate_egress but without port
matching — ICMP has no ports. Rules with a ports filter are
skipped since applying a port range to a portless protocol would
be semantically incorrect.
Trait Implementations§
Source§impl Clone for NetworkPolicy
impl Clone for NetworkPolicy
Source§fn clone(&self) -> NetworkPolicy
fn clone(&self) -> NetworkPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more