summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2024-11-30 18:11:48 +0100
committerMarkus Pettersson <markus.pettersson@mullvad.net>2024-12-02 10:40:50 +0100
commitd8e31a9eddc357a32d635ff5967ac61960862021 (patch)
tree615235d8094c7dbefb0dc062125c3f6ca0031350
parente3399d9c39a07c828e4b8252a43d3de6f261ca24 (diff)
downloadmullvadvpn-d8e31a9eddc357a32d635ff5967ac61960862021.tar.xz
mullvadvpn-d8e31a9eddc357a32d635ff5967ac61960862021.zip
Make `EncryptedDNSForwarder::from_stream` infallibe
-rw-r--r--mullvad-api/src/https_client_with_sni.rs3
-rw-r--r--mullvad-encrypted-dns-proxy/src/forwarder.rs8
2 files changed, 6 insertions, 5 deletions
diff --git a/mullvad-api/src/https_client_with_sni.rs b/mullvad-api/src/https_client_with_sni.rs
index 09e198ca3b..09ce493431 100644
--- a/mullvad-api/src/https_client_with_sni.rs
+++ b/mullvad-api/src/https_client_with_sni.rs
@@ -159,7 +159,8 @@ impl InnerConnectionMode {
InnerConnectionMode::EncryptedDnsProxy(proxy_config) => {
let first_hop = SocketAddr::V4(proxy_config.addr);
let make_proxy_stream = |tcp_stream| async {
- EncryptedDNSForwarder::from_stream(&proxy_config, tcp_stream)
+ let forwarder = EncryptedDNSForwarder::from_stream(&proxy_config, tcp_stream);
+ Ok(forwarder)
};
Self::connect_proxied(
first_hop,
diff --git a/mullvad-encrypted-dns-proxy/src/forwarder.rs b/mullvad-encrypted-dns-proxy/src/forwarder.rs
index 0cac1f6072..43ebca5229 100644
--- a/mullvad-encrypted-dns-proxy/src/forwarder.rs
+++ b/mullvad-encrypted-dns-proxy/src/forwarder.rs
@@ -24,7 +24,7 @@ where
S: AsyncRead + AsyncWrite + Unpin,
{
/// Create a [`Forwarder`] with a connected `stream` to an encrypted DNS proxy server
- pub fn from_stream(proxy_config: &crate::config::ProxyConfig, stream: S) -> io::Result<Self> {
+ pub fn from_stream(proxy_config: &crate::config::ProxyConfig, stream: S) -> Self {
let (read_obfuscator, write_obfuscator) =
if let Some(obfuscation_config) = &proxy_config.obfuscation {
(
@@ -35,11 +35,11 @@ where
(None, None)
};
- Ok(Self {
+ Self {
read_obfuscator,
write_obfuscator,
stream,
- })
+ }
}
}
@@ -48,7 +48,7 @@ impl Forwarder<TcpStream> {
/// Create a forwarder that will connect to a given proxy endpoint.
pub async fn connect(proxy_config: &crate::config::ProxyConfig) -> io::Result<Self> {
let server_connection = TcpStream::connect(proxy_config.addr).await?;
- Self::from_stream(proxy_config, server_connection)
+ Ok(Self::from_stream(proxy_config, server_connection))
}
/// Forwards traffic from the client stream to the remote proxy, obfuscating and deobfuscating