use hyper-tls and hyper-trust-dns as http(s) clients
This commit is contained in:
parent
819b944a46
commit
8fff4f4088
4 changed files with 138 additions and 80 deletions
10
src/proxy.rs
10
src/proxy.rs
|
|
@ -1,5 +1,8 @@
|
|||
use crate::{acceptor::PacketAcceptor, error::*, globals::Globals, log::*};
|
||||
use futures::future::select_all;
|
||||
use hyper::Client;
|
||||
#[cfg(feature = "forward-hyper-trust-dns")]
|
||||
use hyper_trust_dns::TrustDnsResolver;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -11,9 +14,16 @@ impl Proxy {
|
|||
let addresses = self.globals.listen_addresses.clone();
|
||||
let futures = select_all(addresses.into_iter().map(|addr| {
|
||||
info!("Listen address: {:?}", addr);
|
||||
|
||||
#[cfg(feature = "forward-hyper-trust-dns")]
|
||||
let connector = TrustDnsResolver::default().into_rustls_webpki_https_connector();
|
||||
#[cfg(not(feature = "forward-hyper-trust-dns"))]
|
||||
let connector = hyper_tls::HttpsConnector::new();
|
||||
|
||||
let acceptor = PacketAcceptor {
|
||||
listening_on: addr,
|
||||
globals: self.globals.clone(),
|
||||
forwarder: Client::builder().build::<_, hyper::Body>(connector),
|
||||
};
|
||||
self.globals.runtime_handle.spawn(acceptor.start())
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue