forked from tafia/hyper-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Updates from other forks #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c88b416
feat: Upgrade to http / hyper 1.0
siketyan d2cf0fe
ci: Add GitHub Actions workflow
siketyan 47231a8
fix: Use from_proxy_unsecured for no-tls and native-tls in examples
siketyan 0d2dfbc
chore: Fix documentation URL, Bump MSRV to 1.70
siketyan c73c891
ci: Remove Travis CI
siketyan 4f72433
update dependencies
aviramha 5f85b4a
Refactor
aviramha a38c482
rename to hyper-http-proxy
aviramha 51047db
hygiene
aviramha 53e8b08
lint
aviramha 1f568f1
release
aviramha a7bd4cc
fix test
aviramha 4c88862
..
aviramha 505ce12
call set_authorization when creating a Proxy
goenning e8d59b6
Update src/lib.rs
goenning cd6074e
add doc
goenning 475fdfd
cargo fmt --all
goenning 1cd05bb
Merge pull request #2 from goenning/main
Razz4780 8b0e4d7
1.1.0
Razz4780 c7b29b1
Merge pull request #3 from metalbear-co/1.1.0
Razz4780 cd70c13
remove unused rustls-native-certs crate from dependencies
tottoto 3591f61
Merge pull request #4 from tottoto/remove-rustls-native-certs-from-de…
Razz4780 add3c42
Bump version from 1.1.0 to 1.1.1
Razz4780 b47c9cf
Claude recommends upstream commits
BatmanAoD 429b32b
Cherry-pick panic fix and rename crate to rigetti-hyper-proxy
BatmanAoD bdcbad9
do a few more dependency upgrades
BatmanAoD 1019e98
add our copyright to the license file
BatmanAoD 61647e4
replace MetalBear with Rigetti where appropriate
BatmanAoD ed2246e
cargo fmt
BatmanAoD aaaee80
remove LLM recommendations file (see PR #1)
BatmanAoD cba758c
fix 'example' project feature-flags
BatmanAoD 76cf405
clippy-fix
BatmanAoD e7d6eaf
GPT-5.3 fixes incompatible-feature compilation issue
BatmanAoD 1bcd38d
restore 'rustls' feature for existing usage; use cargo-hack in GitHub…
BatmanAoD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| 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: Install cargo-hack | ||
| uses: taiki-e/install-action@cargo-hack | ||
|
|
||
| - name: Run tests on each feature (excluding the helper features marked with `__`) | ||
| run: cargo hack --each-feature --skip __tls --skip __rustls test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,54 @@ | ||
| [package] | ||
| name = "hyper-proxy" | ||
| version = "0.9.0" | ||
| authors = ["Johann Tuffe <tafia973@gmail.com>"] | ||
| name = "rigetti-hyper-proxy" | ||
| version = "1.1.1" | ||
| authors = ["Rigetti QPU Software <qpu-software@rigetti.com>"] | ||
| 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/rigetti/http-proxy" | ||
| 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"] | ||
| # "Alias" for compatibility with existing usage. | ||
| rustls = ["rustls-tls-native-roots"] | ||
|
|
||
| __tls = [] | ||
|
|
||
| # Enables common rustls code. | ||
| __rustls = ["dep:hyper-rustls", "dep:tokio-rustls", "__tls"] |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,84 +1,100 @@ | ||
| # hyper-proxy | ||
| # rigetti-hyper-proxy | ||
|
|
||
| [](https://travis-ci.org/tafia/hyper-proxy) | ||
| [](./LICENSE) | ||
| [](https://crates.io/crates/hyper-proxy) | ||
| [](https://github.com/rigetti/hyper-proxy/actions/workflows/checks.yaml/badge.svg) | ||
| [](./LICENSE-MIT.md) | ||
| [](https://crates.io/crates/rigetti-hyper-proxy) | ||
|
|
||
|
BatmanAoD marked this conversation as resolved.
|
||
| 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to add this: https://github.com/rigetti/hyper-proxy/settings/secrets/actions