mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 10:03:43 +08:00
dns fix
This commit is contained in:
parent
1afbe200c8
commit
b77f5a6495
@ -1,6 +1,4 @@
|
|||||||
import 'package:card_swiper/card_swiper.dart';
|
import 'package:card_swiper/card_swiper.dart';
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_tilt/flutter_tilt.dart';
|
import 'package:flutter_tilt/flutter_tilt.dart';
|
||||||
|
@ -19,6 +19,6 @@ uuid = { version = "1.7.0", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
|||||||
async-std = "1.12.0"
|
async-std = "1.12.0"
|
||||||
hyper = { version = "0.14.28"}
|
hyper = { version = "0.14.28"}
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
reqwest = { version = "0.11", features = ["rustls-tls-native-roots", "cookies", "gzip", "brotli", "deflate", "multipart", "trust-dns", "json","stream"] }
|
reqwest = { version = "0.11", features = ["rustls-tls-native-roots", "cookies", "gzip", "json","stream"] }
|
||||||
hickory-resolver = {version = "0.24.0", features = [ "dns-over-https-rustls","dns-over-rustls","native-certs"]}
|
hickory-resolver = {version = "0.24.0"}
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
@ -429,7 +429,7 @@ impl SseDecode for crate::http_package::RustHttpResponse {
|
|||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
let mut var_statusCode = <u16>::sse_decode(deserializer);
|
let mut var_statusCode = <u16>::sse_decode(deserializer);
|
||||||
let mut var_headers = <std::collections::HashMap<String, String>>::sse_decode(deserializer);
|
let mut var_headers = <HashMap<String, String>>::sse_decode(deserializer);
|
||||||
let mut var_url = <String>::sse_decode(deserializer);
|
let mut var_url = <String>::sse_decode(deserializer);
|
||||||
let mut var_contentLength = <Option<u64>>::sse_decode(deserializer);
|
let mut var_contentLength = <Option<u64>>::sse_decode(deserializer);
|
||||||
let mut var_version = <reqwest::Version>::sse_decode(deserializer);
|
let mut var_version = <reqwest::Version>::sse_decode(deserializer);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
use hickory_resolver::{lookup_ip::LookupIpIntoIter, system_conf, TokioAsyncResolver};
|
use hickory_resolver::{lookup_ip::LookupIpIntoIter, TokioAsyncResolver};
|
||||||
use hyper::client::connect::dns::Name;
|
use hyper::client::connect::dns::Name;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use reqwest::dns::{Addrs, Resolve, Resolving};
|
use reqwest::dns::{Addrs, Resolve, Resolving};
|
||||||
use std::net::SocketAddr;
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use hickory_resolver::config::{NameServerConfigGroup, ResolverConfig, ResolverOpts};
|
||||||
|
|
||||||
/// Wrapper around an `AsyncResolver`, which implements the `Resolve` trait.
|
/// Wrapper around an `AsyncResolver`, which implements the `Resolve` trait.
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
@ -53,11 +54,24 @@ impl Iterator for SocketAddrs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn new_resolver() -> io::Result<TokioAsyncResolver> {
|
fn new_resolver() -> io::Result<TokioAsyncResolver> {
|
||||||
let (config, opts) = system_conf::read_system_conf().map_err(|e| {
|
let group = NameServerConfigGroup::from_ips_clear(
|
||||||
io::Error::new(
|
&[
|
||||||
io::ErrorKind::Other,
|
IpAddr::V4(Ipv4Addr::new(119, 29, 29, 29)),
|
||||||
format!("error reading DNS system conf: {}", e),
|
IpAddr::V4(Ipv4Addr::new(223, 6, 6, 6)),
|
||||||
)
|
IpAddr::V4(Ipv4Addr::new(180, 76, 76, 76)),
|
||||||
})?;
|
IpAddr::V4(Ipv4Addr::new(1, 2, 4, 8)),
|
||||||
Ok(TokioAsyncResolver::tokio(config, opts))
|
IpAddr::V4(Ipv4Addr::new(166, 111, 8, 28)),
|
||||||
|
IpAddr::V4(Ipv4Addr::new(101, 226, 4, 6)),
|
||||||
|
IpAddr::V4(Ipv4Addr::new(114, 114, 114, 114)),
|
||||||
|
IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)),
|
||||||
|
IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)),
|
||||||
|
], 53, true);
|
||||||
|
let cfg = ResolverConfig::from_parts(None, vec![], group);
|
||||||
|
let mut opts = ResolverOpts::default();
|
||||||
|
opts.edns0 = true;
|
||||||
|
opts.timeout = std::time::Duration::from_secs(5);
|
||||||
|
opts.try_tcp_on_error = true;
|
||||||
|
opts.ip_strategy = hickory_resolver::config::LookupIpStrategy::Ipv4thenIpv6;
|
||||||
|
opts.num_concurrent_reqs = 3;
|
||||||
|
Ok(TokioAsyncResolver::tokio(cfg, opts))
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,10 @@ lazy_static! {
|
|||||||
static ref DNS_CLIENT : Arc<dns::MyHickoryDnsResolver> = Arc::from(dns::MyHickoryDnsResolver::default());
|
static ref DNS_CLIENT : Arc<dns::MyHickoryDnsResolver> = Arc::from(dns::MyHickoryDnsResolver::default());
|
||||||
static ref HTTP_CLIENT: reqwest::Client = {
|
static ref HTTP_CLIENT: reqwest::Client = {
|
||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.use_rustls_tls()
|
|
||||||
.dns_resolver(DNS_CLIENT.clone())
|
.dns_resolver(DNS_CLIENT.clone())
|
||||||
|
.use_rustls_tls()
|
||||||
.connect_timeout(Duration::from_secs(10))
|
.connect_timeout(Duration::from_secs(10))
|
||||||
.gzip(true)
|
.gzip(true)
|
||||||
.brotli(true)
|
|
||||||
.deflate(true)
|
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user