aboutsummaryrefslogtreecommitdiff
path: root/src/reverse_proxy.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-08 22:58:19 +0100
committerAlex Auvolat <alex@adnab.me>2021-12-08 22:58:19 +0100
commitca8c5aad2378dd9f8ec525b3b0779f5c53cfe9eb (patch)
treeba5ac35eeacd9ee85363c231030313e7204ecc63 /src/reverse_proxy.rs
parent55f57df82e8486065bd563c21e1ea858c9f8969d (diff)
downloadtricot-ca8c5aad2378dd9f8ec525b3b0779f5c53cfe9eb.tar.gz
tricot-ca8c5aad2378dd9f8ec525b3b0779f5c53cfe9eb.zip
Handle HTTPS targets
Diffstat (limited to 'src/reverse_proxy.rs')
-rw-r--r--src/reverse_proxy.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/reverse_proxy.rs b/src/reverse_proxy.rs
index 401f4b1..9d7780c 100644
--- a/src/reverse_proxy.rs
+++ b/src/reverse_proxy.rs
@@ -139,3 +139,26 @@ pub async fn call(
let proxied_response = create_proxied_response(response);
Ok(proxied_response)
}
+
+pub async fn call_https(
+ client_ip: IpAddr,
+ forward_uri: &str,
+ request: Request<Body>,
+) -> Result<Response<Body>> {
+ let proxied_request = create_proxied_request(client_ip, &forward_uri, request)?;
+
+ trace!("Proxied request (HTTPS): {:?}", proxied_request);
+
+ let https = hyper_rustls::HttpsConnectorBuilder::new()
+ .with_native_roots()
+ .https_only()
+ .enable_http1()
+ .build();
+ let client: Client<_, hyper::Body> = Client::builder().build(https);
+ let response = client.request(proxied_request).await?;
+
+ trace!("Inner response (HTTPS): {:?}", response);
+
+ let proxied_response = create_proxied_response(response);
+ Ok(proxied_response)
+}