Add support for custom dns resolver on server

This commit is contained in:
Σrebe - Romain GERARD 2023-12-19 22:41:11 +01:00
parent d1de41646f
commit d456c67f19
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
8 changed files with 354 additions and 26 deletions

View file

@ -67,7 +67,13 @@ async fn from_query(
match jwt.claims.p {
LocalProtocol::Udp { timeout, .. } => {
let host = Host::parse(&jwt.claims.r)?;
let cnx = udp::connect(&host, jwt.claims.rp, timeout.unwrap_or(Duration::from_secs(10))).await?;
let cnx = udp::connect(
&host,
jwt.claims.rp,
timeout.unwrap_or(Duration::from_secs(10)),
&server_config.dns_resolver,
)
.await?;
Ok((
LocalProtocol::Udp { timeout: None },
host,
@ -79,9 +85,15 @@ async fn from_query(
LocalProtocol::Tcp => {
let host = Host::parse(&jwt.claims.r)?;
let port = jwt.claims.rp;
let (rx, tx) = tcp::connect(&host, port, server_config.socket_so_mark, Duration::from_secs(10))
.await?
.into_split();
let (rx, tx) = tcp::connect(
&host,
port,
server_config.socket_so_mark,
Duration::from_secs(10),
&server_config.dns_resolver,
)
.await?
.into_split();
Ok((jwt.claims.p, host, port, Box::pin(rx), Box::pin(tx)))
}