Add support for custom dns resolver on server
This commit is contained in:
parent
d1de41646f
commit
d456c67f19
8 changed files with 354 additions and 26 deletions
|
@ -2,6 +2,7 @@ pub mod client;
|
|||
mod io;
|
||||
pub mod server;
|
||||
|
||||
use crate::dns::DnsResolver;
|
||||
use crate::{tcp, tls, LocalProtocol, LocalToRemote, WsClientConfig};
|
||||
use async_trait::async_trait;
|
||||
use bb8::ManageConnection;
|
||||
|
@ -126,7 +127,7 @@ impl ManageConnection for WsClientConfig {
|
|||
let tcp_stream = if let Some(http_proxy) = &self.http_proxy {
|
||||
tcp::connect_with_http_proxy(http_proxy, host, *port, so_mark, timeout).await?
|
||||
} else {
|
||||
tcp::connect(host, *port, so_mark, timeout).await?
|
||||
tcp::connect(host, *port, so_mark, timeout, &DnsResolver::System).await?
|
||||
};
|
||||
|
||||
match &self.tls {
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue