Skip to content

Commit

Permalink
support setting DoT or name servers to resolve the server domain
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Nov 3, 2024
1 parent c6fa589 commit 74034c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ pub struct QuicClientConfig {
pub local_tcp_server_addr: Option<SocketAddr>,
pub local_udp_server_addr: Option<SocketAddr>,
pub common_cfg: CommonQuicConfig,
pub dot_servers: Vec<String>,
pub name_servers: Vec<String>,
}

#[derive(Debug, Clone)]
Expand Down
3 changes: 2 additions & 1 deletion src/quic/quic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
9 changes: 8 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ impl Server {
) -> Result<JoinHandle<()>> {
// 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) {
Expand All @@ -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);
Expand Down

0 comments on commit 74034c0

Please sign in to comment.