Crate mproxy_reverse

source ·
Expand description

Multicast Network Dispatcher and Proxy

MPROXY: Reverse Proxy

Forward upstream TCP and UDP upstream to downstream listeners. Messages are routed via UDP multicast to downstream sender threads. Spawns one thread per listener.

Quick Start

In Cargo.toml

[dependencies]
mproxy-reverse = "0.1"

Example src/main.rs

use mproxy_reverse::{reverse_proxy_tcp_udp, reverse_proxy_udp, reverse_proxy_udp_tcp};

let udp_listen_addr: Option<String> = Some("0.0.0.0:9920".into());
let tcp_listen_addr: Option<String> = None;
let multicast_addr: String = "[ff02::1]:9918".into();
let tcp_output_addr: Option<String> = Some("[::1]:9921".into());
let udp_output_addr: Option<String> = None;

let mut threads = vec![];

// TCP connection listener -> UDP multicast channel
if let Some(tcpin) = tcp_listen_addr {
    let tcp_rproxy = reverse_proxy_tcp_udp(tcpin, multicast_addr.clone());
    threads.push(tcp_rproxy);
}

// UDP multicast listener -> TCP sender
if let Some(tcpout) = &tcp_output_addr {
    let tcp_proxy = reverse_proxy_udp_tcp(multicast_addr.clone(), tcpout.to_string());
    threads.push(tcp_proxy);
}

// UDP multicast listener -> UDP sender
if let Some(udpout) = udp_output_addr {
    let udp_proxy = reverse_proxy_udp(multicast_addr, udpout);
    threads.push(udp_proxy);
}

for thread in threads {
    thread.join().unwrap();
}

Command Line Interface

Install with Cargo

cargo install mproxy-reverse
MPROXY: Reverse Proxy

Forward upstream TCP and UDP upstream to downstream listeners.
Messages are routed via UDP multicast to downstream sender threads.
Spawns one thread per listener.

USAGE:
  mproxy-reverse  [FLAGS] [OPTIONS]

OPTIONS:
  --udp-listen-addr [HOSTNAME:PORT]     Spawn a UDP socket listener, and forward to --multicast-addr
  --tcp_listen_addr [HOSTNAME:PORT]     Reverse-proxy accepting TCP connections and forwarding to --multicast-addr
  --multicast-addr  [MULTICAST_IP:PORT] Defaults to '[ff02::1]:9918'
  --tcp-output-addr [HOSTNAME:PORT]     Forward packets from --multicast-addr to TCP downstream
  --udp_output_addr [HOSTNAME:PORT]     Forward packets from --multicast-addr to UDP downstream

FLAGS:
  -h, --help    Prints help information
  -t, --tee     Print UDP input to stdout

EXAMPLE:
  mproxy-reverse --udp-listen-addr '0.0.0.0:9920' --tcp-output-addr '[::1]:9921' --multicast-addr '224.0.0.1:9922'

See Also

Functions

  • Listen for incoming TCP connections and forward received bytes to a UDP socket address
  • Forward bytes from UDP upstream socket address to UDP downstream socket address
  • Forward a UDP socket stream (e.g. from a multicast channel) to connected TCP clients. Spawns a listener thread, plus one thread for each incoming TCP connection.