Skip to main content

Module udp_proxy

Module udp_proxy 

Source
Expand description

Layer-4 UDP proxy.

UdpProxy receives UDP datagrams from clients and forwards each one to a backend server, then relays the backend’s reply to the original sender. This request-reply model covers protocols such as DNS, NTP, and RADIUS.

Each datagram is handled in its own thread, so the main bind loop is never blocked waiting for a backend reply.

§Example

use rust_web_server::udp_proxy::UdpProxy;

// Forward DNS queries round-robin across two resolvers.
UdpProxy::new(["8.8.8.8:53", "8.8.4.4:53"])
    .reply_timeout_ms(2000)
    .bind("0.0.0.0:53")
    .unwrap();

Structs§

UdpProxy
Layer-4 (raw UDP) reverse proxy with round-robin load balancing.