Skip to content

Commit

Permalink
update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq committed Feb 5, 2025
1 parent a3c44be commit e5a0b15
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 91 deletions.
173 changes: 112 additions & 61 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ edition = "2021"
#
anyhow = "1.0"
thiserror = "2.0"
rand = "0.8"
rand = { version = "0.9", default-features = false, features = ["thread_rng"] }
fastrand = "2.3"
memchr = "2.4"
constant_time_eq = "0.3"
Expand Down Expand Up @@ -114,7 +114,7 @@ ip_network_table = "0.2"
radix_trie = "0.2"
fixedbitset = "0.5"
bitflags = "2.8"
lru = { version = "0.12", default-features = false }
lru = { version = "0.13", default-features = false }
#
blake3 = { version = "1.5", default-features = false }
hex = "0.4.2"
Expand Down
4 changes: 3 additions & 1 deletion g3bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ fn build_cli_args() -> Command {

fn main() -> anyhow::Result<()> {
#[cfg(feature = "openssl-probe")]
openssl_probe::init_ssl_cert_env_vars();
unsafe {
openssl_probe::init_openssl_env_vars();
}
openssl::init();

#[cfg(feature = "rustls-ring")]
Expand Down
4 changes: 3 additions & 1 deletion g3keymess/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use g3keymess::opts::ProcArgs;

fn main() -> anyhow::Result<()> {
#[cfg(feature = "openssl-probe")]
openssl_probe::init_ssl_cert_env_vars();
unsafe {
openssl_probe::init_openssl_env_vars();
}
openssl::init();

let Some(proc_args) =
Expand Down
4 changes: 3 additions & 1 deletion g3mkcert/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const ARG_GROUP_ALGORITHM: &str = "algorithm";

fn main() -> anyhow::Result<()> {
#[cfg(feature = "openssl-probe")]
openssl_probe::init_ssl_cert_env_vars();
unsafe {
openssl_probe::init_openssl_env_vars();
}
openssl::init();

let args = build_cli_args().get_matches();
Expand Down
4 changes: 2 additions & 2 deletions g3proxy/src/audit/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ impl AuditHandle {
}

pub(crate) fn do_task_audit(&self) -> bool {
use rand::distributions::Distribution;
use rand::distr::Distribution;

let mut rng = rand::thread_rng();
let mut rng = rand::rng();
self.auditor_config.task_audit_ratio.sample(&mut rng)
}
}
2 changes: 1 addition & 1 deletion g3proxy/src/config/audit/auditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::sync::Arc;

use anyhow::{anyhow, Context};
use rand::distributions::Bernoulli;
use rand::distr::Bernoulli;
use yaml_rust::{yaml, Yaml};

use g3_cert_agent::CertAgentConfig;
Expand Down
4 changes: 2 additions & 2 deletions g3proxy/src/config/auth/audit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

use rand::distributions::{Bernoulli, Distribution};
use rand::distr::{Bernoulli, Distribution};

mod json;
mod yaml;
Expand All @@ -41,7 +41,7 @@ impl Default for UserAuditConfig {
impl UserAuditConfig {
pub(crate) fn do_task_audit(&self) -> Option<bool> {
if let Some(ratio) = &self.task_audit_ratio {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
Some(ratio.sample(&mut rng))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion g3proxy/src/config/escaper/direct_float/bind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl BindSet {
self.unnamed
.iter()
.chain(self.named.values())
.choose(&mut rand::thread_rng())
.choose(&mut rand::rng())
.cloned()
}

Expand Down
2 changes: 1 addition & 1 deletion g3proxy/src/escape/proxy_float/peer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl PeerSet {
.iter()
.chain(self.named.values())
.filter(|p| !p.is_expired())
.choose(&mut rand::thread_rng())
.choose(&mut rand::rng())
.cloned()
}

Expand Down
4 changes: 2 additions & 2 deletions g3proxy/src/escape/trick_float/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::sync::Arc;

use anyhow::anyhow;
use async_trait::async_trait;
use rand::seq::SliceRandom;
use rand::seq::IndexedRandom;

use g3_daemon::stat::remote::ArcTcpConnectionTaskRemoteStats;
use g3_types::metrics::NodeName;
Expand Down Expand Up @@ -90,7 +90,7 @@ impl TrickFloatEscaper {
}

fn random_next(&self) -> anyhow::Result<ArcEscaper> {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let escaper = self
.next_nodes
.choose_weighted(&mut rng, |escaper| escaper._trick_float_weight())
Expand Down
4 changes: 3 additions & 1 deletion g3proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use g3proxy::opts::ProcArgs;

fn main() -> anyhow::Result<()> {
#[cfg(feature = "openssl-probe")]
openssl_probe::init_ssl_cert_env_vars();
unsafe {
openssl_probe::init_openssl_env_vars();
}
openssl::init();

#[cfg(feature = "rustls-ring")]
Expand Down
4 changes: 3 additions & 1 deletion g3tiles/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use g3tiles::opts::ProcArgs;

fn main() -> anyhow::Result<()> {
#[cfg(feature = "openssl-probe")]
openssl_probe::init_ssl_cert_env_vars();
unsafe {
openssl_probe::init_openssl_env_vars();
}
openssl::init();

#[cfg(feature = "rustls-ring")]
Expand Down
11 changes: 2 additions & 9 deletions lib/g3-daemon/src/server/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@
use std::sync::OnceLock;

use chrono::{DateTime, Utc};
use rand::rngs::OsRng;
use uuid::{v1::Context, Timestamp, Uuid};

static UUID_CONTEXT: OnceLock<Context> = OnceLock::new();
static UUID_NODE_ID: OnceLock<[u8; 6]> = OnceLock::new();

pub fn generate_uuid(time: &DateTime<Utc>) -> Uuid {
let context = UUID_CONTEXT.get_or_init(|| {
use rand::Rng;

Context::new(OsRng.gen())
});
let context = UUID_CONTEXT.get_or_init(|| Context::new(rand::random()));
let node_id = UUID_NODE_ID.get_or_init(|| {
use rand::RngCore;

let mut bytes = [0u8; 6];
OsRng.fill_bytes(&mut bytes);
rand::fill(&mut bytes);
bytes
});

Expand Down
2 changes: 1 addition & 1 deletion lib/g3-json/src/value/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::str::FromStr;

use anyhow::anyhow;
use rand::distributions::Bernoulli;
use rand::distr::Bernoulli;
use serde_json::Value;

pub fn as_random_ratio(value: &Value) -> anyhow::Result<Bernoulli> {
Expand Down
6 changes: 3 additions & 3 deletions lib/g3-types/src/collection/selective_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::str::FromStr;
use std::sync::atomic;

use metrohash::MetroHash64;
use rand::seq::SliceRandom;
use rand::seq::IndexedRandom;
use smallvec::SmallVec;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -166,7 +166,7 @@ impl<T: SelectiveItem> SelectiveVec<T> {
0 => panic_on_empty!(),
1 => &self.inner[0],
_ => {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
if self.weighted {
self.inner
.choose_weighted(&mut rng, |v| v.weight())
Expand All @@ -185,7 +185,7 @@ impl<T: SelectiveItem> SelectiveVec<T> {
_ => {
let len = self.inner.len().min(n);

let mut rng = rand::thread_rng();
let mut rng = rand::rng();
if self.weighted {
self.inner
.choose_multiple_weighted(&mut rng, len, |v| v.weight())
Expand Down
2 changes: 1 addition & 1 deletion lib/g3-yaml/src/value/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::str::FromStr;

use anyhow::anyhow;
use rand::distributions::Bernoulli;
use rand::distr::Bernoulli;
use yaml_rust::Yaml;

pub fn as_random_ratio(value: &Yaml) -> anyhow::Result<Bernoulli> {
Expand Down

0 comments on commit e5a0b15

Please sign in to comment.