summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2022-04-06 16:46:37 +0200
committerDavid Lönnhager <david.l@mullvad.net>2022-04-26 10:41:36 +0200
commit59524b645d6a363ec681b7d4758398c2d8c5d6bb (patch)
tree6c9e248699321063fe9d8f0d3e95b96a18c36569
parentbc686e487e4d0eb48d7d884bb74f5d30130d60d3 (diff)
downloadmullvadvpn-59524b645d6a363ec681b7d4758398c2d8c5d6bb.tar.xz
mullvadvpn-59524b645d6a363ec681b7d4758398c2d8c5d6bb.zip
Move the relay selector to its own crate
-rw-r--r--Cargo.lock23
-rw-r--r--Cargo.toml1
-rw-r--r--mullvad-daemon/Cargo.toml1
-rw-r--r--mullvad-daemon/src/lib.rs8
-rw-r--r--mullvad-relay-selector/Cargo.toml29
-rw-r--r--mullvad-relay-selector/src/lib.rs (renamed from mullvad-daemon/src/relays/mod.rs)4
-rw-r--r--mullvad-relay-selector/src/matcher.rs (renamed from mullvad-daemon/src/relays/matcher.rs)0
-rw-r--r--mullvad-relay-selector/src/updater.rs (renamed from mullvad-daemon/src/relays/updater.rs)0
8 files changed, 59 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 664020ac7e..cbd5f6981c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1713,6 +1713,7 @@ dependencies = [
"mullvad-api",
"mullvad-management-interface",
"mullvad-paths",
+ "mullvad-relay-selector",
"mullvad-types",
"nix 0.23.1",
"parking_lot 0.11.2",
@@ -1818,6 +1819,28 @@ dependencies = [
]
[[package]]
+name = "mullvad-relay-selector"
+version = "0.1.0"
+dependencies = [
+ "chrono",
+ "err-derive",
+ "futures",
+ "ipnetwork",
+ "lazy_static",
+ "log",
+ "mullvad-api",
+ "mullvad-types",
+ "parking_lot 0.11.2",
+ "rand 0.7.3",
+ "serde",
+ "serde_json",
+ "talpid-core",
+ "talpid-types",
+ "tokio",
+ "tokio-stream",
+]
+
+[[package]]
name = "mullvad-setup"
version = "2022.1.0"
dependencies = [
diff --git a/Cargo.toml b/Cargo.toml
index f40610b778..75bbc7d0ae 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ members = [
"mullvad-problem-report",
"mullvad-jni",
"mullvad-paths",
+ "mullvad-relay-selector",
"mullvad-types",
"mullvad-api",
"mullvad-exclude",
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index f970250385..81518397f9 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -30,6 +30,7 @@ tokio-stream = "0.1"
uuid = { version = "0.8", features = ["v4"] }
mullvad-paths = { path = "../mullvad-paths" }
+mullvad-relay-selector = { path = "../mullvad-relay-selector" }
mullvad-types = { path = "../mullvad-types" }
mullvad-api = { path = "../mullvad-api" }
talpid-core = { path = "../talpid-core" }
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 8313d79373..dd53781821 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -15,7 +15,6 @@ pub mod logging;
#[cfg(not(target_os = "android"))]
pub mod management_interface;
mod migrations;
-mod relays;
#[cfg(not(target_os = "android"))]
pub mod rpc_uniqueness_check;
pub mod runtime;
@@ -35,6 +34,7 @@ use mullvad_api::{
availability::ApiAvailabilityHandle,
proxy::{ApiConnectionMode, ProxyConfig},
};
+use mullvad_relay_selector::{RelaySelector, RelaySelectorResult};
use mullvad_types::{
account::{AccountData, AccountToken, VoucherSubmission},
device::{Device, DeviceConfig, DeviceData, DeviceEvent, DeviceId, RemoveDeviceEvent},
@@ -592,7 +592,7 @@ pub struct Daemon<L: EventListener> {
api_runtime: mullvad_api::Runtime,
api_handle: mullvad_api::rest::MullvadRestHandle,
version_updater_handle: version_check::VersionUpdaterHandle,
- relay_selector: relays::RelaySelector,
+ relay_selector: RelaySelector,
last_generated_relays: Option<LastSelectedRelays>,
app_version_info: Option<AppVersionInfo>,
shutdown_tasks: Vec<Pin<Box<dyn Future<Output = ()>>>>,
@@ -754,7 +754,7 @@ where
relay_list_listener.notify_relay_list(relay_list.clone());
};
- let relay_selector = relays::RelaySelector::new(
+ let relay_selector = RelaySelector::new(
api_handle.clone(),
on_relay_list_update,
&resource_dir,
@@ -1053,7 +1053,7 @@ where
retry_attempt,
)
.ok();
- if let Some(relays::RelaySelectorResult {
+ if let Some(RelaySelectorResult {
exit_relay,
entry_relay,
endpoint,
diff --git a/mullvad-relay-selector/Cargo.toml b/mullvad-relay-selector/Cargo.toml
new file mode 100644
index 0000000000..24e8491c3d
--- /dev/null
+++ b/mullvad-relay-selector/Cargo.toml
@@ -0,0 +1,29 @@
+[package]
+name = "mullvad-relay-selector"
+version = "0.1.0"
+authors = ["Mullvad VPN"]
+description = "Mullvad VPN relay selector"
+license = "GPL-3.0"
+edition = "2021"
+publish = false
+
+[dependencies]
+chrono = "0.4.19"
+err-derive = "0.3.1"
+futures = "0.3"
+ipnetwork = "0.16"
+log = "0.4"
+parking_lot = "0.11"
+rand = "0.7"
+serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
+tokio = { version = "1.8", features = ["fs", "io-util", "time"] }
+tokio-stream = "0.1"
+
+talpid-core = { path = "../talpid-core" }
+talpid-types = { path = "../talpid-types" }
+mullvad-api = { path = "../mullvad-api" }
+mullvad-types = { path = "../mullvad-types" }
+
+[dev-dependencies]
+lazy_static = "1.0"
diff --git a/mullvad-daemon/src/relays/mod.rs b/mullvad-relay-selector/src/lib.rs
index 1aa8001ba0..081ecdced7 100644
--- a/mullvad-daemon/src/relays/mod.rs
+++ b/mullvad-relay-selector/src/lib.rs
@@ -31,11 +31,9 @@ use talpid_types::{
ErrorExt,
};
-use crate::relays::updater::RelayListUpdater;
-
use self::{
matcher::{RelayMatcher, TunnelMatcher, WireguardMatcher},
- updater::RelayListUpdaterHandle,
+ updater::{RelayListUpdater, RelayListUpdaterHandle},
};
mod matcher;
diff --git a/mullvad-daemon/src/relays/matcher.rs b/mullvad-relay-selector/src/matcher.rs
index 7d75141b16..7d75141b16 100644
--- a/mullvad-daemon/src/relays/matcher.rs
+++ b/mullvad-relay-selector/src/matcher.rs
diff --git a/mullvad-daemon/src/relays/updater.rs b/mullvad-relay-selector/src/updater.rs
index 35f431125a..35f431125a 100644
--- a/mullvad-daemon/src/relays/updater.rs
+++ b/mullvad-relay-selector/src/updater.rs