mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 09:04:45 +08:00
dns fix
This commit is contained in:
@ -37,10 +37,10 @@ pub fn set_default_header(headers: HashMap<String, String>) {
|
||||
pub async fn fetch(method: MyMethod,
|
||||
url: String,
|
||||
headers: Option<HashMap<String, String>>,
|
||||
input_data: Option<Vec<u8>>) -> RustHttpResponse {
|
||||
http_package::fetch(_my_method_to_hyper_method(method), url, headers, input_data).await.unwrap()
|
||||
input_data: Option<Vec<u8>>) -> anyhow::Result<RustHttpResponse> {
|
||||
http_package::fetch(_my_method_to_hyper_method(method), url, headers, input_data).await
|
||||
}
|
||||
|
||||
pub async fn dns_lookup_txt(host: String) -> Vec<String> {
|
||||
http_package::dns_lookup_txt(host).await.unwrap()
|
||||
pub async fn dns_lookup_txt(host: String) -> anyhow::Result<Vec<String>> {
|
||||
http_package::dns_lookup_txt(host).await
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.23.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.24.
|
||||
|
||||
// Section: imports
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.23.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.24.
|
||||
|
||||
#![allow(
|
||||
non_camel_case_types,
|
||||
@ -31,7 +31,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
|
||||
default_rust_opaque = RustOpaqueMoi,
|
||||
default_rust_auto_opaque = RustAutoOpaqueMoi,
|
||||
);
|
||||
const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.23";
|
||||
const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.24";
|
||||
|
||||
// Section: executor
|
||||
|
||||
@ -120,10 +120,8 @@ fn wire_dns_lookup_txt_impl(
|
||||
deserializer.end();
|
||||
move |context| async move {
|
||||
transform_result_sse(
|
||||
(move || async move {
|
||||
Result::<_, ()>::Ok(crate::api::http_api::dns_lookup_txt(api_host).await)
|
||||
})()
|
||||
.await,
|
||||
(move || async move { crate::api::http_api::dns_lookup_txt(api_host).await })()
|
||||
.await,
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -160,15 +158,13 @@ fn wire_fetch_impl(
|
||||
move |context| async move {
|
||||
transform_result_sse(
|
||||
(move || async move {
|
||||
Result::<_, ()>::Ok(
|
||||
crate::api::http_api::fetch(
|
||||
api_method,
|
||||
api_url,
|
||||
api_headers,
|
||||
api_input_data,
|
||||
)
|
||||
.await,
|
||||
crate::api::http_api::fetch(
|
||||
api_method,
|
||||
api_url,
|
||||
api_headers,
|
||||
api_input_data,
|
||||
)
|
||||
.await
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
@ -218,6 +214,13 @@ flutter_rust_bridge::frb_generated_moi_arc_impl_value!(
|
||||
|
||||
// Section: dart2rust
|
||||
|
||||
impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
unreachable!("");
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for reqwest::Version {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@ -673,6 +676,13 @@ impl flutter_rust_bridge::IntoIntoDart<crate::http_package::RustHttpResponse>
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<String>::sse_encode(format!("{:?}", self), serializer);
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for reqwest::Version {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.23.
|
||||
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.24.
|
||||
|
||||
// Section: imports
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use hickory_resolver::config::{NameServerConfigGroup, ResolverConfig, ResolverOpts};
|
||||
use hickory_resolver::{lookup_ip::LookupIpIntoIter, TokioAsyncResolver};
|
||||
use std::io;
|
||||
use hickory_resolver::{lookup_ip::LookupIpIntoIter, system_conf, TokioAsyncResolver};
|
||||
use hyper::client::connect::dns::Name;
|
||||
use once_cell::sync::OnceCell;
|
||||
use reqwest::dns::{Addrs, Resolve, Resolving};
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Wrapper around an `AsyncResolver`, which implements the `Resolve` trait.
|
||||
@ -52,16 +52,12 @@ impl Iterator for SocketAddrs {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_resolver() -> anyhow::Result<TokioAsyncResolver> {
|
||||
let ali_ips: &[IpAddr] = &[
|
||||
IpAddr::V4(Ipv4Addr::new(223, 5, 5, 5)),
|
||||
IpAddr::V4(Ipv4Addr::new(223, 6, 6, 6)),
|
||||
IpAddr::V6("2400:3200::1".parse::<Ipv6Addr>()?),
|
||||
IpAddr::V6("2400:3200:baba::1".parse::<Ipv6Addr>()?),
|
||||
];
|
||||
|
||||
let group =
|
||||
NameServerConfigGroup::from_ips_https(ali_ips, 443, "dns.alidns.com".to_string(), true);
|
||||
let cfg = ResolverConfig::from_parts(None, vec![], group);
|
||||
Ok(TokioAsyncResolver::tokio(cfg, ResolverOpts::default()))
|
||||
fn new_resolver() -> io::Result<TokioAsyncResolver> {
|
||||
let (config, opts) = system_conf::read_system_conf().map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("error reading DNS system conf: {}", e),
|
||||
)
|
||||
})?;
|
||||
Ok(TokioAsyncResolver::tokio(config, opts))
|
||||
}
|
||||
|
Reference in New Issue
Block a user