Skip to content

Commit 6b23ab1

Browse files
Make ProxyType private again
1 parent a155c03 commit 6b23ab1

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

mullvad-encrypted-dns-proxy/src/config/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl std::error::Error for Error {}
3838
/// Type of a proxy configuration. Derived from the 2nd hextet of an IPv6 address in network byte
3939
/// order. E.g. an IPv6 address such as `7f7f:2323::` would have a proxy type value of `0x2323`.
4040
#[derive(PartialEq, Debug, Eq, Hash, Clone)]
41-
pub enum ProxyType {
41+
enum ProxyType {
4242
/// Plain proxy type
4343
Plain,
4444
/// XorV1 - deprecated
@@ -75,8 +75,6 @@ pub struct ProxyConfig {
7575
/// If the proxy requires some obfuscation of the data sent to/received from it,
7676
/// it's represented by an obfuscation config here.
7777
pub obfuscation: Option<ObfuscationConfig>,
78-
79-
pub r#type: ProxyType,
8078
}
8179

8280
#[derive(Debug, Clone, Eq, PartialEq, Hash)]

mullvad-encrypted-dns-proxy/src/config/plain.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ pub fn parse_plain(data: [u8; 12]) -> Result<super::ProxyConfig, super::Error> {
2828
Ok(super::ProxyConfig {
2929
addr,
3030
obfuscation: None,
31-
r#type: super::ProxyType::Plain,
3231
})
3332
}
3433

3534
#[cfg(test)]
3635
mod tests {
3736
use std::net::{Ipv6Addr, SocketAddrV4};
3837

39-
use crate::config::{Error, ProxyConfig, ProxyType};
38+
use crate::config::{Error, ProxyConfig};
4039

4140
#[test]
4241
fn parsing() {
@@ -50,23 +49,20 @@ mod tests {
5049
expected: Ok(ProxyConfig {
5150
addr: "127.0.0.1:1337".parse::<SocketAddrV4>().unwrap(),
5251
obfuscation: None,
53-
r#type: ProxyType::Plain,
5452
}),
5553
},
5654
Test {
5755
input: "2001:100:c0a8:101:bb01::".parse::<Ipv6Addr>().unwrap(),
5856
expected: Ok(ProxyConfig {
5957
addr: "192.168.1.1:443".parse::<SocketAddrV4>().unwrap(),
6058
obfuscation: None,
61-
r#type: ProxyType::Plain,
6259
}),
6360
},
6461
Test {
6562
input: "2001:100:c0a8:101:bb01:404::".parse::<Ipv6Addr>().unwrap(),
6663
expected: Ok(ProxyConfig {
6764
addr: "192.168.1.1:443".parse::<SocketAddrV4>().unwrap(),
6865
obfuscation: None,
69-
r#type: ProxyType::Plain,
7066
}),
7167
},
7268
Test {

mullvad-encrypted-dns-proxy/src/config/xor.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::ProxyType;
21
use core::fmt;
32
use std::net::{Ipv4Addr, SocketAddrV4};
43

@@ -33,7 +32,6 @@ pub fn parse_xor(data: [u8; 12]) -> Result<super::ProxyConfig, super::Error> {
3332
Ok(super::ProxyConfig {
3433
addr,
3534
obfuscation: Some(super::ObfuscationConfig::XorV2(key)),
36-
r#type: ProxyType::XorV2,
3735
})
3836
}
3937

@@ -112,7 +110,7 @@ mod tests {
112110
use std::net::{Ipv6Addr, SocketAddrV4};
113111

114112
use crate::config::xor::{XorKey, XorObfuscator};
115-
use crate::config::{Error, ObfuscationConfig, Obfuscator, ProxyConfig, ProxyType};
113+
use crate::config::{Error, ObfuscationConfig, Obfuscator, ProxyConfig};
116114

117115
#[test]
118116
fn xor_parsing() {
@@ -130,7 +128,6 @@ mod tests {
130128
obfuscation: Some(ObfuscationConfig::XorV2(
131129
XorKey::try_from([0x01, 0x02, 0x03, 0x04, 0x05, 0x06]).unwrap(),
132130
)),
133-
r#type: ProxyType::XorV2,
134131
}),
135132
},
136133
Test {
@@ -142,7 +139,6 @@ mod tests {
142139
obfuscation: Some(ObfuscationConfig::XorV2(
143140
XorKey::try_from([0x01, 0, 0, 0, 0, 0]).unwrap(),
144141
)),
145-
r#type: ProxyType::XorV2,
146142
}),
147143
},
148144
Test {
@@ -154,7 +150,6 @@ mod tests {
154150
obfuscation: Some(ObfuscationConfig::XorV2(
155151
XorKey::try_from([0xff, 0x04, 0x02, 0x04, 0, 0]).unwrap(),
156152
)),
157-
r#type: ProxyType::XorV2,
158153
}),
159154
},
160155
];

mullvad-ios/src/encrypted_dns_proxy.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use crate::ProxyHandle;
22

3-
use mullvad_encrypted_dns_proxy::{
4-
config::{ProxyConfig, ProxyType},
5-
config_resolver, Forwarder,
6-
};
3+
use mullvad_encrypted_dns_proxy::{config::ProxyConfig, config_resolver, Forwarder};
74
use std::{
85
collections::HashSet,
96
io, mem,
@@ -102,7 +99,8 @@ impl EncryptedDnsProxyState {
10299
if let Some(xor_config) = self
103100
.configurations
104101
.iter()
105-
.find(|config| config.r#type == ProxyType::XorV2)
102+
// prefer obfuscated proxy configurations.
103+
.find(|config| config.obfuscation.is_some())
106104
{
107105
self.tried_configurations.insert(xor_config.clone());
108106
return Some(xor_config.clone());

0 commit comments

Comments
 (0)