Skip to main content

Crate obfs4

Crate obfs4 

Source
Expand description

§ptrs-gesher-obfs4

License: MIT/Apache 2.0

An implementation of the obfs4 pluggable transport in pure Rust, providing both client and server sides. Part of the ptrs-gesher framework.

§Status

Version 0.3.0 – not yet published to crates.io. Interface subject to change. Not production ready; do not rely on this for security-critical applications.

§Example

Client example using the ptrs-gesher-core trait framework:

use ptrs::{Args, ClientBuilder as _, ClientTransport as _};
use obfs4;
use tokio::net::TcpStream;

let args = Args::from_str("")?;
let client = obfs4::ClientBuilder::default()
    .options(&args)?
    .build();

// future that opens a tcp connection when awaited
let conn_future = TcpStream::connect("127.0.0.1:9000");

// await (create) the tcp conn, attempt to handshake, and return a
// wrapped Read/Write object on success.
let obfs4_conn = client.establish(Box::pin(conn_future)).await?;

Server example:

let message = b"Hello universe";
let (mut c, mut s) = tokio::io::duplex(65_536);
let mut rng = rand::thread_rng();

let o4_server = obfs4::Server::new_from_random(&mut rng);

tokio::spawn(async move {
    let mut o4s_stream = o4_server.wrap(&mut s).await.unwrap();

    let mut buf = [0_u8; 50];
    let n = o4s_stream.read(&mut buf).await.unwrap();

    // echo the message back over the tunnel
    o4s_stream.write_all(&buf[..n]).await.unwrap();
});

§License

Dual-licensed under either:

  • Apache License, Version 2.0
  • MIT license

at your option.

Re-exports§

pub use client::Client;
pub use client::ClientBuilder;
pub use server::Server;
pub use server::ServerBuilder;

Modules§

client
obfs4 client types.
server
obfs4 server types.

Structs§

Obfs4Stream
An obfs4-encrypted bidirectional stream wrapping an inner async transport.
Transport
Generic obfs4 pluggable transport parameterised over an underlying stream type.

Enums§

Error
Errors that can occur when using the transports, including wrapped from dependencies.
IAT
IAT (inter-arrival time) traffic shaping mode for obfs4 connections.

Constants§

OBFS4_NAME
The transport name string.

Type Aliases§

Obfs4PT
Concrete obfs4 pluggable transport bound to TcpStream.
Result
Result type returning Error or T