From 5a7bade476d9fa91c7c59f858d9481097b819bf9 Mon Sep 17 00:00:00 2001 From: June Date: Tue, 1 Aug 2023 14:48:50 -1000 Subject: [PATCH] update base64 to 0.21.2 Signed-off-by: June --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/api/client_server/voip.rs | 3 ++- src/service/globals/mod.rs | 4 +++- src/service/sending/mod.rs | 24 +++++++++++------------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ddf4875..cdf18211 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -368,7 +368,7 @@ dependencies = [ "async-trait", "axum", "axum-server", - "base64 0.13.1", + "base64 0.21.2", "bytes", "clap", "crossbeam", diff --git a/Cargo.toml b/Cargo.toml index 7a157f4c..9828162a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ thiserror = "1.0.40" # Used to generate thumbnails for images image = { version = "0.24.6", default-features = false, features = ["jpeg", "png", "gif"] } # Used to encode server public key -base64 = "0.13.1" +base64 = "0.21.2" # Used when hashing the state ring = "0.16.20" # Used when querying the SRV record of other servers diff --git a/src/api/client_server/voip.rs b/src/api/client_server/voip.rs index 4990c17c..f0d91f71 100644 --- a/src/api/client_server/voip.rs +++ b/src/api/client_server/voip.rs @@ -1,4 +1,5 @@ use crate::{services, Result, Ruma}; +use base64::{engine::general_purpose, Engine as _}; use hmac::{Hmac, Mac}; use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch}; use sha1::Sha1; @@ -28,7 +29,7 @@ pub async fn turn_server_route( .expect("HMAC can take key of any size"); mac.update(username.as_bytes()); - let password: String = base64::encode_config(mac.finalize().into_bytes(), base64::STANDARD); + let password: String = general_purpose::STANDARD.encode(mac.finalize().into_bytes()); (username, password) } else { diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 875a4574..e9bd0da7 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -31,6 +31,8 @@ use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore}; use tracing::{error, info}; use trust_dns_resolver::TokioAsyncResolver; +use base64::{engine::general_purpose, Engine as _}; + type WellKnownMap = HashMap; type TlsNameMap = HashMap, u16)>; type RateLimitState = (Instant, u32); // Time if last failed try, number of failed tries @@ -367,7 +369,7 @@ impl Service { let mut r = PathBuf::new(); r.push(self.config.database_path.clone()); r.push("media"); - r.push(base64::encode_config(key, base64::URL_SAFE_NO_PAD)); + r.push(general_purpose::URL_SAFE_NO_PAD.encode(key)); r } diff --git a/src/service/sending/mod.rs b/src/service/sending/mod.rs index 14d83be3..b4411444 100644 --- a/src/service/sending/mod.rs +++ b/src/service/sending/mod.rs @@ -18,6 +18,8 @@ use crate::{ use federation::transactions::send_transaction_message; use futures_util::{stream::FuturesUnordered, StreamExt}; +use base64::{engine::general_purpose, Engine as _}; + use ruma::{ api::{ appservice, @@ -497,17 +499,14 @@ impl Service { })?, appservice::event::push_events::v1::Request { events: pdu_jsons, - txn_id: (&*base64::encode_config( - calculate_hash( - &events - .iter() - .map(|e| match e { - SendingEventType::Edu(b) | SendingEventType::Pdu(b) => &**b, - }) - .collect::>(), - ), - base64::URL_SAFE_NO_PAD, - )) + txn_id: (&*general_purpose::URL_SAFE_NO_PAD.encode(calculate_hash( + &events + .iter() + .map(|e| match e { + SendingEventType::Edu(b) | SendingEventType::Pdu(b) => &**b, + }) + .collect::>(), + ))) .into(), }, ) @@ -642,7 +641,7 @@ impl Service { pdus: pdu_jsons, edus: edu_jsons, origin_server_ts: MilliSecondsSinceUnixEpoch::now(), - transaction_id: (&*base64::encode_config( + transaction_id: (&*general_purpose::URL_SAFE_NO_PAD.encode( calculate_hash( &events .iter() @@ -651,7 +650,6 @@ impl Service { }) .collect::>(), ), - base64::URL_SAFE_NO_PAD, )) .into(), },