Async-friendly WebTransport implementation in Rust

Overview

WTransport Logo

Documentation Crates.io RustCI

WTransport

WebTransport protocol, pure-rust, async-friendly.

Introduction

WebTransport is a new protocol being developed to enable low-latency, bidirectional communication between clients and servers over the web. It aims to address the limitations of existing protocols like HTTP and WebSocket by offering a more efficient and flexible transport layer.

Benefits of WebTransport

  • πŸš€ Low latency: WebTransport is designed to minimize latency, making it suitable for real-time applications such as gaming, video streaming, and collaborative editing.
  • πŸ”„ Bidirectional communication: WebTransport allows simultaneous data exchange between the client and server, enabling efficient back-and-forth communication without the need for multiple requests.
  • πŸ”€ Multiplexing: With WebTransport, multiple streams can be multiplexed over a single connection, reducing overhead and improving performance.
  • πŸ”’ Security: WebTransport benefits from the security features provided by the web platform, including transport encryption and same-origin policy.

Notes

Please be aware that WebTransport is still a draft and not yet standardized. The WTransport library, while functional, is not considered completely production-ready. It should be used with caution and may undergo changes as the WebTransport specification evolves.

Simple API

async fn server() -> Result<(), Error> {
    let config = ServerConfig::builder()
        .with_bind_address(SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 4433))
        .with_certificate(Certificate::load("cert.pem", "key.pem")?)
        .build();

    let server = Endpoint::server(config)?;

    println!("Waiting for incoming connections...");
    loop {
        let connecting = server.accept().await?;

        tokio::spawn(async move {
           println!("New connection");
           let connection = connecting.await?;
           let stream = connection.accept_bi().await?
           // ...
        });
    }
}

Getting Started

0. Clone the Repository

git clone https://github.com/BiagioFesta/wtransport.git
cd wtransport/

1. Generate TLS Certificate

cargo run --example gencert

This will generate cert.pem and key.pem in the current working directory.

Moreover, the program will also output the fingerprint of the certificate. Something like this:

Certificate generated
Fingerprint: OjyqTe//WoGnvBrgiO37tkOQJyuN1r7hhyBzwX0gotg=

Please take note of the fingerprint, as you will need it to verify the certificate on the client side.

2. Run Example Server

cargo run --example server

3. Run Client on Browser

Latest versions of Google Chrome started supporting some implementations of the protocol.

Since the generated certificate is self-signed, it cannot be directly accepted by the browser at the moment. In order to allow the local certificate, you need to launch Google Chrome with two additional options:

google-chrome \
  --origin-to-force-quic-on=localhost:4433 \
  --ignore-certificate-errors-spki-list=FINGERPRINT

Replace FINGERPRINT with the value obtained in step 1. For example, OjyqTe//WoGnvBrgiO37tkOQJyuN1r7hhyBzwX0gotg=.

4. Connect to the Server

Open the website https://webtransport.day/ on Google Chrome instace. Use the URL: https://localhost:4433, and click on Connect.

Enjoy!

Examples

You might also like...
A high performence Socks5 proxy server with bind/reverse support implementation by Rust.

rsocx A high performence Socks5 proxy server with bind/reverse support implementation by Rust Features Async-std No unsafe code Single executable Linu

Interactive bind/reverse PTY shell with Windows&Linux support implementation by Rust.
Interactive bind/reverse PTY shell with Windows&Linux support implementation by Rust.

Cliws Lightweight interactive bind/reverse PTY shell with Windows&Linux support implementation by Rust. Features WebSocket Full pty support: VIM, SSH,

Rustus - TUS protocol implementation in Rust.

Rustus Tus protocol implementation written in Rust. Features This implementation has several features to make usage as simple as possible. Rustus is r

An implementation of the ZITADEL gRPC API in Rust.

An implementation of the ZITADEL gRPC API in Rust. Complemented with other useful elements such as ServiceAccount auth.

RakNet Protocol implementation by Rust.

rust-raknet RakNet Protocol implementation by Rust. Raknet is a reliable udp transport protocol that is often used for communication between game clie

Implementation of the Docker Registry HTTP API V2 in Rust, that can act as a proxy to other registries

Docker registry server and proxy (I'm bad at creating catchy names, but this one is good enough.) This project aims to implement a Docker Registry HTT

Rust implementation of TCP + UDP Proxy Protocol (aka. MMProxy)

mmproxy-rs A Rust implementation of MMProxy! πŸš€ Rationale Many previous implementations only support PROXY Protocol for either TCP or UDP, whereas thi

A rust implementation of websock/socket proxy. Support noVNC

websockify-rs: WebSockets support for any application/server This is a rust implement of the websockify-js, which is part of the noVNC project. At the

An implementation of the classic arcade game Whac-A-Hole inside Discord, made in 12 hours, with no experience in Rust.

Whac-A-Hole A blazingly fast implementation of the classic arcade game What-A-Hole inside Discord, made in 12 hours, with no experience in Rust ( πŸš€ ?

Comments
  • My suggestions for APIs

    My suggestions for APIs

    I have a suggestion that the same stream should only be triggered once, and then the data transmitted through the stream will pass through OnStreamData. It is also recommended that each stream carry a streamId.

    opened by redoriental 5
Releases(0.1.1)
  • 0.1.1(Jun 9, 2023)

    Version 0.1.1

    What's Changed

    • Dgrams support
    • Varint Refactoring
    • Retrieve Remote address
    • Default TLS enforced
    • Others

    Full Changelog: https://github.com/BiagioFesta/wtransport/compare/0.1.0...0.1.1

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(May 25, 2023)

    Version 0.1.0 - Initial Release of WTransport

    This release marks the initial release of WTransport, a Rust library that implements the WebTransport protocol.

    While it is not yet production-ready and should be used with caution, this release lays the groundwork for future development and testing. Users can explore the core functionality of WebTransport, including low-latency bidirectional communication, multiplexing, and enhanced security features.

    Contributions, feedback, and bug reports are welcomed as we continue to refine and improve the library.

    Source code(tar.gz)
    Source code(zip)
Owner
Biagio Festa
Biagio Festa
A minimalistic encryption protocol for rust async streams/packets, based on noise protocol and snow.

Snowstorm A minimalistic encryption protocol for rust async streams / packets, based on noise protocol and snow. Quickstart Snowstorm allows you to se

Black Binary 19 Nov 22, 2022
A mini async telnet client.

mini-telnet A mini async telnet client.

kolapapa 15 May 5, 2022
Redis backed session store for async-session using fred.rs.

async-fred-session Redis backed session store for async-session using fred.rs. This work is mostly based on async-redis-session. use async_fred_sessio

void* 4 Feb 28, 2023
Futures-based QUIC implementation in Rust

Pure-rust QUIC protocol implementation Quinn is a pure-rust, future-based implementation of the QUIC transport protocol undergoing standardization by

null 2.6k Jan 8, 2023
neqo β€” an Implementation of QUIC written in Rust

Neqo, an Implementation of QUIC written in Rust To run test HTTP/3 programs (neqo-client and neqo-server): cargo build ./target/debug/neqo-server [::]

Mozilla 1.6k Jan 7, 2023
The Rust Implementation of libp2p networking stack.

Central repository for work on libp2p This repository is the central place for Rust development of the libp2p spec. Warning: While we are trying our b

libp2p 3k Jan 4, 2023
A pure Rust implementation of WebRTC API

A pure Rust implementation of WebRTC API

WebRTC.rs 2.7k Jan 7, 2023
Backroll is a pure Rust implementation of GGPO rollback networking library.

backroll-rs Backroll is a pure Rust implementation of GGPO rollback networking library. Development Status This is still in an untested alpha stage. A

Hourai Teahouse 273 Dec 28, 2022
A small holepunching implementation written in Rust (UDP)

rust-udp-holepunch A small holepunching implementation written in Rust (UDP) Prerequisites Your rendezvous server must lay in a network which doesn't

Amit Katz 8 Dec 26, 2022
Rust implementation of PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols

Rust PRECIS Framework libray PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols as descr

Santiago Carot-Nemesio 1 Oct 20, 2022