summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-08-22 07:40:56 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-08-22 08:18:40 -0300
commit2d0d03837724115e2d5e828562aeddd9590edd13 (patch)
tree030dd39ac257cf0a1f0e5287fc55ca0866c98ddf
parent0fa07495d6a36af821e799e8dbccd7e4f34053e1 (diff)
downloadmullvadvpn-2d0d03837724115e2d5e828562aeddd9590edd13.tar.xz
mullvadvpn-2d0d03837724115e2d5e828562aeddd9590edd13.zip
Revert "Upgrade tokio-timer"
This reverts commit 380f8cd8ec9d2d37801f9cc8f2b77216feed8ea6.
-rw-r--r--Cargo.lock12
-rw-r--r--mullvad-daemon/Cargo.toml2
-rw-r--r--mullvad-daemon/src/relays.rs21
3 files changed, 22 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7a41a750d2..bb3e67aa73 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -863,7 +863,7 @@ dependencies = [
"talpid-ipc 0.1.0",
"talpid-types 0.1.0",
"tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"windows-service 0.1.0 (git+https://github.com/mullvad/windows-service-rs.git?rev=55c5dfb372e6b3f5607a3159c5388d27b6b84ff6)",
@@ -1770,6 +1770,15 @@ dependencies = [
[[package]]
name = "tokio-timer"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "tokio-timer"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -2201,6 +2210,7 @@ source = "git+https://github.com/mullvad/rust-openssl#4dbd237fe1f6454d8a0042ccf4
"checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162"
"checksum tokio-tcp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4c329b47f071eb8a746040465fa751bd95e4716e98daef6a9b4e434c17d565"
"checksum tokio-threadpool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24ab84f574027b0e875378f31575cf175360891919e93a3490f07e76e00e4efb"
+"checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc"
"checksum tokio-timer 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1c76b4e97a4f61030edff8bd272364e4f731b9f54c7307eb4eb733c3926eb96a"
"checksum tokio-udp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43eb534af6e8f37d43ab1b612660df14755c42bd003c5f8d2475ee78cc4600c0"
"checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2"
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index 42d4911d01..bd6add0daf 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -23,7 +23,7 @@ uuid = { version = "0.6", features = ["v4"] }
lazy_static = "1.0"
rand = "0.5"
tokio-core = "0.1"
-tokio-timer = "0.2"
+tokio-timer = "0.1"
regex = "1.0"
mullvad-ipc-client = { path = "../mullvad-ipc-client" }
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs
index 6d33c8900f..4f733307c8 100644
--- a/mullvad-daemon/src/relays.rs
+++ b/mullvad-daemon/src/relays.rs
@@ -17,11 +17,12 @@ use std::fs::File;
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::sync::{mpsc, Arc, Mutex, MutexGuard};
-use std::time::{self, Duration, Instant, SystemTime};
+use std::time::{self, Duration, SystemTime};
use std::{io, thread};
+use rand::distributions::{IndependentSample, Range};
use rand::{self, Rng, ThreadRng};
-use tokio_timer::{Deadline, DeadlineError};
+use tokio_timer::{TimeoutError, Timer};
const RELAYS_FILENAME: &str = "relays.json";
const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(15);
@@ -38,12 +39,9 @@ error_chain! {
}
}
-impl From<DeadlineError<Error>> for Error {
- fn from(e: DeadlineError<Error>) -> Error {
- match e.into_inner() {
- Some(inner_e) => inner_e,
- None => Error::from_kind(ErrorKind::DownloadTimeoutError),
- }
+impl<F> From<TimeoutError<F>> for Error {
+ fn from(_: TimeoutError<F>) -> Error {
+ Error::from_kind(ErrorKind::DownloadTimeoutError)
}
}
@@ -310,7 +308,7 @@ impl RelaySelector {
None
} else {
// Pick a random number in the range 0 - total_weight. This choses the relay.
- let mut i: u64 = self.rng.gen_range(0, total_weight + 1);
+ let mut i: u64 = Range::new(0, total_weight + 1).ind_sample(&mut self.rng);
Some(
relays
.iter()
@@ -437,12 +435,13 @@ impl RelayListUpdater {
fn download_relay_list(&mut self) -> Result<RelayList> {
info!("Downloading list of relays...");
- let timeout_instant = Instant::now() + DOWNLOAD_TIMEOUT;
let download_future = self
.rpc_client
.relay_list()
.map_err(|e| Error::with_chain(e, ErrorKind::DownloadError));
- let relay_list = Deadline::new(download_future, timeout_instant).wait()?;
+ let relay_list = Timer::default()
+ .timeout(download_future, DOWNLOAD_TIMEOUT)
+ .wait()?;
Ok(relay_list)
}