pub struct Rule {
pub direction: Direction,
pub destination: Destination,
pub protocols: Vec<Protocol>,
pub ports: Vec<PortRange>,
pub action: Action,
}Expand description
A single network rule.
The destination field is direction-dependent: in an egress-direction
rule, destination is what the guest is reaching; in an ingress-
direction rule, destination is the source (peer) of the incoming
connection. Both-direction rules apply in either path with the
destination interpreted appropriately for each.
Fields§
§direction: DirectionDirection this rule applies to: outbound, inbound, or either.
destination: DestinationDestination filter. Direction-dependent interpretation.
protocols: Vec<Protocol>Protocol set (empty = any protocol). The rule matches if the packet’s protocol is in this set.
ports: Vec<PortRange>Port-range set (empty = any port). Always the guest-side port: destination port for egress, listening port for ingress.
action: ActionAction to take.
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn allow_egress(destination: Destination) -> Self
pub fn allow_egress(destination: Destination) -> Self
Convenience: allow rule for egress, any protocol, any port.
Sourcepub fn deny_egress(destination: Destination) -> Self
pub fn deny_egress(destination: Destination) -> Self
Convenience: deny rule for egress, any protocol, any port.
Sourcepub fn allow_ingress(destination: Destination) -> Self
pub fn allow_ingress(destination: Destination) -> Self
Convenience: allow rule for ingress, any protocol, any port.
Sourcepub fn deny_ingress(destination: Destination) -> Self
pub fn deny_ingress(destination: Destination) -> Self
Convenience: deny rule for ingress, any protocol, any port.
Sourcepub fn allow_any(destination: Destination) -> Self
pub fn allow_any(destination: Destination) -> Self
Convenience: allow rule for either direction, any protocol, any port.
Sourcepub fn deny_any(destination: Destination) -> Self
pub fn deny_any(destination: Destination) -> Self
Convenience: deny rule for either direction, any protocol, any port.
Sourcepub fn allow_dns() -> Self
pub fn allow_dns() -> Self
Allow plain DNS (UDP/53 and TCP/53) to the sandbox gateway, i.e. the in-process DNS forwarder.
Building block for deny-by-default policies: under the
DNS-as-egress evaluation rules, generic IP-based destinations
(Cidr / non-Host Group) cannot match a query because the
name has no resolved IP yet, so a policy of
default_egress = Deny with only those rules refuses every DNS
query. Group::Host is the one IP-based destination that is
honored at DNS-decision time, since it names the gateway
forwarder the query is delivered to.
At connection-time this rule stays narrow: it only matches the gateway IPs, not arbitrary private resolvers a guest might aim at directly.
DoT (TCP/853) is not included; if you need it, add an explicit
Group::Host tcp/853 allow rule (and pair it with TLS
interception).
Sourcepub fn deny_dns() -> Self
pub fn deny_dns() -> Self
Deny plain DNS (UDP/53 and TCP/53) to the sandbox gateway.
This is the deny counterpart to Self::allow_dns and is useful as
an override placed before profile-generated rules.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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