pub struct NetworkBuilder { /* private fields */ }Expand description
Fluent builder for NetworkConfig.
Implementations§
Source§impl NetworkBuilder
impl NetworkBuilder
Sourcepub fn from_config(config: NetworkConfig) -> Self
pub fn from_config(config: NetworkConfig) -> Self
Start building from an existing network configuration.
Sourcepub fn port(self, host_port: u16, guest_port: u16) -> Self
pub fn port(self, host_port: u16, guest_port: u16) -> Self
Publish a TCP port: host_port on the host maps to guest_port in the guest.
Sourcepub fn port_bind(
self,
host_bind: IpAddr,
host_port: u16,
guest_port: u16,
) -> Self
pub fn port_bind( self, host_bind: IpAddr, host_port: u16, guest_port: u16, ) -> Self
Publish a TCP port on a specific host bind address.
Sourcepub fn port_udp_bind(
self,
host_bind: IpAddr,
host_port: u16,
guest_port: u16,
) -> Self
pub fn port_udp_bind( self, host_bind: IpAddr, host_port: u16, guest_port: u16, ) -> Self
Publish a UDP port on a specific host bind address.
Sourcepub fn policy(self, policy: NetworkPolicy) -> Self
pub fn policy(self, policy: NetworkPolicy) -> Self
Set the network policy.
Sourcepub fn dns(self, f: impl FnOnce(DnsBuilder) -> DnsBuilder) -> Self
pub fn dns(self, f: impl FnOnce(DnsBuilder) -> DnsBuilder) -> Self
Configure DNS interception via a closure.
.dns(|d| d
.nameservers(["1.1.1.1".parse::<Nameserver>()?])
.rebind_protection(false)
)Sourcepub fn tls(self, f: impl FnOnce(TlsBuilder) -> TlsBuilder) -> Self
pub fn tls(self, f: impl FnOnce(TlsBuilder) -> TlsBuilder) -> Self
Configure TLS interception via a closure.
Sourcepub fn secret(self, f: impl FnOnce(SecretBuilder) -> SecretBuilder) -> Self
pub fn secret(self, f: impl FnOnce(SecretBuilder) -> SecretBuilder) -> Self
Add a secret via a closure builder.
.secret(|s| s
.env("OPENAI_API_KEY")
.value(api_key)
.allow_host("api.openai.com")
)Sourcepub fn secret_entry(self, entry: SecretEntry) -> Self
pub fn secret_entry(self, entry: SecretEntry) -> Self
Add a materialized secret entry.
Sourcepub fn secret_env(
self,
env_var: impl Into<String>,
value: impl Into<String>,
placeholder: impl Into<String>,
allowed_host: impl Into<String>,
) -> Self
pub fn secret_env( self, env_var: impl Into<String>, value: impl Into<String>, placeholder: impl Into<String>, allowed_host: impl Into<String>, ) -> Self
Shorthand: add a secret with env var, value, placeholder, and allowed host.
Sourcepub fn on_secret_violation(
self,
f: impl FnOnce(ViolationActionBuilder) -> ViolationActionBuilder,
) -> Self
pub fn on_secret_violation( self, f: impl FnOnce(ViolationActionBuilder) -> ViolationActionBuilder, ) -> Self
Set the violation action for secrets.
Sourcepub fn max_connections(self, max: usize) -> Self
pub fn max_connections(self, max: usize) -> Self
Set the maximum number of concurrent connections.
Sourcepub fn interface(self, overrides: InterfaceOverrides) -> Self
pub fn interface(self, overrides: InterfaceOverrides) -> Self
Set guest interface overrides.
Sourcepub fn ipv4_pool(self, pool: Ipv4Network) -> Self
pub fn ipv4_pool(self, pool: Ipv4Network) -> Self
Set the IPv4 pool used to derive per-sandbox /30 guest subnets.
The default is 172.16.0.0/12. Pools must be at least /30.
Sourcepub fn ipv6_pool(self, pool: Ipv6Network) -> Self
pub fn ipv6_pool(self, pool: Ipv6Network) -> Self
Set the IPv6 pool used to derive per-sandbox /64 guest prefixes.
The default is fd42:6d73:62::/48. Pools must be at least /64.
Sourcepub fn trust_host_cas(self, enabled: bool) -> Self
pub fn trust_host_cas(self, enabled: bool) -> Self
Whether to ship the host’s trusted root CAs into the guest at boot. Default: false. Opt in when running behind a corporate TLS-inspecting proxy (Cloudflare Warp Zero Trust, Zscaler, Netskope, …) whose gateway CA is trusted on the host but unknown to the guest’s stock Mozilla bundle.
Sourcepub fn build(self) -> Result<NetworkConfig, BuildError>
pub fn build(self) -> Result<NetworkConfig, BuildError>
Consume the builder and return the configuration.
Surfaces the first BuildError accumulated by any nested
builder (currently DnsBuilder). Errors stored on the
network builder itself flow through here too.
Trait Implementations§
Source§impl Clone for NetworkBuilder
impl Clone for NetworkBuilder
Source§fn clone(&self) -> NetworkBuilder
fn clone(&self) -> NetworkBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more