-
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
base: master
Are you sure you want to change the base?
Changes from all commits
c88b416
d2cf0fe
47231a8
0d2dfbc
c73c891
4f72433
5f85b4a
a38c482
51047db
53e8b08
1f568f1
a7bd4cc
4c88862
505ce12
e8d59b6
cd6074e
475fdfd
1cd05bb
8b0e4d7
c7b29b1
cd70c13
3591f61
add3c42
b47c9cf
429b32b
bdcbad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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.
| 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>"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"] | ||
This file was deleted.
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we append ourselves to this..?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| 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/metalbear-co/hyper-http-proxy/actions/workflows/checks.yaml) | ||
| [](./LICENSE-MIT.md) | ||
| [](https://crates.io/crates/rigetti-hyper-proxy) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
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