summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-05-08 11:29:31 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-05-08 17:22:57 +0200
commit852b72f7c47bc6a24968a3c0b948d809ec09487a (patch)
treeaa920f685bd007e122b120684fb05de16c26a8e6
parent4ebb74586ae0e53cdbe997aa950129c7d2e2c639 (diff)
downloadmullvadvpn-852b72f7c47bc6a24968a3c0b948d809ec09487a.tar.xz
mullvadvpn-852b72f7c47bc6a24968a3c0b948d809ec09487a.zip
Ensure country codes, city codes, and hostnames are lowercase in relay list
-rw-r--r--mullvad-rpc/src/relay_list.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/mullvad-rpc/src/relay_list.rs b/mullvad-rpc/src/relay_list.rs
index cd1d33f576..5e98d4f2c3 100644
--- a/mullvad-rpc/src/relay_list.rs
+++ b/mullvad-rpc/src/relay_list.rs
@@ -69,12 +69,12 @@ impl ServerRelayList {
for (code, location) in locations.into_iter() {
match split_location_code(&code) {
Some((country_code, city_code)) => {
+ let country_code = country_code.to_lowercase();
+ let city_code = city_code.to_lowercase();
let country = countries
- .entry(country_code.to_string())
- .or_insert_with(|| location_to_country(&location, country_code.to_owned()));
- country
- .cities
- .push(location_to_city(&location, city_code.to_owned()));
+ .entry(country_code.clone())
+ .or_insert_with(|| location_to_country(&location, country_code));
+ country.cities.push(location_to_city(&location, city_code));
}
None => {
log::error!("Bad location code - {}", code);
@@ -102,7 +102,8 @@ impl ServerRelayList {
openvpn: OpenVpn,
) {
let openvpn_endpoint_data = openvpn.ports;
- for openvpn_relay in openvpn.relays.into_iter() {
+ for mut openvpn_relay in openvpn.relays.into_iter() {
+ openvpn_relay.to_lower();
if let Some((country_code, city_code)) = split_location_code(&openvpn_relay.location) {
if let Some(country) = countries.get_mut(country_code) {
if let Some(city) = country
@@ -155,7 +156,8 @@ impl ServerRelayList {
public_key,
};
- for wireguard_relay in relays {
+ for mut wireguard_relay in relays {
+ wireguard_relay.relay.to_lower();
if let Some((country_code, city_code)) =
split_location_code(&wireguard_relay.relay.location)
{
@@ -205,7 +207,8 @@ impl ServerRelayList {
shadowsocks,
} = bridges;
- for bridge_relay in relays {
+ for mut bridge_relay in relays {
+ bridge_relay.to_lower();
if let Some((country_code, city_code)) = split_location_code(&bridge_relay.location) {
if let Some(country) = countries.get_mut(country_code) {
if let Some(city) = country
@@ -314,6 +317,13 @@ struct Relay {
include_in_country: bool,
}
+impl Relay {
+ fn to_lower(&mut self) {
+ self.hostname = self.hostname.to_lowercase();
+ self.location = self.location.to_lowercase();
+ }
+}
+
#[derive(Debug, serde::Deserialize)]
struct Wireguard {
port_ranges: Vec<(u16, u16)>,