diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-12-11 15:55:46 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-12-17 12:30:15 +0100 |
| commit | 06576e6d3c8a5797d8c266758363b11fd472368d (patch) | |
| tree | 4c95e3ad0774fba1a546eab33a4d6e560e046873 | |
| parent | b8416a2c68034cf0b353c34cc9425e2945fd78f0 (diff) | |
| download | mullvadvpn-06576e6d3c8a5797d8c266758363b11fd472368d.tar.xz mullvadvpn-06576e6d3c8a5797d8c266758363b11fd472368d.zip | |
Use tokio_timer rather than Delay (compatibility)
| -rw-r--r-- | mullvad-daemon/src/wireguard.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/mullvad-daemon/src/wireguard.rs b/mullvad-daemon/src/wireguard.rs index 33a7fc25d9..7654bed061 100644 --- a/mullvad-daemon/src/wireguard.rs +++ b/mullvad-daemon/src/wireguard.rs @@ -7,18 +7,18 @@ pub use mullvad_types::wireguard::*; use std::{ cmp, sync::mpsc, - time::{Duration, Instant}, + time::Duration, }; pub use talpid_types::net::wireguard::{ ConnectionConfig, PrivateKey, TunnelConfig, TunnelParameters, }; use talpid_types::ErrorExt; -use tokio::timer::Delay; use tokio_core::reactor::Remote; use tokio_retry::{ strategy::{jitter, ExponentialBackoff}, RetryIf, }; +use tokio_timer; const TOO_MANY_KEYS_ERROR_CODE: i64 = -703; /// Default automatic key rotation (in hours) @@ -37,7 +37,7 @@ pub enum Error { RpcError(#[error(source)] jsonrpc_client_core::Error), #[error(display = "Account already has maximum number of keys")] TooManyKeys, - #[error(display = "Failed to create Delay object")] + #[error(display = "Failed to create timer object")] Delay, #[error(display = "Failed to create key rotation scheduler")] CreateAutomaticKeyRotationScheduler, @@ -78,12 +78,10 @@ impl Future for KeyRotationScheduler { _ => { log::error!("Automatic key rotation failed; retrying"); self.key_request_rx = None; - self.delay = Box::new( - Delay::new( - Instant::now() + Duration::from_secs(AUTOMATIC_ROTATION_RETRY_DELAY), - ) - .map_err(|_| ()), - ); + + self.delay = Box::new(tokio_timer::wheel().build().sleep( + Duration::from_secs(AUTOMATIC_ROTATION_RETRY_DELAY) + ).map_err(|_| ())); } } } @@ -165,7 +163,10 @@ impl KeyRotationScheduler { delay = cmp::max(Duration::from_secs(0), cmp::min(remaining_time, delay)); } - Box::new(Delay::new(Instant::now() + delay).map_err(|_| ())) + Box::new( + tokio_timer::wheel().build().sleep(delay) + .map_err(|_| ()) + ) } } |
