udpexchange

Crates.ioudpexchange
lib.rsudpexchange
version0.1.1
sourcesrc
created_at2023-10-03 23:42:40.88884
updated_at2023-10-18 18:57:18.560109
descriptionSmall CLI tool for creating simple UDP hubs; small executable size experiment
homepage
repositoryhttps://github.com/vi/udpexchange
max_upload_size
id991663
size11,341
Vitaly Shukela (vi)

documentation

README

udpexchange

This program follows the following algorithm:

  1. Listen UDP socket at specified address
  2. For each incoming UDP datagram, remember source address in LRU cache
  3. Return empty datagrams back to sender (pings/keepalives)
  4. Forward non-empty datagrams to each known unexpired address (except of sender).

Optionally, it can remember some recent messages and send them to newly seen clients.

Security

This service may allow DDoS amplification, so should not be run publicly.

Small executable size

This project is partly an experiment to create small executables using Rust while having (partial?) access to libstd and using reasonable command-line arguments parser.

cargo build --release -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort --target=x86_64-unknown-linux-musl --features=mini

should produce a working 51-kilobyte executable.

Note that hacks activated by --features=mini may be unsound and less portable. Even smaller size is attainable by also using eyra.

Installation

Download a pre-built executable from Github releases or install from source code with cargo install --path . or cargo install udpexchange.

CLI options

udpexchange --help output
Usage: udpexchange <listen_addr> [-t <timeout>] [-r]

Simple UDP service which replies to all other known clients

Positional Arguments:
  listen_addr       socket address to bind UDP to

Options:
  -t, --timeout     timeout, in seconds, to expire clients.
  -r, --replay      send recent accumulated messages to newly seen clients
  --help            display usage information
Commit count: 6

cargo fmt