Domain Fronting
A Rust library for domain fronting - tunneling connections through HTTP POST requests to bypass censorship and access restrictions.
- Client: Implements
AsyncRead+AsyncWritefor seamless integration with async code - Server: HTTP session management with persistent upstream TCP connection per session
- TLS: TLS support with SNI (requires the
tlsfeature)
Cargo Features
tls: Enables TLS support viarustls(disabled by default)examples: Enables example binaries (includestls)
Building the server
To build the server on Ubuntu 22.04 and 24.04, you need to have build-essential and at least 1.85 version of the rust toolchain.
With the dependencies installed, the binary can be built via cargo.
cargo build --bin domain_fronting_server --features examples --release
The binary will reside in
$CARGO_TARGET_DIR/target/release/domain_fronting_server, typically this is
in ./target/release/domain_fronting_server.
Usage
Client
Enable the tls feature and supply your own rustls::ClientConfig with the certificate store of your choice:
[]
= { = "0.1", = ["tls"] }
use ;
use ;
use ClientConfig;
use Arc;
async
Client with custom transport
To provide your own transport stream (e.g. for testing or when the TCP connection is managed externally):
use ;
use ;
use TcpStream;
use ClientConfig;
use Arc;
async
Server
use Sessions;
use Arc;
async
Examples
The crate includes two example binaries:
Client Example
Server Example
For plain TCP (no TLS):
Protocol
The domain fronting protocol works as follows:
- Client establishes an HTTP/1.1 connection to the fronting domain (CDN)
- Client sends POST requests with:
Hostheader set to the target host- Session ID header (configurable) with a unique UUID
- Request body containing data to send upstream
- Server maintains a persistent upstream connection for each session ID
- Server forwards client data to upstream and returns upstream response in HTTP response body
- Empty POST requests are used for polling when the client has no data to send
License
Copyright (C) 2026 Mullvad VPN AB
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
For the full license agreement, see the LICENSE file or find it at https://www.gnu.org/licenses/gpl-3.0.