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.
- Handshake
Auth - Optional authenticated ECDH (PSK mixing + optional peer fingerprint).
- Server
- Wraps a
TcpListenerwith 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 withHandshakeAuth::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§
- OnMessage
Fn - Callback type for asynchronous inbound message delivery.
- Result
- Result alias for library operations.