Skip to content

Commit

Permalink
update rand
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Feb 14, 2025
1 parent 436ca17 commit 9804a66
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 21 deletions.
85 changes: 68 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ markdown = { version = "1.0.0-alpha.15", features = ["log"] }
password-hash = "0.5.0"
argon2 = "0.5.0"
actix-web-httpauth = "0.8.0"
rand = "0.8.5"
rand = "0.9.0"
actix-multipart = "0.7.2"
base64 = "0.22"
rustls-acme = "0.9.2"
Expand Down
4 changes: 2 additions & 2 deletions src/webserver/database/sqlpage_functions/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ pub(crate) async fn random_string(len: usize) -> anyhow::Result<String> {

/// Returns a random string of the specified length.
pub(crate) fn random_string_sync(len: usize) -> String {
use rand::{distributions::Alphanumeric, Rng};
password_hash::rand_core::OsRng
use rand::{distr::Alphanumeric, Rng};
rand::rng()
.sample_iter(&Alphanumeric)
.take(len)
.map(char::from)
Expand Down
2 changes: 1 addition & 1 deletion src/webserver/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn anyhow_err_to_actix_resp(e: &anyhow::Error, env: app_config::DevOrProd) -> Ht
resp.status(StatusCode::TOO_MANY_REQUESTS)
.insert_header((
header::RETRY_AFTER,
header::HeaderValue::from(rand::thread_rng().gen_range(1..=15)),
header::HeaderValue::from(rand::rng().random_range(1..=15)),
))
.body("The database is currently too busy to handle your request. Please try again later.\n\n".to_owned() + &body)
} else {
Expand Down

0 comments on commit 9804a66

Please sign in to comment.