fix dns query (#864)

1. dns resolver should be global unique so dns cache can work. avoid dns query influence hole punching.
2. when system dns failed, fallback to hickory dns.
This commit is contained in:
Sijie.Sun
2025-05-23 10:34:28 +08:00
committed by GitHub
parent 83d1ecc4da
commit 5a2fd4465c
14 changed files with 201 additions and 110 deletions

View File

@@ -548,7 +548,8 @@ impl WgTunnelListener {
impl TunnelListener for WgTunnelListener {
async fn listen(&mut self) -> Result<(), super::TunnelError> {
let addr =
check_scheme_and_get_socket_addr::<SocketAddr>(&self.addr, "wg", IpVersion::Both)?;
check_scheme_and_get_socket_addr::<SocketAddr>(&self.addr, "wg", IpVersion::Both)
.await?;
let socket2_socket = socket2::Socket::new(
socket2::Domain::for_address(addr),
socket2::Type::DGRAM,
@@ -705,7 +706,8 @@ impl super::TunnelConnector for WgTunnelConnector {
&self.addr,
"wg",
self.ip_version,
)?;
)
.await?;
if addr.is_ipv6() {
return self.connect_with_ipv6(addr).await;