Skip to main content

microsandbox_network/
lib.rs

1//! Network configuration models and the optional host networking engine.
2//!
3//! The model tree is always available for SDK-side configuration. The
4//! `engine` feature adds packet processing, relays, DNS forwarding, policy
5//! enforcement, TLS interception, and port publishing for the `msb` runtime.
6
7// New lints introduced in rustc 1.95 fire on existing code; addressing
8// them is out of scope for the current change and tracked separately.
9#![allow(
10    clippy::useless_conversion,
11    clippy::identity_op,
12    clippy::unnecessary_cast,
13    clippy::needless_update,
14    clippy::manual_c_str_literals
15)]
16
17#[cfg(feature = "engine")]
18mod engine;
19mod model;
20pub mod proxy;
21
22#[cfg(feature = "engine")]
23pub(crate) use engine::addr;
24#[cfg(feature = "engine")]
25pub use engine::{icmp, netstack, network, ports, tcp, udp};
26pub use model::{config, dns, policy, secrets, tls};
27
28//--------------------------------------------------------------------------------------------------
29// Constants
30//--------------------------------------------------------------------------------------------------
31
32/// Static hostname the guest uses to reach the sandbox host.
33///
34/// The host-side DNS interceptor matches guest queries against this
35/// name, and agentd writes the same name into `/etc/hosts`.
36#[cfg(feature = "engine")]
37pub(crate) const HOST_ALIAS: &str = "host.microsandbox.internal";
38
39//--------------------------------------------------------------------------------------------------
40// Re-Exports
41//--------------------------------------------------------------------------------------------------
42
43#[doc(hidden)]
44pub use config::ResolvedNetworkConfig;
45pub use proxy::{
46    OutboundProxy, OutboundProxyBuildError, OutboundProxyBuilder, OutboundProxyConfig,
47    OutboundProxyParseError, OutboundProxyProtocol, Socks4ProxyBuilder, Socks5Credentials,
48    Socks5ProxyBuilder,
49};
50
51pub use config::builder;
52#[cfg(feature = "engine")]
53pub use icmp::{error as icmp_error, relay as icmp_relay};
54#[cfg(feature = "engine")]
55pub use netstack::{backend, device, poll as stack, shared};
56#[cfg(feature = "engine")]
57pub use ports::publisher;
58#[cfg(feature = "engine")]
59pub use tcp::connection as conn;
60#[cfg(feature = "engine")]
61pub use udp::{fragments as udp_fragments, relay as udp_relay};