muxtls 0.5.0

Multiplexed streams over TLS/TCP
Documentation

muxtls

muxtls multiplexes bidirectional streams over a single TLS/TCP connection using Tokio and rustls. Streams have independent send and receive directions, with flow control and buffer limits at both stream and connection level.

[dependencies]
muxtls = "0.5"

Create a client or server with Endpoint. Use Connection::open_bi to open a stream and Connection::accept_bi to accept one. Keep a connection handle alive while using its streams. Each direction supports either chunk operations or Tokio's AsyncRead and AsyncWrite traits. Use finish or AsyncWriteExt::shutdown to finish sending. See the API documentation.

Echo example

Run the server and client in separate terminals:

cargo run -p muxtls --example echo_server
cargo run -p muxtls --example echo_client

The examples use a self-signed localhost certificate and disable client-side certificate verification for this demonstration. For deployed services, load the server certificate and key with ServerConfig::from_pem_files. Configure clients with native roots, explicit custom roots, or the optional platform-verifier feature for platform certificate verification.

For mutual TLS, configure trusted client roots with ServerConfig::from_der_with_client_auth and supply a client identity using a ClientConfig constructor ending in _and_client_auth. Connection::peer_identity exposes the certificate chain from the handshake.

Protocol

Peers negotiate muxtls/1 through TLS ALPN. The muxtls-proto crate provides the transport-independent codec. The wire specification defines framing and stream lifecycle. See also the flow-control rules and conformance vectors.

License

Licensed under either the MIT license or the Apache License, Version 2.0, at your option.