From 74034c0c0d2a286cfd093b1587d9e297e7ea6e45 Mon Sep 17 00:00:00 2001 From: neevek Date: Sun, 3 Nov 2024 22:23:33 +0800 Subject: [PATCH] support setting DoT or name servers to resolve the server domain --- src/lib.rs | 2 ++ src/quic/quic_client.rs | 3 ++- src/server.rs | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1dc8c5a..42ead7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -335,6 +335,8 @@ pub struct QuicClientConfig { pub local_tcp_server_addr: Option, pub local_udp_server_addr: Option, pub common_cfg: CommonQuicConfig, + pub dot_servers: Vec, + pub name_servers: Vec, } #[derive(Debug, Clone)] diff --git a/src/quic/quic_client.rs b/src/quic/quic_client.rs index 67998f5..e1a9b0e 100644 --- a/src/quic/quic_client.rs +++ b/src/quic/quic_client.rs @@ -71,6 +71,7 @@ impl QuicClient { } else { None }; - // TODO specify DoT or dns servers to resolve the server domain + config.dot_servers = quic_client_config.dot_servers.clone(); + config.dns_servers = quic_client_config.name_servers.clone(); } } diff --git a/src/server.rs b/src/server.rs index c2d8c33..40941df 100644 --- a/src/server.rs +++ b/src/server.rs @@ -359,7 +359,8 @@ impl Server { ) -> Result> { // if we have to forward tcp/udp through quic tunnel, we can directly use the // quic client's tcp/udp entry without creating another layer of traffic relay - let server_addr = &self.config.server_addr; + let cfg = &self.config; + let server_addr = &cfg.server_addr; let (tcp_server_addr, udp_server_addr) = if server_addr.proto == Some(ProtoType::Udp) { (None, server_addr.net_addr.to_socket_addr()) } else if server_addr.proto == Some(ProtoType::Tcp) { @@ -371,12 +372,18 @@ impl Server { ) }; + #[allow(warnings)] + let dot_servers = cfg.dot_server.split(',').map(String::from).collect(); + let name_servers = cfg.name_servers.split(',').map(String::from).collect(); + // with +quic protocols, quic_client will be used to connect to the upstream let quic_client_config = QuicClientConfig { server_addr: quic_server_addr, local_tcp_server_addr: tcp_server_addr, local_udp_server_addr: udp_server_addr, common_cfg: common_quic_config, + dot_servers, + name_servers, }; let mut client = QuicClient::new(quic_client_config);