-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathhickory_dns.rs
More file actions
31 lines (24 loc) · 730 Bytes
/
Copy pathhickory_dns.rs
File metadata and controls
31 lines (24 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::sync::Arc;
use wreq::dns::{HickoryDnsResolver, LookupIpStrategy};
#[tokio::main]
async fn main() -> wreq::Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
// Custom dns resolve,Can be assigned to multiple clients
let resolver = Arc::new(HickoryDnsResolver::new(LookupIpStrategy::Ipv4thenIpv6)?);
// Build a client
let client = wreq::Client::builder()
.dns_resolver(resolver)
.no_proxy()
.build()?;
// Use the API you're already familiar with
let text = client
.get("https://tls.peet.ws/api/all")
.send()
.await?
.text()
.await?;
println!("{text}");
Ok(())
}