pub struct NetRule {
pub protocol: Protocol,
pub target: NetTarget,
pub ports: Vec<u16>,
pub all_ports: bool,
}Expand description
A single --net-allow / --net-deny rule. Both flags share this
representation and the same grammar; they differ only in whether
hostnames are accepted (--net-deny rejects them) and in how the
resolved rule is enforced (allowlist vs denylist).
Fields§
§protocol: ProtocolL4 protocol this rule applies to.
target: NetTargetWhat the rule targets at the IP layer.
ports: Vec<u16>Permitted/denied ports. Empty when all_ports is true and always
empty for Protocol::Icmp.
all_ports: bool“Any port” (bare target with no :port, or the * port token).
Implementations§
Source§impl NetRule
impl NetRule
Sourcepub fn parse_allow(spec: &str) -> Result<NetRule, SandboxError>
pub fn parse_allow(spec: &str) -> Result<NetRule, SandboxError>
Parse a --net-allow spec into a rule. Hostnames are accepted and
resolved to IPs at sandbox start. Grammar (shared with --net-deny):
host/<ip>/<cidr>/*– all ports (port optional;*targets any IP). TCP is the default scheme.host:<port[,port,...]>/<ip>:<port>/<cidr>:*/:port.[<ipv6|ipv6cidr>]:<port>– bracketed IPv6 with a port (a bareaddr:portstring is itself a valid IPv6 address, so the port form needs brackets).tcp://.../udp://.../icmp://...schemes (icmp: no port).
Sourcepub fn parse_deny(spec: &str) -> Result<NetDeny, SandboxError>
pub fn parse_deny(spec: &str) -> Result<NetDeny, SandboxError>
Parse a --net-deny spec into a rule. Identical grammar to
parse_allow, except hostnames are rejected
(the target must be a literal IP/CIDR or *); use --http-deny
for domain blocking.