pub struct HostEgress { /* private fields */ }Expand description
Top-level host-socket egress that dispatches guest traffic to protocol-specific handlers and manages inbound port forwarding.
Implementations§
Source§impl HostEgress
impl HostEgress
Sourcepub fn new(
gateway_ip: Ipv4Addr,
gateway_mac: [u8; 6],
guest_ip: Ipv4Addr,
reply_tx: Sender<Vec<u8>>,
cancel: CancellationToken,
mtu: usize,
) -> Self
pub fn new( gateway_ip: Ipv4Addr, gateway_mac: [u8; 6], guest_ip: Ipv4Addr, reply_tx: Sender<Vec<u8>>, cancel: CancellationToken, mtu: usize, ) -> Self
Creates a new host-socket egress.
reply_tx is used by all sub-proxies to send L2 frames back to the
datapath for writing to the guest FD. mtu is the guest link MTU;
guest-bound UDP datagrams above it are IPv4-fragmented.
Sourcepub fn reply_sender(&self) -> Sender<Vec<u8>>
pub fn reply_sender(&self) -> Sender<Vec<u8>>
Returns a clone of the reply sender for external use (e.g. async DNS forwarding).
Sourcepub fn set_proxy_awareness(
&mut self,
dns_log: DnsResolutionLog,
proxy_env: ProxyEnvironment,
)
pub fn set_proxy_awareness( &mut self, dns_log: DnsResolutionLog, proxy_env: ProxyEnvironment, )
Makes the UDP path proxy-aware, mirroring TcpBridge::set_proxy_awareness:
shares the fake-IP dns_log (so a fake-IP destination is reversed to its
domain) and the detected proxy_env (so a configured SOCKS proxy routes
non-gateway, non-bypassed UDP flows). Opt-in and off by default, so the VMM
and existing callers are unaffected. HTTP proxies can’t carry UDP, so only
a SOCKS proxy engages this.
Sourcepub fn handle_outbound(&mut self, frame: &[u8], guest_mac: [u8; 6])
pub fn handle_outbound(&mut self, frame: &[u8], guest_mac: [u8; 6])
Dispatches an outbound IPv4 frame to the appropriate protocol proxy.
Inbound reply frames (matching an active inbound connection) are intercepted first; everything else is proxied through host sockets.
Sourcepub fn handle_inbound_command(
&mut self,
cmd: InboundCommand,
guest_mac: [u8; 6],
)
pub fn handle_inbound_command( &mut self, cmd: InboundCommand, guest_mac: [u8; 6], )
Handles an inbound UDP command from the listener manager.
Sourcepub fn maintenance(&mut self)
pub fn maintenance(&mut self)
Runs periodic maintenance (flow cleanup).
Sourcepub fn expire_flow(&mut self, _addr: SocketAddr)
pub fn expire_flow(&mut self, _addr: SocketAddr)
Expire a specific flow by address (called from timer wheel).
This is the timer-wheel-driven counterpart to maintenance().
Instead of scanning all flows, it targets a specific expired flow.