Crate pasque

Crate pasque 

Source
Expand description

Pasque is an UDP over HTTP/3 (RFC 9298) and IP over HTTP/3 implementation (RFC 9484). Built using Quiche as the HTTP/3 & QUIC implementation and Tokio for async operations. The project is yet under construction, and some features from the RFCs are still missing.

§Starting a server

psq-server.rs is a simple example of a server implementation using Pasque. For example, to start an UDP tunnel endpoint at path “udp”, you could have:

use pasque::{server::Config, PsqServer, UdpEndpoint};
use std::net::SocketAddr;
use std::str::FromStr;
#[tokio::main]
async fn main() {
    let config = Config::read_from_file("server.json").unwrap();
    let mut psqserver = PsqServer::start(
        &vec![SocketAddr::from_str("0.0.0.0:443").unwrap()],
        &config,
    ).await.unwrap();
    psqserver.add_endpoint("udp", Box::new(UdpEndpoint::new())).await;
}

(of course with proper error handling). First, certificate information is read from a config file, then HTTP/3 / QUIC server is started, binding to UDP port 4433. And a UdpEndpoint is added for proxying UDP datagrams. IpEndpoint can be used for proxying IP packets from TUN interface (needs sudo privilege, only tested on Linux for the time being).

§Starting a client

psq-client.rs is an example of a client implementation using Pasque. To match the above server example, a client-end of the UDP tunnel would be:

use pasque::{PsqClient, UdpTunnel};
#[tokio::main]
async fn main() {
    let mut psqconn = PsqClient::connect("https://localhost", false).await.unwrap();
    let udptunnel = UdpTunnel::connect(
        &mut psqconn,
        "udp",
        "130.233.224.196", 9000,
        "127.0.0.1:0".parse().unwrap(),
    ).await.unwrap();
    println!("UDP datagrams to {} are forwarded to HTTP tunnel.", udptunnel.sockaddr().unwrap());
}

The above first opens a HTTP/3 / QUIC connection to given server. Then UDP tunnel is connected to “udp” endpoint, for destination address 130.233.224.196, UDP port 9000. The client opens a local UDP socket that is used to deliver packets to and from the the tunnel. User can specify the address and port to bind, or if none is given, the bound address can be queried using the UdpTunnel::sockaddr() function.

IpTunnel is available for establishing IP tunnels from TUN interface (requires sudo privileges, tested only on Linux).

Re-exports§

pub use crate::client::PsqClient;
pub use crate::server::PsqServer;
pub use crate::stream::iptunnel::IpTunnel;
pub use crate::stream::iptunnel::IpEndpoint;
pub use crate::stream::udptunnel::UdpTunnel;
pub use crate::stream::udptunnel::UdpEndpoint;
pub use crate::stream::filestream::FileStream;
pub use crate::stream::filestream::Files;

Modules§

client
The client side operation of a HTTP/3 session
jwt
platform
Platform specific network operations
server
The server side operations for incoming HTTP/3 connections
stream
The client and server side logic for different types of tunnel endpoints
test_utils

Enums§

PsqError

Functions§

set_qlog