(&self)
| 361 | } |
| 362 | |
| 363 | pub fn update(&self) { |
| 364 | let now = now(); |
| 365 | let mut new_params_set = vec![]; |
| 366 | let previous_params = { |
| 367 | let params_set = self.globals.dnscrypt_encryption_params_set.read(); |
| 368 | for params in &**params_set { |
| 369 | if params.dnscrypt_cert().ts_end() >= now { |
| 370 | new_params_set.push(params.clone()); |
| 371 | } |
| 372 | } |
| 373 | params_set.last().cloned() |
| 374 | }; |
| 375 | let active_params = DNSCryptEncryptionParams::new( |
| 376 | &self.globals.provider_kp, |
| 377 | self.globals.key_cache_capacity, |
| 378 | previous_params, |
| 379 | self.globals.pq_enabled, |
| 380 | ); |
| 381 | for params in active_params { |
| 382 | new_params_set.push(Arc::new(params)); |
| 383 | } |
| 384 | let state = State { |
| 385 | provider_kp: self.globals.provider_kp.clone(), |
| 386 | dnscrypt_encryption_params_set: new_params_set.iter().map(|x| (**x).clone()).collect(), |
| 387 | }; |
| 388 | let state_file = self.globals.state_file.to_path_buf(); |
| 389 | self.globals.runtime_handle.spawn(async move { |
| 390 | let _ = state.async_save(state_file).await; |
| 391 | }); |
| 392 | *self.globals.dnscrypt_encryption_params_set.write() = Arc::new(new_params_set); |
| 393 | debug!("New certificate issued"); |
| 394 | } |
| 395 | |
| 396 | pub async fn run(self) { |
| 397 | let mut fut_interval = tokio::time::interval(std::time::Duration::from_secs(u64::from( |
no test coverage detected