diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-02-11 16:36:43 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-02-15 19:18:32 +0100 |
| commit | a26f1b73493f5ca2a866de15158cc4f987b82acd (patch) | |
| tree | 9ad9ca9b7fd22cb0d184f11f239ad4170e879f39 | |
| parent | 7dd8c0d8b8a1c0712887f09cd9708961a8516ea2 (diff) | |
| download | mullvadvpn-a26f1b73493f5ca2a866de15158cc4f987b82acd.tar.xz mullvadvpn-a26f1b73493f5ca2a866de15158cc4f987b82acd.zip | |
Set If-None-Match header attribute when requesting relay list
| -rw-r--r-- | mullvad-daemon/src/relays.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index ee53b7dde2..3bb1c0ee9c 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -140,6 +140,10 @@ impl ParsedRelays { pub fn relays(&self) -> &Vec<Relay> { &self.relays } + + pub fn tag(&self) -> Option<&str> { + self.locations.etag.as_deref() + } } pub struct RelaySelector { @@ -813,7 +817,8 @@ impl RelayListUpdater { futures::select! { _check_update = check_interval.next() => { if download_future.is_terminated() && self.should_update() { - download_future = Box::pin(Self::download_relay_list(self.rpc_client.clone()).fuse()); + let tag = self.parsed_relays.lock().tag().map(|tag| tag.to_string()); + download_future = Box::pin(Self::download_relay_list(self.rpc_client.clone(), tag).fuse()); self.earliest_next_try = Instant::now() + UPDATE_INTERVAL; } }, @@ -876,8 +881,9 @@ impl RelayListUpdater { fn download_relay_list( rpc_handle: RelayListProxy, + tag: Option<String>, ) -> impl Future<Output = Result<Option<RelayList>, mullvad_rpc::rest::Error>> + 'static { - let download_futures = move || rpc_handle.relay_list(None); + let download_futures = move || rpc_handle.relay_list(tag.clone()); let exponential_backoff = ExponentialBackoff::from_millis(EXPONENTIAL_BACKOFF_DELAY_MS) .factor(EXPONENTIAL_BACKOFF_FACTOR) |
