Skip to content

Commit

Permalink
favor ipv6 over ipv4 for resolving rstund
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Nov 19, 2023
1 parent 8ec9701 commit cd473f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bincode = "1.3.3"
pin-utils = "0.1.0"
enum-as-inner = "0.6"
num_cpus = "1.13.1"
rs-utilities = "0.4.0"
rs-utilities = "0.4.2"
# rs-utilities = { path = "../rs-utilities" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
17 changes: 13 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use log::{debug, error, info, warn};
use quinn::{congestion, TransportConfig};
use quinn::{RecvStream, SendStream};
use quinn_proto::{IdleTimeout, VarInt};
use rs_utilities::{dns, log_and_bail};
use rs_utilities::{
dns::{self, DNSQueryOrdering, DNSResolverConfig, DNSResolverLookupIpStrategy},
log_and_bail,
};
use rustls::{client::ServerCertVerified, Certificate, RootCertStore, ServerName};
use rustls_platform_verifier::{self, Verifier};
use serde::Serialize;
Expand Down Expand Up @@ -589,12 +592,18 @@ impl Client {
dot_server: &str,
name_servers: Vec<String>,
) -> Result<IpAddr> {
let dns_config = DNSResolverConfig {
strategy: DNSResolverLookupIpStrategy::Ipv6thenIpv4,
num_conccurent_reqs: 3,
ordering: DNSQueryOrdering::QueryStatistics,
};

let resolver = if !dot_server.is_empty() {
dns::resolver(dot_server, vec![])
dns::resolver2(dot_server, vec![], dns_config)
} else if !name_servers.is_empty() {
dns::resolver("", name_servers)
dns::resolver2("", name_servers, dns_config)
} else {
rs_utilities::dns::resolver("", vec![])
dns::resolver2("", vec![], dns_config)
};

let ip = resolver.await.lookup_first(domain).await?;
Expand Down

0 comments on commit cd473f8

Please sign in to comment.