Skip to main content

Crate rutcpduplex

Crate rutcpduplex 

Source
Expand description

Native Rust port of tcpduplex: encrypted full-duplex messaging over TCP (X25519 ECDH, AES-256-GCM).

Protocol-compatible with the Go library so Go ↔ Rust sessions interoperate.

§Quick start

use rutcpduplex::{dial, serve_conn};
use std::net::TcpListener;
use std::thread;

let ln = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = ln.local_addr().unwrap();
thread::spawn(move || {
    let (stream, _) = ln.accept().unwrap();
    let srv = serve_conn(stream).unwrap();
    let msg = srv.receive().unwrap();
    srv.send(&msg).unwrap();
    let _ = srv.close();
});

let cli = dial(&addr.to_string()).unwrap();
cli.send(b"hello").unwrap();
let out = cli.receive().unwrap();
assert_eq!(out, b"hello");
let _ = cli.close();

Modules§

crypto
Cryptographic handshake and AES-GCM session compatible with Go tcpduplex/crypto.
protocol
Wire framing and versioning compatible with Go tcpduplex/protocol.
transfer
Encrypted resumable file transfer over a tcpduplex session.

Structs§

Config
Tunes transport timing, queue depths, protocol revision, and handshake authentication.
Conn
Encrypted full-duplex tcpduplex session after handshake.
HandshakeAuth
Optional authenticated ECDH (PSK mixing + optional peer fingerprint).
Server
Wraps a TcpListener with shared tcpduplex defaults for accepted peers.

Enums§

Error
Connection / dial sentinel errors.

Constants§

VERSION
Library version string.

Functions§

dial
Dial TCP and negotiate a tcpduplex session with default config.
dial_with_config
Dial with an optional Config.
peer_public_key_fingerprint
Returns SHA256(raw X25519 public key bytes) for use with HandshakeAuth::expected_peer_pub_key_sha256.
serve_conn
Complete the listener-side handshake on an accepted TCP stream.
serve_conn_with_config
Listener handshake with optional Config.

Type Aliases§

OnMessageFn
Callback type for asynchronous inbound message delivery.
Result
Result alias for library operations.