All Projects → tafia → hyper-proxy

tafia / hyper-proxy

Licence: MIT license
A proxy connector for Hyper-based crates

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to hyper-proxy

Tokio Rustls
Asynchronous TLS/SSL streams for Tokio using Rustls.
Stars: ✭ 143 (+95.89%)
Mutual labels:  tls, tokio, futures
aitch
aitch is a simple, lightweight toolkit for building HTTP servers in Rust, loosely based on Go's net/http.
Stars: ✭ 19 (-73.97%)
Mutual labels:  hyper, tokio, futures
tsukuyomi
Asynchronous Web framework for Rust
Stars: ✭ 81 (+10.96%)
Mutual labels:  tokio, futures
Illustrated Tls
The Illustrated TLS Connection: Every byte explained
Stars: ✭ 2,751 (+3668.49%)
Mutual labels:  tls, ssl
hudsucker
Intercepting HTTP/S proxy
Stars: ✭ 114 (+56.16%)
Mutual labels:  tls, ssl
Rustls
A modern TLS library in Rust
Stars: ✭ 3,062 (+4094.52%)
Mutual labels:  tls, ssl
Snuffy
Snuffy is a simple command line tool to inspect SSL/TLS data.
Stars: ✭ 236 (+223.29%)
Mutual labels:  tls, ssl
SimpleSockets
Asynchronous TCP .NET library with reliable transmission and receipt of data, with an ssl implementation.
Stars: ✭ 74 (+1.37%)
Mutual labels:  tls, ssl
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (+186.3%)
Mutual labels:  tls, ssl
steady-tun
Secure TLS tunnel with pool of prepared upstream connections
Stars: ✭ 37 (-49.32%)
Mutual labels:  tls, ssl
dheater
D(HE)ater is a proof of concept implementation of the D(HE)at attack (CVE-2002-20001) through which denial-of-service can be performed by enforcing the Diffie-Hellman key exchange.
Stars: ✭ 142 (+94.52%)
Mutual labels:  tls, ssl
python-mbedtls
Cryptographic library with an mbed TLS back end
Stars: ✭ 64 (-12.33%)
Mutual labels:  tls, ssl
Sslyze
Fast and powerful SSL/TLS scanning library.
Stars: ✭ 2,623 (+3493.15%)
Mutual labels:  tls, ssl
Ssl exporter
Exports Prometheus metrics for SSL certificates
Stars: ✭ 211 (+189.04%)
Mutual labels:  tls, ssl
vault-pki-monitor-venafi
Venafi PKI Monitoring Secrets Engine for HashiCorp Vault that enforces security policy and provides certificate visiblity to the enterprise.
Stars: ✭ 18 (-75.34%)
Mutual labels:  tls, ssl
Terraform Provider Acme Old
ACME (Let's Encrypt) Support for Terraform
Stars: ✭ 211 (+189.04%)
Mutual labels:  tls, ssl
Openssl
TLS/SSL and crypto library
Stars: ✭ 17,157 (+23402.74%)
Mutual labels:  tls, ssl
Chromium-Gost
Chromium с поддержкой алгоритмов ГОСТ
Stars: ✭ 286 (+291.78%)
Mutual labels:  tls, ssl
Manuale
A fully manual Let's Encrypt/ACME client
Stars: ✭ 201 (+175.34%)
Mutual labels:  tls, ssl
Gmssl
支持国密SM2/SM3/SM4/SM9/ZUC/SSL的OpenSSL分支
Stars: ✭ 2,747 (+3663.01%)
Mutual labels:  tls, ssl

hyper-proxy

Travis Build Status MIT licensed crates.io

A proxy connector for hyper based applications.

Documentation

Example

use hyper::{Client, Request, Uri};
use hyper::client::HttpConnector;
use futures::{TryFutureExt, TryStreamExt};
use hyper_proxy::{Proxy, ProxyConnector, Intercept};
use headers::Authorization;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let proxy = {
        let proxy_uri = "http://my-proxy:8080".parse().unwrap();
        let mut proxy = Proxy::new(Intercept::All, proxy_uri);
        proxy.set_authorization(Authorization::basic("John Doe", "Agent1234"));
        let connector = HttpConnector::new();
        let proxy_connector = ProxyConnector::from_proxy(connector, proxy).unwrap();
        proxy_connector
    };

    // Connecting to http will trigger regular GETs and POSTs.
    // We need to manually append the relevant headers to the request
    let uri: Uri = "http://my-remote-website.com".parse().unwrap();
    let mut req = Request::get(uri.clone()).body(hyper::Body::empty()).unwrap();

    if let Some(headers) = proxy.http_headers(&uri) {
        req.headers_mut().extend(headers.clone().into_iter());
    }

    let client = Client::builder().build(proxy);
    let fut_http = client.request(req)
        .and_then(|res| res.into_body().map_ok(|x|x.to_vec()).try_concat())
        .map_ok(move |body| ::std::str::from_utf8(&body).unwrap().to_string());

    // Connecting to an https uri is straightforward (uses 'CONNECT' method underneath)
    let uri = "https://my-remote-websitei-secured.com".parse().unwrap();
    let fut_https = client.get(uri)
        .and_then(|res| res.into_body().map_ok(|x|x.to_vec()).try_concat())
        .map_ok(move |body| ::std::str::from_utf8(&body).unwrap().to_string());

    let (http_res, https_res) = futures::future::join(fut_http, fut_https).await;
    let (_, _) = (http_res?, https_res?);

    Ok(())
}

Features

hyper-proxy exposes three main Cargo features, to configure which TLS implementation it uses to connect to a proxy. It can also be configured without TLS support, by compiling without default features entirely. The supported list of configurations is:

  1. No TLS support (default-features = false)
  2. TLS support via native-tls to link against the operating system's native TLS implementation (default)
  3. TLS support via rustls (default-features = false, features = ["rustls"])
  4. TLS support via rustls, using a statically-compiled set of CA certificates to bypass the operating system's default store (default-features = false, features = ["rustls-webpki"])

Credits

Large part of the code comes from reqwest. The core part as just been extracted and slightly enhanced.

Main changes are:

  • support for authentication
  • add non secured tunneling
  • add the possibility to add additional headers when connecting to the proxy
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].