forked from seanmonstar/reqwest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom DNS resolution (seanmonstar#1653)
Closes seanmonstar#1125
- Loading branch information
1 parent
231b18f
commit f11e958
Showing
7 changed files
with
191 additions
and
278 deletions.
There are no files selected for viewing
This file contains 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 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 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,32 @@ | ||
use futures_util::future::FutureExt; | ||
use hyper::client::connect::dns::{GaiResolver as HyperGaiResolver, Name}; | ||
use hyper::service::Service; | ||
|
||
use crate::dns::{Addrs, Resolve, Resolving}; | ||
use crate::error::BoxError; | ||
|
||
#[derive(Debug)] | ||
pub struct GaiResolver(HyperGaiResolver); | ||
|
||
impl GaiResolver { | ||
pub fn new() -> Self { | ||
Self(HyperGaiResolver::new()) | ||
} | ||
} | ||
|
||
impl Default for GaiResolver { | ||
fn default() -> Self { | ||
GaiResolver::new() | ||
} | ||
} | ||
|
||
impl Resolve for GaiResolver { | ||
fn resolve(&self, name: Name) -> Resolving { | ||
let this = &mut self.0.clone(); | ||
Box::pin(Service::<Name>::call(this, name).map(|result| { | ||
result | ||
.map(|addrs| -> Addrs { Box::new(addrs) }) | ||
.map_err(|err| -> BoxError { Box::new(err) }) | ||
})) | ||
} | ||
} |
Oops, something went wrong.