mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-29 17:06:53 +08:00
使用 DNS 分流
This commit is contained in:
@ -21,12 +21,13 @@ pub struct RustHttpResponse {
|
||||
|
||||
lazy_static! {
|
||||
static ref DEFAULT_HEADER: RwLock<HeaderMap> = RwLock::from(HeaderMap::new());
|
||||
static ref DNS_CLIENT : Arc<dns::MyHickoryDnsResolver> = Arc::from(dns::MyHickoryDnsResolver::default());
|
||||
static ref HTTP_CLIENT: reqwest::Client = {
|
||||
reqwest::Client::builder()
|
||||
.use_rustls_tls()
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
.timeout(Duration::from_secs(10))
|
||||
.dns_resolver(Arc::from(dns::MyHickoryDnsResolver::default()))
|
||||
.dns_resolver(DNS_CLIENT.clone())
|
||||
.build()
|
||||
.unwrap()
|
||||
};
|
||||
@ -83,6 +84,10 @@ pub async fn fetch(
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
pub async fn dns_lookup_txt(name: String) -> anyhow::Result<Vec<String>> {
|
||||
DNS_CLIENT.lookup_txt(name).await
|
||||
}
|
||||
|
||||
fn _reade_resp_header(r_header: &HeaderMap) -> HashMap<String, String> {
|
||||
let mut resp_headers = HashMap::new();
|
||||
for ele in r_header {
|
||||
|
Reference in New Issue
Block a user