mod.rs

Overview

This file implements a network transport layer using the wtransport library, which provides QUIC-based communication with TLS support. It defines the WTransport struct implementing the NetTransport trait, enabling creation of listeners and client connections over QUIC with TLS encryption. The file includes the handling of incoming connection requests, TLS ALPN negotiation, and data sending/receiving through asynchronous streams.

The transport supports configuration of TLS modes (including a debug mode), congestion control via the BBR algorithm, and customization of QUIC parameters such as stream limits, timeouts, and keep-alive intervals.

Main Components and Their Functionality

WTransport Struct

NetTransport Implementation for WTransport

Provides asynchronous methods to create listeners and connect as clients.

create_listener

connect


WTransportListener Struct

WTransportIncomingRequest Struct

ALPN Negotiation:
The accept() method inspects the incoming session headers for the ALPN_HEADER_NAME ("Acki-Nacki-ALPN"). It parses the header value, selects the first ALPN protocol supported by both local and remote peers, and records the negotiated protocol in the connection.


WTransportConnection Struct

Key Methods:


Important Implementation Details


Interactions with Other Parts of the System


Visual Diagram: Class Structure Overview

classDiagram
class WTransport {
- debug_tls_mode: bool
+ with_debug_tls_mode()
+ create_listener()
+ connect()
}
class WTransportListener {
- endpoint: Endpoint<Server>
- local_addr: SocketAddr
- local_identity: String
- alpn_supported: HashSet<String>
+ accept()
}
class WTransportIncomingRequest {
- request: IncomingSession
- local_addr: SocketAddr
- local_identity: String
- alpn_supported: HashSet<String>
+ remote_addr()
+ accept()
}
class WTransportConnection {
- connection: Connection
- local_addr: SocketAddr
- local_identity: String
- alpn_negotiated: Option<String>
+ local_addr()
+ remote_addr()
+ local_identity()
+ remote_identity()
+ remote_certificate()
+ alpn_negotiated()
+ send()
+ close()
+ recv()
+ watch_close()
}
WTransport ..|> NetTransport
WTransportListener ..|> NetListener
WTransportIncomingRequest ..|> NetIncomingRequest
WTransportConnection ..|> NetConnection
WTransportListener --> WTransportIncomingRequest : accept()
WTransportIncomingRequest --> WTransportConnection : accept()
WTransport --> WTransportListener : create_listener()
WTransport --> WTransportConnection : connect()

Constants


Usage Flow Summary

  1. Server Side:

    • Instantiate WTransport.

    • Call create_listener() with bind address, ALPN protocols, and credentials.

    • Use accept() on the listener to receive incoming requests.

    • Call accept() on WTransportIncomingRequest to accept connection and perform ALPN negotiation.

    • Use WTransportConnection to send/receive data.

  2. Client Side:

    • Instantiate WTransport.

    • Call connect() with remote address, preferred ALPN protocols, and credentials.

    • Use returned WTransportConnection to communicate with server.


This file provides a performant and secure transport layer abstraction using QUIC and TLS, suitable for networked applications requiring multiplexed streams, low latency, and secure communication. It integrates with the rest of the system through defined traits for consistent usage patterns. For further details on TLS configuration and network traits, see the tls module and NetTransport interface.