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 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
.block_domain("malware.example.com")
.block_domain_suffix(".tracking.com")
.nameservers(["1.1.1.1".parse::<Nameserver>()?])
)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_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, action: ViolationAction) -> Self
pub fn on_secret_violation(self, action: ViolationAction) -> 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 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.