Skip to main content

Crate koi_udp

Crate koi_udp 

Source
Expand description

UDP datagram bridging over HTTP/SSE.

Containers cannot bind host UDP sockets directly. This crate exposes a lease-based HTTP API that lets a containerised process:

  1. Bind a host UDP port (creating a UdpBinding).
  2. Receive datagrams via an SSE stream (GET /v1/udp/recv/{id}).
  3. Send datagrams through the bound socket (POST /v1/udp/send/{id}).
  4. Heartbeat to extend the lease (POST /v1/udp/heartbeat/{id}).

Bindings expire after lease_secs without a heartbeat, at which point the reaper closes the socket. This prevents resource leaks if a container dies.

Follows the same Core/Runtime pattern as koi-health and koi-dns.

Modules§

http
HTTP routes for UDP bridging - bind, unbind, recv (SSE), send, status, heartbeat.

Structs§

ActiveBinding
An active UDP binding - owns the socket and a relay task that broadcasts received datagrams to subscribers.
BindingInfo
Metadata for a live binding (returned by status endpoint).
UdpBindRequest
Request body for creating a new binding.
UdpDatagram
A datagram received on a bound socket, ready to be relayed over SSE.
UdpRuntime
Manages UDP socket bindings, datagram relay, and lease reaping.
UdpSendRequest
Request to send a datagram through a bound socket.

Enums§

UdpError