Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c88b416
feat: Upgrade to http / hyper 1.0
siketyan Jan 14, 2024
d2cf0fe
ci: Add GitHub Actions workflow
siketyan Jan 14, 2024
47231a8
fix: Use from_proxy_unsecured for no-tls and native-tls in examples
siketyan Jan 14, 2024
0d2dfbc
chore: Fix documentation URL, Bump MSRV to 1.70
siketyan Jan 14, 2024
c73c891
ci: Remove Travis CI
siketyan Jan 14, 2024
4f72433
update dependencies
aviramha May 26, 2024
5f85b4a
Refactor
aviramha May 26, 2024
a38c482
rename to hyper-http-proxy
aviramha May 26, 2024
51047db
hygiene
aviramha May 26, 2024
53e8b08
lint
aviramha May 26, 2024
1f568f1
release
aviramha May 26, 2024
a7bd4cc
fix test
aviramha May 26, 2024
4c88862
..
aviramha May 26, 2024
505ce12
call set_authorization when creating a Proxy
goenning Feb 20, 2025
e8d59b6
Update src/lib.rs
goenning Mar 11, 2025
cd6074e
add doc
goenning Mar 11, 2025
475fdfd
cargo fmt --all
goenning Mar 12, 2025
1cd05bb
Merge pull request #2 from goenning/main
Razz4780 Mar 12, 2025
8b0e4d7
1.1.0
Razz4780 Mar 12, 2025
c7b29b1
Merge pull request #3 from metalbear-co/1.1.0
Razz4780 Mar 12, 2025
cd70c13
remove unused rustls-native-certs crate from dependencies
tottoto Mar 20, 2025
3591f61
Merge pull request #4 from tottoto/remove-rustls-native-certs-from-de…
Razz4780 Feb 10, 2026
add3c42
Bump version from 1.1.0 to 1.1.1
Razz4780 Mar 21, 2026
b47c9cf
Claude recommends upstream commits
BatmanAoD Apr 17, 2026
429b32b
Cherry-pick panic fix and rename crate to rigetti-hyper-proxy
BatmanAoD Apr 17, 2026
bdcbad9
do a few more dependency upgrades
BatmanAoD Apr 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Checks

on:
push:
branches:
- main
pull_request: ~

jobs:
test:
name: Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt,clippy

- name: Run rustfmt
run: cargo fmt --all --check

- name: Run clippy
uses: giraffate/clippy-action@v1
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests default
run: cargo test
- name: Run tests rustls-tls-webpki-roots
run: cargo test --no-default-features --features rustls-tls-webpki-roots
- name: Run tests native-tls-vendored
run: cargo test --no-default-features --features native-tls-vendored
- name: Run tests native-tls
run: cargo test --no-default-features --features native-tls
20 changes: 20 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
push:
tags:
- "*.*.*"
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CRATES_IO_SECRET }}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

68 changes: 36 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
[package]
name = "hyper-proxy"
version = "0.9.0"
authors = ["Johann Tuffe <tafia973@gmail.com>"]
name = "rigetti-hyper-proxy"
version = "1.1.1"
authors = ["MetalBear Tech LTD <hi@metalbear.co>"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably change this, just in case people use this email to ask for support?

description = "A proxy connector for Hyper-based applications"

documentation = "https://docs.rs/hyper-proxy"
repository = "https://github.com/tafia/hyper-proxy"

documentation = "https://docs.rs/rigetti-hyper-proxy"
repository = "https://github.com/metalbear-co/hyper-http-proxy"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with this

readme = "README.md"
keywords = ["hyper", "proxy", "tokio", "ssl"]
categories = ["web-programming::http-client", "asynchronous", "authentication"]
license = "MIT"
edition = "2018"
edition = "2021"
rust-version = "1.70.0"

[dependencies]
tokio = { version = "1", features = ["io-std", "io-util"] }
hyper = { version = "0.14", features = ["client"] }
tokio = { version = "1.47", features = ["io-std", "io-util"] }
hyper = { version = "1", features = ["client"] }
hyper-util = { version = "0.1", features = ["client", "client-legacy", "tokio"] }

tower-service = "0.3"
http = "0.2"
http = "1"
futures-util = { version = "0.3", default-features = false }
bytes = "1.0"
hyper-tls = { version = "0.5.0", optional = true }
tokio-native-tls = { version = "0.3.0", optional = true }
bytes = "1.11"
pin-project-lite = "0.2"
hyper-tls = { version = "0.6", optional = true }
tokio-native-tls = { version = "0.3", optional = true }
native-tls = { version = "0.2", optional = true }
openssl = { version = "0.10", optional = true }
tokio-openssl = { version = "0.6", optional = true }
tokio-rustls = { version = "0.22", optional = true }
hyper-rustls = { version = "0.22", optional = true }
tokio-rustls = { version = "0.26", optional = true, default-features = false}
hyper-rustls = { version = "0.27", optional = true, default-features = false }

webpki = { version = "0.21", optional = true }
rustls-native-certs = { version = "0.5.0", optional = true }
webpki-roots = { version = "0.21.0", optional = true }
headers = "0.3"
webpki-roots = { version = "1.0", optional = true }
headers = "0.4"

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
hyper = { version = "0.14", features = ["client", "http1", "tcp"] }
tokio = { version = "1.47", features = ["full"] }
hyper = { version = "1.9", features = ["client", "http1"] }
hyper-util = { version = "0.1", features = ["client", "client-legacy", "http1", "tokio"] }
http-body-util = "0.1"
futures = "0.3"

[features]
openssl-tls = ["openssl", "tokio-openssl"]
tls = ["tokio-native-tls", "hyper-tls", "native-tls"]
# note that `rustls-base` is not a valid feature on its own - it will configure rustls without root
# certificates!
rustls-base = ["tokio-rustls", "hyper-rustls", "webpki"]
rustls = ["rustls-base", "rustls-native-certs", "hyper-rustls/native-tokio"]
rustls-webpki = ["rustls-base", "webpki-roots", "hyper-rustls/webpki-tokio"]
default = ["tls"]
default = ["default-tls"]
default-tls = ["rustls-tls-native-roots"]
native-tls = ["dep:native-tls", "tokio-native-tls", "hyper-tls", "__tls"]
native-tls-vendored = ["native-tls", "tokio-native-tls?/vendored"]
rustls-tls-webpki-roots = ["dep:webpki-roots", "__rustls", "hyper-rustls/webpki-roots"]
rustls-tls-native-roots = ["__rustls", "hyper-rustls/rustls-native-certs"]

__tls = []

# Enables common rustls code.
# Equivalent to rustls-tls-manual-roots but shorter :)
__rustls = ["dep:hyper-rustls", "dep:tokio-rustls", "__tls"]
50 changes: 0 additions & 50 deletions Changelog.md

This file was deleted.

2 changes: 2 additions & 0 deletions LICENSE-MIT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
The MIT License (MIT)

Copyright (c) 2017 Johann Tuffe
Copyright (c) 2024 Natsuki Ikeguchi
Copyright (c) 2024 MetalBear Tech LTD
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we append ourselves to this..?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add us here


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
116 changes: 66 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,100 @@
# hyper-proxy
# rigetti-hyper-proxy

[![Travis Build Status](https://travis-ci.org/tafia/hyper-proxy.svg?branch=master)](https://travis-ci.org/tafia/hyper-proxy)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![crates.io](http://meritbadge.herokuapp.com/hyper-proxy)](https://crates.io/crates/hyper-proxy)
[![Checks](https://github.com/metalbear-co/hyper-http-proxy/actions/workflows/checks.yaml/badge.svg)](https://github.com/metalbear-co/hyper-http-proxy/actions/workflows/checks.yaml)
[![MIT licensed](https://img.shields.io/github/license/metalbear-co/hyper-http-proxy)](./LICENSE-MIT.md)
[![crates.io](https://img.shields.io/crates/v/rigetti-hyper-proxy)](https://crates.io/crates/rigetti-hyper-proxy)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably change these references too

A proxy connector for [hyper][1] based applications.

[Documentation][3]

## Example

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

use bytes::Bytes;
use headers::Authorization;
use http_body_util::{BodyExt, Empty};
use hyper::{Request, Uri};
use rigetti_hyper_proxy::{Proxy, ProxyConnector, Intercept};
use hyper_util::client::legacy::Client;
use hyper_util::client::legacy::connect::HttpConnector;
use hyper_util::rt::TokioExecutor;

#[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(())
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(Empty::<Bytes>::new()).unwrap();

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

let client = Client::builder(TokioExecutor::new()).build(proxy);
let fut_http = async {
let res = client.request(req).await?;
let body = res.into_body().collect().await?.to_bytes();

Ok::<_, Box<dyn Error>>(String::from_utf8(body.to_vec()).unwrap())
};

// Connecting to an https uri is straightforward (uses 'CONNECT' method underneath)
let uri = "https://my-remote-websitei-secured.com".parse().unwrap();
let fut_https = async {
let res = client.get(uri).await?;
let body = res.into_body().collect().await?.to_bytes();

Ok::<_, Box<dyn Error>>(String::from_utf8(body.to_vec()).unwrap())
};

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
`rigetti-hyper-proxy` exposes 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:

native-tls = ["dep:native-tls", "tokio-native-tls", "hyper-tls", "__tls"]
native-tls-vendored = ["native-tls", "tokio-native-tls?/vendored"]
rustls-tls-manual-roots = ["__rustls"]
rustls-tls-webpki-roots = ["dep:webpki-roots", "__rustls"]
rustls-tls-native-roots = ["dep:rustls-native-certs", "__rustls", "hyper-rustls/rustls-native-certs"]
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"]`)
2. TLS support via `native-tls` to link against the operating system's native TLS implementation (`default-features = false, features = ["native-tls"]`)
3. TLS support via `rustls` using native certificates (default).
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"]`)
operating system's default store (`default-features = false, features = ["rustls-tls-webpki-roots"]`)

## Credits

This was forked from https://github.com/siketyan/hyper-http-proxy that originally forked from https://github.com/tafia/hyper-proxy


Large part of the code comes from [reqwest][2].
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

[1]: https://crates.io/crates/hyper
[2]: https://github.com/seanmonstar/reqwest
[3]: https://docs.rs/hyper-proxy
[3]: https://docs.rs/rigetti-hyper-proxy
Loading
Loading